Skip to content

Commit 0388163

Browse files
Add parent classes into query requests & responses, folderise #79
1 parent 30d1d1d commit 0388163

16 files changed

+103
-328
lines changed

.editorconfig

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# CiviCRM editor configuration normalization
2+
# @see http://editorconfig.org/
3+
4+
# This is the top-most .editorconfig file; do not search in parent directories.
5+
root = true
6+
7+
# All files.
8+
[*]
9+
end_of_line = LF
10+
indent_style = space
11+
indent_size = 4
12+
charset = utf-8
13+
trim_trailing_whitespace = true
14+
insert_final_newline = true

src/AIMGateway.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ public function refund(array $parameters = array())
161161
*/
162162
public function paymentPlansQuery(array $parameters = array())
163163
{
164-
return $this->createRequest('\Omnipay\AuthorizeNet\Message\AIMPaymentPlansQueryRequest', $parameters);
164+
return $this->createRequest('\Omnipay\AuthorizeNet\Message\Query\AIMPaymentPlansQueryRequest', $parameters);
165165
}
166166

167167
/**
@@ -170,7 +170,7 @@ public function paymentPlansQuery(array $parameters = array())
170170
*/
171171
public function paymentPlanQuery(array $parameters = array())
172172
{
173-
return $this->createRequest('\Omnipay\AuthorizeNet\Message\AIMPaymentPlanQueryRequest', $parameters);
173+
return $this->createRequest('\Omnipay\AuthorizeNet\Message\Query\AIMPaymentPlanQueryRequest', $parameters);
174174
}
175175

176176
/**

src/Message/QueryBatchRequest.php renamed to src/Message/Query/AIMAbstractQueryRequest.php

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,12 @@
11
<?php
22

3-
namespace Omnipay\AuthorizeNet\Message;
4-
5-
use Omnipay\Common\CreditCard;
3+
namespace Omnipay\AuthorizeNet\Message\Query;
64

75
/**
8-
* Authorize.Net AIM Authorize Request
6+
* Authorize.Net AIM Abstract Request
97
*/
10-
class QueryBatchRequest extends AIMAbstractRequest
8+
abstract class AIMAbstractQueryRequest extends AIMAbstractRequest
119
{
12-
protected $action = '';
13-
protected $requestType = 'getSettledBatchListRequest';
1410
protected $limit = 1000;
1511
protected $offset = 1;
1612

@@ -62,17 +58,4 @@ public function getData()
6258
$data = $this->getBaseData();
6359
return $data;
6460
}
65-
66-
protected function addTransactionType(\SimpleXMLElement $data)
67-
{
68-
}
69-
70-
public function sendData($data)
71-
{
72-
$headers = array('Content-Type' => 'text/xml; charset=utf-8');
73-
$data = $data->saveXml();
74-
$httpResponse = $this->httpClient->post($this->getEndpoint(), $headers, $data)->send();
75-
76-
return $this->response = new QueryBatchResponse($this, $httpResponse->getBody());
77-
}
7861
}

src/Message/AIMPaymentPlanQueryRequest.php renamed to src/Message/Query/AIMPaymentPlanQueryRequest.php

Lines changed: 2 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
<?php
22

3-
namespace Omnipay\AuthorizeNet\Message;
3+
namespace Omnipay\AuthorizeNet\Message\Query;
44

55
use Omnipay\Common\CreditCard;
66

77
/**
88
* Authorize.Net AIM Authorize Request
99
*/
10-
class AIMPaymentPlanQueryRequest extends AIMAbstractRequest
10+
class AIMPaymentPlanQueryRequest extends AIMAbstractQueryRequest
1111
{
1212
protected $action = '';
1313
protected $requestType = 'ARBGetSubscriptionRequest';
@@ -29,46 +29,6 @@ public function setRecurringReference($recurringReference)
2929
$this->recurringReference = $recurringReference;
3030
}
3131

32-
/**
33-
* Get Limit.
34-
*
35-
* @return int
36-
*/
37-
public function getLimit()
38-
{
39-
return $this->limit;
40-
}
41-
42-
/**
43-
* Set Limit.
44-
*
45-
* @param int $limit
46-
*/
47-
public function setLimit($limit)
48-
{
49-
$this->limit = $limit;
50-
}
51-
52-
/**
53-
* Get offset.
54-
*
55-
* @return int
56-
*/
57-
public function getOffset()
58-
{
59-
return $this->offset;
60-
}
61-
62-
/**
63-
* Set offset.
64-
*
65-
* @param int $offset
66-
*/
67-
public function setOffset($offset)
68-
{
69-
$this->offset = $offset;
70-
}
71-
7232
/**
7333
* Get data to send.
7434
*/

src/Message/AIMPaymentPlanQueryResponse.php renamed to src/Message/Query/AIMPaymentPlanQueryResponse.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace Omnipay\AuthorizeNet\Message;
3+
namespace Omnipay\AuthorizeNet\Message\Query;
44

55
use Omnipay\AuthorizeNet\Model\CardReference;
66
use Omnipay\AuthorizeNet\Model\TransactionReference;
@@ -12,7 +12,7 @@
1212
/**
1313
* Authorize.Net AIM Response
1414
*/
15-
class AIMPaymentPlanQueryResponse extends AbstractResponse
15+
class AIMPaymentPlanQueryResponse extends AbstractQueryResponse
1616
{
1717
protected $subscription;
1818
protected $profile;
@@ -68,8 +68,7 @@ public function getRecurAmount()
6868

6969
public function getRecurReference()
7070
{
71-
echo "he";
72-
print_r($this->subscription);
71+
return $this->subscription;
7372
}
7473

7574
public function getContactReference()

src/Message/AIMPaymentPlansQueryRequest.php renamed to src/Message/Query/AIMPaymentPlansQueryRequest.php

Lines changed: 1 addition & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace Omnipay\AuthorizeNet\Message;
3+
namespace Omnipay\AuthorizeNet\Message\Query;
44

55
use Omnipay\Common\CreditCard;
66

@@ -24,36 +24,6 @@ public function getLimit()
2424
return $this->limit;
2525
}
2626

27-
/**
28-
* Set Limit.
29-
*
30-
* @param int $limit
31-
*/
32-
public function setLimit($limit)
33-
{
34-
$this->limit = $limit;
35-
}
36-
37-
/**
38-
* Get offset.
39-
*
40-
* @return int
41-
*/
42-
public function getOffset()
43-
{
44-
return $this->offset;
45-
}
46-
47-
/**
48-
* Set offset.
49-
*
50-
* @param int $offset
51-
*/
52-
public function setOffset($offset)
53-
{
54-
$this->offset = $offset;
55-
}
56-
5727
/**
5828
* Get data to send.
5929
*/
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace Omnipay\AuthorizeNet\Message;
3+
namespace Omnipay\AuthorizeNet\Message\Query;
44

55
use Omnipay\AuthorizeNet\Model\CardReference;
66
use Omnipay\AuthorizeNet\Model\TransactionReference;
@@ -11,7 +11,7 @@
1111
/**
1212
* Authorize.Net AIM Response
1313
*/
14-
class AIMPaymentPlansQueryResponse extends AbstractResponse
14+
class AIMPaymentPlansQueryResponse extends AbstractQueryResponse
1515
{
1616
public function __construct(AbstractRequest $request, $data)
1717
{
@@ -41,31 +41,4 @@ public function getPlanData()
4141
$result = $this->xml2array($this->data->subscriptionDetails, true);
4242
return $result['subscriptionDetails'][0]['subscriptionDetail'];
4343
}
44-
45-
/**
46-
* http://bookofzeus.com/articles/convert-simplexml-object-into-php-array/
47-
*
48-
* Convert a simpleXMLElement in to an array
49-
*
50-
* @todo this is duplicated from CIMAbstractResponse. Put somewhere shared.
51-
*
52-
* @param \SimpleXMLElement $xml
53-
*
54-
* @return array
55-
*/
56-
public function xml2array(\SimpleXMLElement $xml)
57-
{
58-
$arr = array();
59-
foreach ($xml as $element) {
60-
$tag = $element->getName();
61-
$e = get_object_vars($element);
62-
if (!empty($e)) {
63-
$arr[$tag][] = $element instanceof \SimpleXMLElement ? $this->xml2array($element) : $e;
64-
} else {
65-
$arr[$tag] = trim($element);
66-
}
67-
}
68-
69-
return $arr;
70-
}
7144
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<?php
2+
3+
namespace Omnipay\AuthorizeNet\Message\Query;
4+
5+
use Omnipay\AuthorizeNet\Model\CardReference;
6+
use Omnipay\AuthorizeNet\Model\TransactionReference;
7+
use Omnipay\Common\Exception\InvalidResponseException;
8+
use Omnipay\Common\Message\AbstractRequest;
9+
use Omnipay\Common\Message\AbstractResponse;
10+
use Omnipay\Omnipay;
11+
12+
/**
13+
* Authorize.Net AIM Response
14+
*/
15+
abstract class AbstractQueryResponse extends AbstractResponse
16+
{
17+
/**
18+
* http://bookofzeus.com/articles/convert-simplexml-object-into-php-array/
19+
*
20+
* Convert a simpleXMLElement in to an array
21+
*
22+
* @todo this is duplicated from CIMAbstractResponse. Put somewhere shared.
23+
*
24+
* @param \SimpleXMLElement $xml
25+
*
26+
* @return array
27+
*/
28+
public function xml2array(\SimpleXMLElement $xml)
29+
{
30+
$arr = array();
31+
foreach ($xml as $element) {
32+
$tag = $element->getName();
33+
$e = get_object_vars($element);
34+
if (!empty($e)) {
35+
$arr[$tag][] = $element instanceof \SimpleXMLElement ? $this->xml2array($element) : $e;
36+
} else {
37+
$arr[$tag] = trim($element);
38+
}
39+
}
40+
41+
return $arr;
42+
}
43+
}

src/Message/QueryBatchDetailRequest.php renamed to src/Message/Query/QueryBatchDetailRequest.php

Lines changed: 1 addition & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace Omnipay\AuthorizeNet\Message;
3+
namespace Omnipay\AuthorizeNet\Message\Query;
44

55
use Omnipay\Common\CreditCard;
66

@@ -15,46 +15,6 @@ class QueryBatchDetailRequest extends QueryBatchRequest
1515
protected $offset = 1;
1616
protected $batchID;
1717

18-
/**
19-
* Get Limit.
20-
*
21-
* @return int
22-
*/
23-
public function getLimit()
24-
{
25-
return $this->limit;
26-
}
27-
28-
/**
29-
* Set Limit.
30-
*
31-
* @param int $limit
32-
*/
33-
public function setLimit($limit)
34-
{
35-
$this->limit = $limit;
36-
}
37-
38-
/**
39-
* Get offset.
40-
*
41-
* @return int
42-
*/
43-
public function getOffset()
44-
{
45-
return $this->offset;
46-
}
47-
48-
/**
49-
* Set offset.
50-
*
51-
* @param int $offset
52-
*/
53-
public function setOffset($offset)
54-
{
55-
$this->offset = $offset;
56-
}
57-
5818
/**
5919
* Get data to send.
6020
*/

0 commit comments

Comments
 (0)