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 usage record summary #467

Merged
merged 1 commit into from
Aug 23, 2018
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
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ cache:

env:
global:
- STRIPE_MOCK_VERSION=0.25.0
- STRIPE_MOCK_VERSION=0.26.0

before_install:
# Unpack and start stripe-mock so that the test suite can talk to it
Expand Down
1 change: 1 addition & 0 deletions stripe/api_resources/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,4 @@
from stripe.api_resources.topup import Topup
from stripe.api_resources.transfer import Transfer
from stripe.api_resources.usage_record import UsageRecord
from stripe.api_resources.usage_record_summary import UsageRecordSummary
4 changes: 4 additions & 0 deletions stripe/api_resources/subscription_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,7 @@
class SubscriptionItem(CreateableAPIResource, DeletableAPIResource,
UpdateableAPIResource, ListableAPIResource):
OBJECT_NAME = 'subscription_item'

def usage_record_summaries(self, **params):
return self.request(
'get', self.instance_url() + '/usage_record_summaries', params)
7 changes: 7 additions & 0 deletions stripe/api_resources/usage_record_summary.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from __future__ import absolute_import, division, print_function

from stripe.stripe_object import StripeObject


class UsageRecordSummary(StripeObject):
OBJECT_NAME = 'usage_record_summary'
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.Topup.OBJECT_NAME: api_resources.Topup,
api_resources.Transfer.OBJECT_NAME: api_resources.Transfer,
api_resources.UsageRecord.OBJECT_NAME: api_resources.UsageRecord,
api_resources.UsageRecordSummary.OBJECT_NAME:
api_resources.UsageRecordSummary,
}


Expand Down
16 changes: 16 additions & 0 deletions tests/api_resources/test_usage_record_summary.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from __future__ import absolute_import, division, print_function

import stripe


class TestUsageRecordSummary(object):
def test_is_listable(self, request_mock):
resource = stripe.SubscriptionItem.retrieve('si_123')
usage_record_summaries = resource.usage_record_summaries()
request_mock.assert_requested(
'get',
'/v1/subscription_items/si_123/usage_record_summaries'
)
assert isinstance(usage_record_summaries.data, list)
assert isinstance(usage_record_summaries.data[0],
stripe.UsageRecordSummary)
2 changes: 1 addition & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from tests.request_mock import RequestMock


MOCK_MINIMUM_VERSION = '0.25.0'
MOCK_MINIMUM_VERSION = '0.26.0'
MOCK_PORT = os.environ.get('STRIPE_MOCK_PORT', 12111)


Expand Down