Skip to content

Commit

Permalink
API Updates for beta branch (#921)
Browse files Browse the repository at this point in the history
  • Loading branch information
richardm-stripe committed Feb 2, 2023
1 parent 1738952 commit ef09950
Show file tree
Hide file tree
Showing 11 changed files with 88 additions and 5 deletions.
7 changes: 6 additions & 1 deletion CHANGELOG.md
@@ -1,9 +1,14 @@
# Changelog

## 5.1.0 - 2023-02-02
* [#920](https://github.com/stripe/stripe-python/pull/920) API Updates
* Add support for `resume` method on resource `Subscription`
* [#913](https://github.com/stripe/stripe-python/pull/913) Pass params into logger.{info,debug}

## 5.1.0b7 - 2023-01-26
* [#917](https://github.com/stripe/stripe-python/pull/917) API Updates for beta branch
* Updated stable APIs to the latest version
* Add support for `list_transactions` method on resource `Tax.Transaction`
* Add support for `list_transactions` method on resource `Tax.Transaction`

## 5.1.0b6 - 2023-01-19
* [#915](https://github.com/stripe/stripe-python/pull/915) API Updates for beta branch
Expand Down
2 changes: 1 addition & 1 deletion OPENAPI_VERSION
@@ -1 +1 @@
v221
v223
4 changes: 4 additions & 0 deletions stripe/api_resources/financial_connections/__init__.py
Expand Up @@ -11,4 +11,8 @@
from stripe.api_resources.financial_connections.account_ownership import (
AccountOwnership,
)
from stripe.api_resources.financial_connections.inferred_balance import (
InferredBalance,
)
from stripe.api_resources.financial_connections.session import Session
from stripe.api_resources.financial_connections.transaction import Transaction
2 changes: 2 additions & 0 deletions stripe/api_resources/financial_connections/account.py
Expand Up @@ -4,8 +4,10 @@

from stripe import util
from stripe.api_resources.abstract import ListableAPIResource
from stripe.api_resources.abstract import nested_resource_class_methods


@nested_resource_class_methods("inferred_balance", operations=["list"])
class Account(ListableAPIResource):
"""
A Financial Connections Account represents an account that exists outside of Stripe, to which you have been granted some degree of access.
Expand Down
13 changes: 13 additions & 0 deletions stripe/api_resources/financial_connections/inferred_balance.py
@@ -0,0 +1,13 @@
# -*- coding: utf-8 -*-
# File generated from our OpenAPI spec
from __future__ import absolute_import, division, print_function

from stripe.api_resources.abstract import ListableAPIResource


class InferredBalance(ListableAPIResource):
"""
A historical balance for the account on a particular day. It may be sourced from a balance snapshot provided by a financial institution, or inferred using transactions data.
"""

OBJECT_NAME = "financial_connections.account_inferred_balance"
13 changes: 13 additions & 0 deletions stripe/api_resources/financial_connections/transaction.py
@@ -0,0 +1,13 @@
# -*- coding: utf-8 -*-
# File generated from our OpenAPI spec
from __future__ import absolute_import, division, print_function

from stripe.api_resources.abstract import ListableAPIResource


class Transaction(ListableAPIResource):
"""
A Transaction represents a real transaction that affects a Financial Connections Account balance.
"""

OBJECT_NAME = "financial_connections.transaction"
31 changes: 31 additions & 0 deletions stripe/api_resources/subscription.py
Expand Up @@ -91,6 +91,37 @@ def delete_discount(self, idempotency_key=None, **params):
params=params,
)

@classmethod
def _cls_resume(
cls,
subscription,
api_key=None,
stripe_version=None,
stripe_account=None,
**params
):
return cls._static_request(
"post",
"/v1/subscriptions/{subscription}/resume".format(
subscription=util.sanitize_id(subscription)
),
api_key=api_key,
stripe_version=stripe_version,
stripe_account=stripe_account,
params=params,
)

@util.class_method_variant("_cls_resume")
def resume(self, idempotency_key=None, **params):
return self._request(
"post",
"/v1/subscriptions/{subscription}/resume".format(
subscription=util.sanitize_id(self.get("id"))
),
idempotency_key=idempotency_key,
params=params,
)

@classmethod
def search(cls, *args, **kwargs):
return cls._search(
Expand Down
2 changes: 2 additions & 0 deletions stripe/object_classes.py
Expand Up @@ -47,7 +47,9 @@
api_resources.financial_connections.Account.OBJECT_NAME: api_resources.financial_connections.Account,
api_resources.financial_connections.AccountOwner.OBJECT_NAME: api_resources.financial_connections.AccountOwner,
api_resources.financial_connections.AccountOwnership.OBJECT_NAME: api_resources.financial_connections.AccountOwnership,
api_resources.financial_connections.InferredBalance.OBJECT_NAME: api_resources.financial_connections.InferredBalance,
api_resources.financial_connections.Session.OBJECT_NAME: api_resources.financial_connections.Session,
api_resources.financial_connections.Transaction.OBJECT_NAME: api_resources.financial_connections.Transaction,
api_resources.FundingInstructions.OBJECT_NAME: api_resources.FundingInstructions,
api_resources.gift_cards.Card.OBJECT_NAME: api_resources.gift_cards.Card,
api_resources.gift_cards.Transaction.OBJECT_NAME: api_resources.gift_cards.Transaction,
Expand Down
4 changes: 2 additions & 2 deletions stripe/util.py
Expand Up @@ -53,14 +53,14 @@ def log_debug(message, **params):
msg = logfmt(dict(message=message, **params))
if _console_log_level() == "debug":
print(msg, file=sys.stderr)
logger.debug(msg)
logger.debug(msg, params)


def log_info(message, **params):
msg = logfmt(dict(message=message, **params))
if _console_log_level() in ["debug", "info"]:
print(msg, file=sys.stderr)
logger.info(msg)
logger.info(msg, params)


def _test_or_live_environment():
Expand Down
11 changes: 11 additions & 0 deletions tests/test_generated_examples.py
Expand Up @@ -489,6 +489,17 @@ def test_account_capability_update(self, request_mock):
"/v1/accounts/acct_xxxxxxxxxxxxx/capabilities/card_payments",
)

def test_subscription_resume(self, request_mock):
stripe.Subscription.resume(
"sub_xxxxxxxxxxxxx",
proration_date=1675400000,
proration_behavior="always_invoice",
)
request_mock.assert_requested(
"post",
"/v1/subscriptions/sub_xxxxxxxxxxxxx/resume",
)

def test_account_person_retrieve(self, request_mock):
stripe.Account.retrieve_person(
"acct_xxxxxxxxxxxxx", "person_xxxxxxxxxxxxx"
Expand Down
4 changes: 3 additions & 1 deletion tests/test_util.py
Expand Up @@ -65,7 +65,9 @@ def log_test_loop(self, test_cases, logging_func, logger_name, mocker):
)
else:
print_mock.assert_not_called()
logger_mock.assert_called_once_with("message='foo \\nbar' y=3")
logger_mock.assert_called_once_with(
"message='foo \\nbar' y=3", {"y": 3}
)
finally:
mocker.stopall()

Expand Down

0 comments on commit ef09950

Please sign in to comment.