Skip to content

Commit af72040

Browse files
authored
Merge branch 'master' into melaniew/python-3.9-support
2 parents 5095cad + b539359 commit af72040

File tree

9 files changed

+68
-6
lines changed

9 files changed

+68
-6
lines changed

CHANGELOG

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
- Added support for Fulfillment.update_tracking ([#432](https://github.com/Shopify/shopify_python_api/pull/432))
22
- Add FulfillmentEvent resource ([#454](https://github.com/Shopify/shopify_python_api/pull/454))
3+
- Fix for being unable to get the len() of a filter ([#456](https://github.com/Shopify/shopify_python_api/pull/456))
4+
- Add ApplicationCredit resource ([#457](https://github.com/Shopify/shopify_python_api/pull/457))
35

46
== Version 8.2.0
57
- [Feature] Add support for Dynamic API Versioning. When the library is initialized, it will now make a request to

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ The [Shopify Admin API](https://shopify.dev/docs/admin-api) Python Library
88
## Usage
99

1010
### Requirements
11-
You should be signed up as a partner on the [Shopify Partners Dashboard](https://partners.shopify.com) so that you can create and manage shopify applications.
11+
You should be signed up as a partner on the [Shopify Partners Dashboard](https://www.shopify.com/partners) so that you can create and manage shopify applications.
1212

1313
### Installation
1414

@@ -21,7 +21,7 @@ pip install --upgrade ShopifyAPI
2121
### Getting Started
2222
#### Public and Custom Apps
2323

24-
1. First create a new application in the [Partners Dashboard](https://partners.shopify.com/apps/new), and retreive your API Key and API Secret Key.
24+
1. First create a new application in the [Partners Dashboard](https://www.shopify.com/partners), and retrieve your API Key and API Secret Key.
2525
1. We then need to supply these keys to the Shopify Session Class so that it knows how to authenticate.
2626

2727
```python

scripts/shopify_api.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,9 @@ def run_task(cls, task=None, *args):
5252
# Allow unambigious abbreviations of tasks
5353
if task not in cls._tasks:
5454
matches = filter(lambda item: item.startswith(task), cls._tasks)
55-
if len(matches) == 1:
56-
task = matches[0]
55+
list_of_matches = list(matches)
56+
if len(list_of_matches) == 1:
57+
task = list_of_matches[0]
5758
else:
5859
sys.stderr.write('Could not find task "%s".\n' % (task))
5960

shopify/resources/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
from .tax_line import TaxLine
1818
from .script_tag import ScriptTag
1919
from .application_charge import ApplicationCharge
20+
from .application_credit import ApplicationCredit
2021
from .recurring_application_charge import RecurringApplicationCharge
2122
from .usage_charge import UsageCharge
2223
from .asset import Asset
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
from ..base import ShopifyResource
2+
3+
class ApplicationCredit(ShopifyResource):
4+
pass

test/application_credit_test.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import shopify
2+
import json
3+
from test.test_helper import TestCase
4+
5+
class ApplicationCreditTest(TestCase):
6+
def test_get_application_credit(self):
7+
self.fake('application_credits/445365009', method='GET', body=self.load_fixture('application_credit'), code=200)
8+
application_credit = shopify.ApplicationCredit.find(445365009)
9+
self.assertEqual('5.00', application_credit.amount)
10+
11+
def test_get_all_application_credits(self):
12+
self.fake('application_credits', method='GET', body=self.load_fixture('application_credits'), code=200)
13+
application_credits = shopify.ApplicationCredit.find()
14+
self.assertEqual(1, len(application_credits))
15+
self.assertEqual(445365009, application_credits[0].id)
16+
17+
def test_create_application_credit(self):
18+
self.fake(
19+
'application_credits',
20+
method='POST',
21+
body=self.load_fixture('application_credit'),
22+
headers={'Content-type': 'application/json'},
23+
code=201
24+
)
25+
26+
application_credit = shopify.ApplicationCredit.create({
27+
'description': 'application credit for refund',
28+
'amount': 5.0
29+
})
30+
31+
expected_body = {
32+
"application_credit": {
33+
"description": "application credit for refund",
34+
"amount": 5.0
35+
}
36+
}
37+
38+
self.assertEqual(expected_body, json.loads(self.http.request.data.decode("utf-8")))

test/fixtures/application_credit.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"application_credit": {
3+
"id": 445365009,
4+
"amount": "5.00",
5+
"description": "credit for application refund",
6+
"test": null
7+
}
8+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"application_credits": [
3+
{
4+
"id": 445365009,
5+
"amount": "5.00",
6+
"description": "credit for application refund",
7+
"test": null
8+
}
9+
]
10+
}

test/fulfillment_event_test.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import shopify
22
from test.test_helper import TestCase
3-
from pyactiveresource.activeresource import ActiveResource
43

54
class FulFillmentEventTest(TestCase):
65
def test_get_fulfillment_event(self):
@@ -21,4 +20,3 @@ def test_error_on_incorrect_status(self):
2120
fulfillment_event = shopify.FulfillmentEvent.find(12584341209251, order_id='2776493818019', fulfillment_id='2608403447971')
2221
fulfillment_event.status = incorrect_status
2322
fulfillment_event.save()
24-

0 commit comments

Comments
 (0)