Maileon PHP client  1.5.0
Easily integrate your PHP application with Maileon.
TransactionsService.php
1 <?php
2 
11 
19  public function getTransactionTypesCount() {
20  return $this->get('transactions/types/count');
21  }
22 
36  function getTransactionTypes($page_index = 1, $page_size = 10) {
37  $queryParameters = array(
38  'page_index' => $page_index,
39  'page_size' => $page_size
40  );
41 
42  return $this->get('transactions/types', $queryParameters);
43  }
44 
55  function getTransactionType($id) {
56  return $this->get("transactions/types/" . $id);
57  }
58 
69  function createTransactionType($trt) {
70  return $this->post("transactions/types", $trt -> toXMLString());
71  }
72 
83  function deleteTransactionType($id) {
84  return $this->delete("transactions/types/" . $id);
85  }
86 
101  function createTransactions($transactions, $release = true, $ignoreInvalidEvents = false) {
102  $queryParameters = array(
103  'release' => ($release == true)?'true':'false',
104  'ignore_invalid_transactions' => ($ignoreInvalidEvents == true)?'true':'false'
105  );
106 
108 
109  $result = $this->post("transactions", $data, $queryParameters, "application/json",
110  'com_maileon_api_transactions_ProcessingReports');
111 
112  return $result;
113  }
114 
129  function deleteTransactions($type_id, $before_timestamp = 9223372036854775807) {
130  $queryParameters = array(
131  'type_id' => $type_id,
132  'before_timestamp' => $before_timestamp
133  );
134 
135  return $this->delete("transactions", $queryParameters);
136  }
137 
148  function findTransactionTypeByName($type_name) {
149  //FIXME: more than 1000 transactions
150  $types = $this->getTransactionTypes(1, 1000)->getResult();
151 
152  $type_name = mb_strtolower($type_name);
153 
154  foreach($types as $type) {
155  if(strcmp(mb_strtolower($type->name), $type_name) == 0) {
156  return (int)$type->id;
157  }
158  }
159 
160  return null;
161  }
162 
171  function getRecentTransactions($type_id, $count = 1000, $minExcludedTxId = 0) {
172  if($count < 1 || $count > 2000) { throw new com_maileon_api_MaileonAPIException("the given count is not in the [1..2000] range"); }
173  if($minExcludedTxId < 0) { throw new com_maileon_api_MaileonAPIException("the given $minExcludedTxId must be greater or equal to 0"); }
174 
175  $queryParameters = array(
176  'type_id' => $type_id,
177  'count' => $count,
178  'min_excluded_transaction_id' => $minExcludedTxId
179  );
180 
181  return $this->get("transactions", $queryParameters, "application/json",
182  array('array', 'com_maileon_api_transactions_RecentTransaction'));
183  }
184 }
deleteTransactions($type_id, $before_timestamp=9223372036854775807)
getRecentTransactions($type_id, $count=1000, $minExcludedTxId=0)
createTransactions($transactions, $release=true, $ignoreInvalidEvents=false)
post($resourcePath, $payload="", $queryParameters=array(), $mimeType= 'application/vnd.maileon.api+xml', $deserializationType=null, $contentType=null, $contentLength=null)