Skip to content

Commit 24ff4e4

Browse files
authored
Merge branch 'master' into master
2 parents d0e7fe7 + d83f6d7 commit 24ff4e4

9 files changed

+145
-5
lines changed

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -485,6 +485,15 @@ The custom methods are specific to some resources which may not be available for
485485
- [current()](https://help.shopify.com/api/reference/user#current)
486486
Get the current logged-in user
487487

488+
### Shopify API features headers
489+
To send `X-Shopify-Api-Features` headers while using the SDK, you can use the following:
490+
491+
```
492+
$config['ShopifyApiFeatures'] = ['include-presentment-prices'];
493+
$shopify = new PHPShopify\ShopifySDK($config);
494+
```
495+
496+
488497
## Reference
489498
- [Shopify API Reference](https://help.shopify.com/api/reference/)
490499

lib/Balance.php

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<?php
2+
/**
3+
* Created by PhpStorm.
4+
* @author Robert Jacobson <rjacobson@thexroadz.com>
5+
* @author Matthew Crigger <mcrigger@thexroadz.com>
6+
*
7+
* @see https://help.shopify.com/en/api/reference/shopify_payments/balance Shopify API Reference for Shopify Payment Balance
8+
*/
9+
10+
namespace PHPShopify;
11+
12+
/**
13+
* --------------------------------------------------------------------------
14+
* ShopifyPayment -> Child Resources
15+
* --------------------------------------------------------------------------
16+
*
17+
*
18+
*/
19+
class Balance extends ShopifyResource
20+
{
21+
/**
22+
* @inheritDoc
23+
*/
24+
protected $resourceKey = 'balance';
25+
26+
/**
27+
* Get the pluralized version of the resource key
28+
*
29+
* Normally its the same as $resourceKey appended with 's', when it's different, the specific resource class will override this function
30+
*
31+
* @return string
32+
*/
33+
protected function pluralizeKey()
34+
{
35+
return $this->resourceKey;
36+
}
37+
38+
/**
39+
* If the resource is read only. (No POST / PUT / DELETE actions)
40+
*
41+
* @var boolean
42+
*/
43+
public $readOnly = true;
44+
45+
/**
46+
* @inheritDoc
47+
*/
48+
protected $childResource = array(
49+
'Transactions'
50+
);
51+
}

lib/Customer.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
* --------------------------------------------------------------------------
2323
* Customer -> Custom actions
2424
* --------------------------------------------------------------------------
25-
* @method array search() Search for customers matching supplied query
25+
* @method array search(string $query = '') Search for customers matching supplied query
2626
*/
2727
class Customer extends ShopifyResource
2828
{
@@ -77,4 +77,4 @@ public function account_activation_url($customer_id = 0)
7777
$url = $this->generateUrl(array(), $customer_id.'/account_activation_url');
7878
return $this->post(array(), $url, false);
7979
}
80-
}
80+
}

lib/Payouts.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php
2+
/**
3+
* Created by PhpStorm.
4+
* @author Robert Jacobson <rjacobson@thexroadz.com>
5+
* @author Matthew Crigger <mcrigger@thexroadz.com>
6+
*
7+
* @see https://help.shopify.com/en/api/reference/shopify_payments/payout Shopify API Reference for Shopify Payment Payouts
8+
*/
9+
10+
namespace PHPShopify;
11+
12+
/**
13+
* --------------------------------------------------------------------------
14+
* ShopifyPayment -> Child Resources
15+
* --------------------------------------------------------------------------
16+
*
17+
*
18+
*/
19+
class Payouts extends ShopifyResource
20+
{
21+
/**
22+
* @inheritDoc
23+
*/
24+
protected $resourceKey = 'payout';
25+
}

lib/Refund.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* --------------------------------------------------------------------------
1515
* Refund -> Custom actions
1616
* --------------------------------------------------------------------------
17-
* @method array calculate() Calculate a Refund.
17+
* @method array calculate(array $calculation = null) Calculate a Refund.
1818
*
1919
*/
2020
class Refund extends ShopifyResource
@@ -30,4 +30,4 @@ class Refund extends ShopifyResource
3030
protected $customPostActions = array (
3131
'calculate',
3232
);
33-
}
33+
}

lib/ShopifyPayment.php

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,15 @@
1818
*
1919
* @method ShopifyResource Dispute(integer $id = null)
2020
*
21+
* @property-read ShopifyResource $Balance
22+
*
23+
* @method ShopifyResource Balance(integer $id = null)
24+
*
25+
* @property-read ShopifyResource $Payouts
26+
*
27+
* @method ShopifyResource Payouts(integer $id = null)
28+
*
29+
2130
*/
2231
class ShopifyPayment extends ShopifyResource
2332
{
@@ -26,10 +35,19 @@ class ShopifyPayment extends ShopifyResource
2635
*/
2736
public $resourceKey = 'shopify_payment';
2837

38+
/**
39+
* If the resource is read only. (No POST / PUT / DELETE actions)
40+
*
41+
* @var boolean
42+
*/
43+
public $readOnly = true;
44+
2945
/**
3046
* @inheritDoc
3147
*/
3248
protected $childResource = array(
33-
'Dispute'
49+
'Balance',
50+
'Dispute',
51+
'Payouts',
3452
);
3553
}

lib/ShopifyResource.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,12 @@ public function __construct($id = null, $parentResourceUrl = '')
149149
} elseif (!isset($config['ApiKey']) || !isset($config['Password'])) {
150150
throw new SdkException("Either AccessToken or ApiKey+Password Combination (in case of private API) is required to access the resources. Please check SDK configuration!");
151151
}
152+
153+
if (isset($config['ShopifyApiFeatures'])) {
154+
foreach($config['ShopifyApiFeatures'] as $apiFeature) {
155+
$this->httpHeaders['X-Shopify-Api-Features'] = $apiFeature;
156+
}
157+
}
152158
}
153159

154160
/**

lib/ShopifySDK.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@
146146
* @method ScriptTag ScriptTag(integer $id = null)
147147
* @method ShippingZone ShippingZone(integer $id = null)
148148
* @method Shop Shop(integer $id = null)
149+
* @method ShopifyPayment ShopifyPayment()
149150
* @method SmartCollection SmartCollection(integer $id = null)
150151
* @method Theme Theme(int $id = null)
151152
* @method User User(integer $id = null)
@@ -235,16 +236,20 @@ class ShopifySDK
235236
protected $childResources = array(
236237
'Article' => 'Blog',
237238
'Asset' => 'Theme',
239+
'Balance' => 'ShopifyPayment',
238240
'CustomerAddress' => 'Customer',
241+
'Dispute' => 'ShopifyPayment',
239242
'Fulfillment' => 'Order',
240243
'FulfillmentEvent' => 'Fulfillment',
241244
'OrderRisk' => 'Order',
245+
'Payouts' => 'ShopifyPayment',
242246
'ProductImage' => 'Product',
243247
'ProductVariant' => 'Product',
244248
'DiscountCode' => 'PriceRule',
245249
'Province' => 'Country',
246250
'Refund' => 'Order',
247251
'Transaction' => 'Order',
252+
'Transactions' => 'Balance',
248253
'UsageCharge' => 'RecurringApplicationCharge',
249254
);
250255

lib/Transactions.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
/**
3+
* Created by PhpStorm.
4+
* @author Robert Jacobson <rjacobson@thexroadz.com>
5+
* @author Matthew Crigger <mcrigger@thexroadz.com>
6+
*
7+
* @see https://help.shopify.com/en/api/reference/shopify_payments/transaction Shopify API Reference for Shopify Payment Transactions
8+
*/
9+
10+
namespace PHPShopify;
11+
12+
13+
class Transactions extends ShopifyResource
14+
{
15+
/**
16+
* @inheritDoc
17+
*/
18+
protected $resourceKey = 'transaction';
19+
20+
/**
21+
* If the resource is read only. (No POST / PUT / DELETE actions)
22+
*
23+
* @var boolean
24+
*/
25+
public $readOnly = true;
26+
}

0 commit comments

Comments
 (0)