Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for listing source_transactions #359

Merged
merged 1 commit into from
Oct 26, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions stripe/api_resources/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
from stripe.api_resources.reversal import Reversal
from stripe.api_resources.sku import SKU
from stripe.api_resources.source import Source
from stripe.api_resources.source_transaction import SourceTransaction
from stripe.api_resources.subscription import Subscription
from stripe.api_resources.subscription_item import SubscriptionItem
from stripe.api_resources.three_d_secure import ThreeDSecure
Expand Down
4 changes: 4 additions & 0 deletions stripe/api_resources/source.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,7 @@ def delete(self, **params):
"`Source.detach` method instead",
DeprecationWarning)
self.detach(**params)

def source_transactions(self, **params):
return self.request(
'get', self.instance_url() + '/source_transactions', params)
5 changes: 5 additions & 0 deletions stripe/api_resources/source_transaction.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from stripe.stripe_object import StripeObject


class SourceTransaction(StripeObject):
OBJECT_NAME = 'source_transaction'
19 changes: 19 additions & 0 deletions stripe/test/api_resources/test_source_transaction.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import stripe
from stripe.test.helper import StripeResourceTest


class SourceTransactionTest(StripeResourceTest):
def test_list_source_transactions(self):
source = stripe.Source.construct_from({
'id': 'src_test',
'type': 'ach_credit'
}, 'api_key')

source.source_transactions()

self.requestor_mock.request.assert_called_with(
'get',
'/v1/sources/src_test/source_transactions',
{},
None
)
2 changes: 2 additions & 0 deletions stripe/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,8 @@ def load_object_classes():
api_resources.Reversal.OBJECT_NAME: api_resources.Reversal,
api_resources.SKU.OBJECT_NAME: api_resources.SKU,
api_resources.Source.OBJECT_NAME: api_resources.Source,
api_resources.SourceTransaction.OBJECT_NAME:
api_resources.SourceTransaction,
api_resources.Subscription.OBJECT_NAME: api_resources.Subscription,
api_resources.SubscriptionItem.OBJECT_NAME:
api_resources.SubscriptionItem,
Expand Down