Skip to content

Commit

Permalink
add-revrec-for-shipping-methods
Browse files Browse the repository at this point in the history
  • Loading branch information
8eth committed Feb 13, 2024
1 parent d45d3e8 commit 1865905
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 1 deletion.
3 changes: 3 additions & 0 deletions recurly/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1483,6 +1483,9 @@ class ShippingMethod(Resource):
'name',
'accounting_code',
'tax_code',
'liability_gl_account_id',
'revenue_gl_account_id',
'performance_obligation_id',
'created_at',
'updated_at',
)
Expand Down
22 changes: 22 additions & 0 deletions tests/fixtures/shipping-method/get.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
GET https://api.recurly.com/v2/shipping_methods/shipping2 HTTP/1.1
X-Api-Version: {api-version}
Accept: application/xml
Authorization: Basic YXBpa2V5Og==
User-Agent: {user-agent}


HTTP/1.1 200 OK
Content-Type: application/xml; charset=utf-8

<?xml version="1.0" encoding="UTF-8"?>
<shipping_method href="https://api.recurly.com/v2/shipping_methods/shipping3">
<code>shipping2</code>
<name>shipping 2</name>
<accounting_code>ship</accounting_code>
<tax_code>FR</tax_code>
<liability_gl_account_id>t5ejtge1xw0x</liability_gl_account_id>
<revenue_gl_account_id>t5ejtgf1vxh1</revenue_gl_account_id>
<performance_obligation_id>6</performance_obligation_id>
<created_at type="datetime">2023-07-06T16:57:18Z</created_at>
<updated_at type="datetime">2023-07-06T16:57:18Z</updated_at>
</shipping_method>
35 changes: 35 additions & 0 deletions tests/fixtures/shipping-method/list.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
GET https://api.recurly.com/v2/shipping_methods HTTP/1.1
X-Api-Version: {api-version}
Accept: application/xml
Authorization: Basic YXBpa2V5Og==
User-Agent: {user-agent}


HTTP/1.1 200 OK
Content-Type: application/xml; charset=utf-8

<?xml version="1.0" encoding="UTF-8"?>
<shipping_methods type="array">
<shipping_method href="https://api.recurly.com/v2/shipping_methods/shipping2">
<code>shipping2</code>
<name>shipping 2</name>
<accounting_code>ship</accounting_code>
<tax_code>FR</tax_code>
<liability_gl_account_id>t5ejtge1xw0x</liability_gl_account_id>
<revenue_gl_account_id>t5ejtgf1vxh1</revenue_gl_account_id>
<performance_obligation_id>6</performance_obligation_id>
<created_at type="datetime">2023-07-06T16:57:18Z</created_at>
<updated_at type="datetime">2023-07-06T16:57:18Z</updated_at>
</shipping_method>
<shipping_method href="https://api.recurly.com/v2/shipping_methods/shipping">
<code>shipping</code>
<name>shipping</name>
<accounting_code></accounting_code>
<tax_code></tax_code>
<liability_gl_account_id nil="nil"></liability_gl_account_id>
<revenue_gl_account_id nil="nil"></revenue_gl_account_id>
<performance_obligation_id>4</performance_obligation_id>
<created_at type="datetime">2023-07-05T22:47:07Z</created_at>
<updated_at type="datetime">2023-07-06T18:15:41Z</updated_at>
</shipping_method>
</shipping_methods>
22 changes: 21 additions & 1 deletion tests/test_resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import recurly
from recurly import Account, AddOn, Address, Adjustment, BillingInfo, Coupon, Item, Plan, Redemption, Subscription, \
SubscriptionAddOn, Transaction, MeasuredUnit, Usage, GiftCard, Delivery, ShippingAddress, AccountAcquisition, \
SubscriptionAddOn, Transaction, MeasuredUnit, Usage, GiftCard, Delivery, ShippingAddress, ShippingMethod, AccountAcquisition, \
Purchase, Invoice, InvoiceCollection, CreditPayment, CustomField, ExportDate, ExportDateFile, DunningCampaign, \
DunningCycle, GeneralLedgerAccount, InvoiceTemplate, PerformanceObligation, PlanRampInterval, SubRampInterval, ExternalSubscription, ExternalProduct, \
ExternalProductReference, ExternalPaymentPhase, CustomFieldDefinition, ExternalInvoice, ExternalCharge, ExternalAccount, \
Expand Down Expand Up @@ -3516,6 +3516,26 @@ def test_get_performance_obligation(self):
self.assertEqual(performance_obligation.id, '6')
self.assertEqual(performance_obligation.name, 'Over Time (Daily)')

def test_get_shipping_method(self):
with self.mock_request('shipping-method/get.xml'):
shipping_method = ShippingMethod.get('shipping2')

self.assertEqual(shipping_method.code, 'shipping2')
self.assertEqual(shipping_method.name, 'shipping 2')
self.assertEqual(shipping_method.accounting_code, 'ship')
self.assertEqual(shipping_method.tax_code, 'FR')
self.assertEqual(shipping_method.liability_gl_account_id, 't5ejtge1xw0x')
self.assertEqual(shipping_method.revenue_gl_account_id, 't5ejtgf1vxh1')
self.assertEqual(shipping_method.performance_obligation_id, '6')

def test_list_shipping_methods(self):
with self.mock_request('shipping-method/list.xml'):
shipping_methods = ShippingMethod.all()

self.assertEqual(len(shipping_methods), 2)
self.assertIsInstance(shipping_methods[0], ShippingMethod)
self.assertIsInstance(shipping_methods[1], ShippingMethod)

if __name__ == '__main__':
import unittest
unittest.main()

0 comments on commit 1865905

Please sign in to comment.