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 ScheduledQueryRun #456

Merged
merged 1 commit into from
Jul 27, 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
1 change: 1 addition & 0 deletions stripe/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
# API resources
from stripe.api_resources import * # noqa
from stripe.api_resources import issuing # noqa
from stripe.api_resources import sigma # noqa

# OAuth
from stripe.oauth import OAuth # noqa
Expand Down
5 changes: 5 additions & 0 deletions stripe/api_resources/sigma/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from __future__ import absolute_import, division, print_function

# flake8: noqa

from stripe.api_resources.sigma.scheduled_query_run import ScheduledQueryRun
11 changes: 11 additions & 0 deletions stripe/api_resources/sigma/scheduled_query_run.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from __future__ import absolute_import, division, print_function

from stripe.api_resources.abstract import ListableAPIResource


class ScheduledQueryRun(ListableAPIResource):
OBJECT_NAME = 'scheduled_query_run'
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The object name should really be sigma.scheduled_query_run based on recent API decisions we made. It's not though, similarly to apple pay domains.

The issue is that if we change this in the future, we'll need to have some custom logic for the deserializer which will be tricky. I don't think we have renamed an object before.

This comment is mostly here as food for thoughts though!


@classmethod
def class_url(cls):
return '/v1/sigma/scheduled_query_runs'
2 changes: 2 additions & 0 deletions stripe/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,8 @@ def load_object_classes():
api_resources.RecipientTransfer,
api_resources.Refund.OBJECT_NAME: api_resources.Refund,
api_resources.Reversal.OBJECT_NAME: api_resources.Reversal,
api_resources.sigma.ScheduledQueryRun.OBJECT_NAME:
api_resources.sigma.ScheduledQueryRun,
api_resources.SKU.OBJECT_NAME: api_resources.SKU,
api_resources.Source.OBJECT_NAME: api_resources.Source,
api_resources.SourceTransaction.OBJECT_NAME:
Expand Down
46 changes: 46 additions & 0 deletions tests/api_resources/sigma/test_scheduled_query_run.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
from __future__ import absolute_import, division, print_function

import stripe


TEST_RESOURCE_ID = 'sqr_123'


class TestTransaction(object):
FIXTURE = {
'id': TEST_RESOURCE_ID,
'object': 'scheduled_query_run'
}

def test_is_listable(self, request_mock):
request_mock.stub_request(
'get',
'/v1/sigma/scheduled_query_runs',
{
'object': 'list',
'data': [self.FIXTURE],
}
)
resources = stripe.sigma.ScheduledQueryRun.list()
request_mock.assert_requested(
'get',
'/v1/sigma/scheduled_query_runs'
)
assert isinstance(resources.data, list)
assert isinstance(resources.data[0], stripe.sigma.ScheduledQueryRun)

def test_is_retrievable(self, request_mock):
request_mock.stub_request(
'get',
'/v1/sigma/scheduled_query_runs/%s' % TEST_RESOURCE_ID,
{
'id': '%s' % TEST_RESOURCE_ID,
'object': 'scheduled_query_run'
}
)
resource = stripe.sigma.ScheduledQueryRun.retrieve(TEST_RESOURCE_ID)
request_mock.assert_requested(
'get',
'/v1/sigma/scheduled_query_runs/%s' % TEST_RESOURCE_ID
)
assert isinstance(resource, stripe.sigma.ScheduledQueryRun)