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

API Updates #720

Merged
merged 7 commits into from
May 19, 2021
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 .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [2.7, 3.4, 3.5, 3.6, 3.7, 3.8, 3.9, pypy-2.7, pypy-3.7]
python-version: [2.7, 3.5, 3.6, 3.7, 3.8, 3.9, pypy-2.7, pypy-3.7]

steps:
- uses: actions/checkout@v2
Expand Down
3 changes: 1 addition & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ language: python
matrix:
include:
- python: "2.7"
- python: "3.4"
dist: xenial
- python: "3.5"
- python: "3.6"
Expand All @@ -28,7 +27,7 @@ cache:
env:
global:
# If changing this number, please also change it in `tests/conftest.py`.
- STRIPE_MOCK_VERSION=0.103.0
- STRIPE_MOCK_VERSION=0.105.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 @@ -7,6 +7,7 @@

from stripe.api_resources import billing_portal
from stripe.api_resources import checkout
from stripe.api_resources import identity
from stripe.api_resources import issuing
from stripe.api_resources import radar
from stripe.api_resources import reporting
Expand Down
3 changes: 2 additions & 1 deletion stripe/api_resources/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
)
@nested_resource_class_methods("login_link", operations=["create"])
@nested_resource_class_methods(
"person", operations=["create", "retrieve", "update", "delete", "list"]
"person",
operations=["create", "retrieve", "update", "delete", "list"],
)
class Account(
CreateableAPIResource,
Expand Down
4 changes: 3 additions & 1 deletion stripe/api_resources/apple_pay_domain.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@


class ApplePayDomain(
CreateableAPIResource, DeletableAPIResource, ListableAPIResource
CreateableAPIResource,
DeletableAPIResource,
ListableAPIResource,
):
OBJECT_NAME = "apple_pay_domain"

Expand Down
3 changes: 2 additions & 1 deletion stripe/api_resources/application_fee.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@


@nested_resource_class_methods(
"refund", operations=["create", "retrieve", "update", "list"]
"refund",
operations=["create", "retrieve", "update", "list"],
)
class ApplicationFee(ListableAPIResource):
OBJECT_NAME = "application_fee"
Expand Down
4 changes: 3 additions & 1 deletion stripe/api_resources/billing_portal/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@


class Configuration(
CreateableAPIResource, ListableAPIResource, UpdateableAPIResource
CreateableAPIResource,
ListableAPIResource,
UpdateableAPIResource,
):
OBJECT_NAME = "billing_portal.configuration"
4 changes: 3 additions & 1 deletion stripe/api_resources/credit_note.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@

@custom_method("void_credit_note", http_verb="post", http_path="void")
class CreditNote(
CreateableAPIResource, ListableAPIResource, UpdateableAPIResource
CreateableAPIResource,
ListableAPIResource,
UpdateableAPIResource,
):
OBJECT_NAME = "credit_note"

Expand Down
9 changes: 6 additions & 3 deletions stripe/api_resources/customer.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,16 @@

@custom_method("delete_discount", http_verb="delete", http_path="discount")
@nested_resource_class_methods(
"balance_transaction", operations=["create", "retrieve", "update", "list"]
"balance_transaction",
operations=["create", "retrieve", "update", "list"],
)
@nested_resource_class_methods(
"source", operations=["create", "retrieve", "update", "delete", "list"]
"source",
operations=["create", "retrieve", "update", "delete", "list"],
)
@nested_resource_class_methods(
"tax_id", operations=["create", "retrieve", "delete", "list"]
"tax_id",
operations=["create", "retrieve", "delete", "list"],
)
class Customer(
CreateableAPIResource,
Expand Down
4 changes: 3 additions & 1 deletion stripe/api_resources/file_link.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@


class FileLink(
CreateableAPIResource, ListableAPIResource, UpdateableAPIResource
CreateableAPIResource,
ListableAPIResource,
UpdateableAPIResource,
):
OBJECT_NAME = "file_link"
10 changes: 10 additions & 0 deletions stripe/api_resources/identity/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from __future__ import absolute_import, division, print_function

# flake8: noqa

from stripe.api_resources.identity.verification_report import (
VerificationReport,
)
from stripe.api_resources.identity.verification_session import (
VerificationSession,
)
7 changes: 7 additions & 0 deletions stripe/api_resources/identity/verification_report.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.api_resources.abstract import ListableAPIResource


class VerificationReport(ListableAPIResource):
OBJECT_NAME = "identity.verification_report"
29 changes: 29 additions & 0 deletions stripe/api_resources/identity/verification_session.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
from __future__ import absolute_import, division, print_function

from stripe import util
from stripe.api_resources.abstract import CreateableAPIResource
from stripe.api_resources.abstract import ListableAPIResource
from stripe.api_resources.abstract import UpdateableAPIResource
from stripe.api_resources.abstract import custom_method


@custom_method("cancel", http_verb="post")
@custom_method("redact", http_verb="post")
class VerificationSession(
CreateableAPIResource,
ListableAPIResource,
UpdateableAPIResource,
):
OBJECT_NAME = "identity.verification_session"

def cancel(self, idempotency_key=None, **params):
url = self.instance_url() + "/cancel"
headers = util.populate_headers(idempotency_key)
self.refresh_from(self.request("post", url, params, headers))
return self

def redact(self, idempotency_key=None, **params):
url = self.instance_url() + "/redact"
headers = util.populate_headers(idempotency_key)
self.refresh_from(self.request("post", url, params, headers))
return self
4 changes: 3 additions & 1 deletion stripe/api_resources/issuing/cardholder.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@


class Cardholder(
CreateableAPIResource, ListableAPIResource, UpdateableAPIResource
CreateableAPIResource,
ListableAPIResource,
UpdateableAPIResource,
):
OBJECT_NAME = "issuing.cardholder"
4 changes: 3 additions & 1 deletion stripe/api_resources/issuing/dispute.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@

@custom_method("submit", http_verb="post")
class Dispute(
CreateableAPIResource, ListableAPIResource, UpdateableAPIResource
CreateableAPIResource,
ListableAPIResource,
UpdateableAPIResource,
):
OBJECT_NAME = "issuing.dispute"

Expand Down
4 changes: 3 additions & 1 deletion stripe/api_resources/payment_intent.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
@custom_method("capture", http_verb="post")
@custom_method("confirm", http_verb="post")
class PaymentIntent(
CreateableAPIResource, ListableAPIResource, UpdateableAPIResource
CreateableAPIResource,
ListableAPIResource,
UpdateableAPIResource,
):
OBJECT_NAME = "payment_intent"

Expand Down
4 changes: 3 additions & 1 deletion stripe/api_resources/payment_method.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
@custom_method("attach", http_verb="post")
@custom_method("detach", http_verb="post")
class PaymentMethod(
CreateableAPIResource, ListableAPIResource, UpdateableAPIResource
CreateableAPIResource,
ListableAPIResource,
UpdateableAPIResource,
):
OBJECT_NAME = "payment_method"

Expand Down
4 changes: 3 additions & 1 deletion stripe/api_resources/promotion_code.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@


class PromotionCode(
CreateableAPIResource, ListableAPIResource, UpdateableAPIResource
CreateableAPIResource,
ListableAPIResource,
UpdateableAPIResource,
):
OBJECT_NAME = "promotion_code"
4 changes: 3 additions & 1 deletion stripe/api_resources/radar/value_list_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@


class ValueListItem(
CreateableAPIResource, DeletableAPIResource, ListableAPIResource
CreateableAPIResource,
DeletableAPIResource,
ListableAPIResource,
):
OBJECT_NAME = "radar.value_list_item"
4 changes: 3 additions & 1 deletion stripe/api_resources/setup_intent.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
@custom_method("cancel", http_verb="post")
@custom_method("confirm", http_verb="post")
class SetupIntent(
CreateableAPIResource, ListableAPIResource, UpdateableAPIResource
CreateableAPIResource,
ListableAPIResource,
UpdateableAPIResource,
):
OBJECT_NAME = "setup_intent"

Expand Down
4 changes: 3 additions & 1 deletion stripe/api_resources/subscription_schedule.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
@custom_method("cancel", http_verb="post")
@custom_method("release", http_verb="post")
class SubscriptionSchedule(
CreateableAPIResource, ListableAPIResource, UpdateableAPIResource
CreateableAPIResource,
ListableAPIResource,
UpdateableAPIResource,
):
OBJECT_NAME = "subscription_schedule"

Expand Down
4 changes: 3 additions & 1 deletion stripe/api_resources/tax_rate.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@


class TaxRate(
CreateableAPIResource, ListableAPIResource, UpdateableAPIResource
CreateableAPIResource,
ListableAPIResource,
UpdateableAPIResource,
):
OBJECT_NAME = "tax_rate"
7 changes: 5 additions & 2 deletions stripe/api_resources/transfer.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,13 @@

@custom_method("cancel", http_verb="post")
@nested_resource_class_methods(
"reversal", operations=["create", "retrieve", "update", "list"]
"reversal",
operations=["create", "retrieve", "update", "list"],
)
class Transfer(
CreateableAPIResource, ListableAPIResource, UpdateableAPIResource
CreateableAPIResource,
ListableAPIResource,
UpdateableAPIResource,
):
OBJECT_NAME = "transfer"

Expand Down
2 changes: 2 additions & 0 deletions stripe/object_classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
api_resources.File.OBJECT_NAME: api_resources.File,
api_resources.File.OBJECT_NAME_ALT: api_resources.File,
api_resources.FileLink.OBJECT_NAME: api_resources.FileLink,
api_resources.identity.VerificationReport.OBJECT_NAME: api_resources.identity.VerificationReport,
api_resources.identity.VerificationSession.OBJECT_NAME: api_resources.identity.VerificationSession,
api_resources.Invoice.OBJECT_NAME: api_resources.Invoice,
api_resources.InvoiceItem.OBJECT_NAME: api_resources.InvoiceItem,
api_resources.InvoiceLineItem.OBJECT_NAME: api_resources.InvoiceLineItem,
Expand Down
27 changes: 27 additions & 0 deletions tests/api_resources/identity/test_verification_report.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
from __future__ import absolute_import, division, print_function

import stripe


TEST_RESOURCE_ID = "vs_123"


class TestVerificationReport(object):
def test_is_listable(self, request_mock):
resources = stripe.identity.VerificationReport.list()
request_mock.assert_requested(
"get", "/v1/identity/verification_reports"
)
assert isinstance(resources.data, list)
assert isinstance(
resources.data[0], stripe.identity.VerificationReport
)

def test_is_retrievable(self, request_mock):
resource = stripe.identity.VerificationReport.retrieve(
TEST_RESOURCE_ID
)
request_mock.assert_requested(
"get", "/v1/identity/verification_reports/%s" % TEST_RESOURCE_ID
)
assert isinstance(resource, stripe.identity.VerificationReport)
Loading