Skip to content

Commit b539359

Browse files
authored
Merge pull request #457 from Shopify/paulinakhew-add-applicationcredit
Add application credit
2 parents 9cafb36 + 7fb2996 commit b539359

File tree

7 files changed

+62
-2
lines changed

7 files changed

+62
-2
lines changed

CHANGELOG

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +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))
33
- 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))
45

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

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)