Skip to content

Commit

Permalink
feat(api): manual updates (#45)
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-app[bot] committed Feb 16, 2025
1 parent 8a5f94a commit 578ba4a
Show file tree
Hide file tree
Showing 7 changed files with 64 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .stats.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
configured_endpoints: 30
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/terminal%2Fterminal-628874ec2e5b758af40534d51d43f95fed9f211b93e27ce9a0a48b48fad01035.yml
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/terminal%2Fterminal-d05a14360ad19c97c022f9f0fbc0e129c234aa471d5e4446f38ff07b97cef937.yml
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ from terminal_shop import Terminal
client = Terminal(
bearer_token=os.environ.get("TERMINAL_BEARER_TOKEN"), # This is the default and can be omitted
# defaults to "production".
environment="sandbox",
environment="dev",
)

product = client.product.list()
Expand All @@ -54,7 +54,7 @@ from terminal_shop import AsyncTerminal
client = AsyncTerminal(
bearer_token=os.environ.get("TERMINAL_BEARER_TOKEN"), # This is the default and can be omitted
# defaults to "production".
environment="sandbox",
environment="dev",
)


Expand Down
14 changes: 7 additions & 7 deletions src/terminal_shop/_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@

ENVIRONMENTS: Dict[str, str] = {
"production": "https://api.terminal.shop/",
"sandbox": "https://sandbox.terminal.shop/",
"dev": "https://api.dev.terminal.shop/",
}


Expand All @@ -69,13 +69,13 @@ class Terminal(SyncAPIClient):
# client options
bearer_token: str

_environment: Literal["production", "sandbox"] | NotGiven
_environment: Literal["production", "dev"] | NotGiven

def __init__(
self,
*,
bearer_token: str | None = None,
environment: Literal["production", "sandbox"] | NotGiven = NOT_GIVEN,
environment: Literal["production", "dev"] | NotGiven = NOT_GIVEN,
base_url: str | httpx.URL | None | NotGiven = NOT_GIVEN,
timeout: Union[float, Timeout, None, NotGiven] = NOT_GIVEN,
max_retries: int = DEFAULT_MAX_RETRIES,
Expand Down Expand Up @@ -182,7 +182,7 @@ def copy(
self,
*,
bearer_token: str | None = None,
environment: Literal["production", "sandbox"] | None = None,
environment: Literal["production", "dev"] | None = None,
base_url: str | httpx.URL | None = None,
timeout: float | Timeout | None | NotGiven = NOT_GIVEN,
http_client: httpx.Client | None = None,
Expand Down Expand Up @@ -283,13 +283,13 @@ class AsyncTerminal(AsyncAPIClient):
# client options
bearer_token: str

_environment: Literal["production", "sandbox"] | NotGiven
_environment: Literal["production", "dev"] | NotGiven

def __init__(
self,
*,
bearer_token: str | None = None,
environment: Literal["production", "sandbox"] | NotGiven = NOT_GIVEN,
environment: Literal["production", "dev"] | NotGiven = NOT_GIVEN,
base_url: str | httpx.URL | None | NotGiven = NOT_GIVEN,
timeout: Union[float, Timeout, None, NotGiven] = NOT_GIVEN,
max_retries: int = DEFAULT_MAX_RETRIES,
Expand Down Expand Up @@ -396,7 +396,7 @@ def copy(
self,
*,
bearer_token: str | None = None,
environment: Literal["production", "sandbox"] | None = None,
environment: Literal["production", "dev"] | None = None,
base_url: str | httpx.URL | None = None,
timeout: float | Timeout | None | NotGiven = NOT_GIVEN,
http_client: httpx.AsyncClient | None = None,
Expand Down
8 changes: 8 additions & 0 deletions src/terminal_shop/resources/subscription.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ def create(
product_variant_id: str,
quantity: int,
next: str | NotGiven = NOT_GIVEN,
schedule: subscription_create_params.Schedule | NotGiven = NOT_GIVEN,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
Expand All @@ -83,6 +84,8 @@ def create(
next: Next shipment and billing date for the subscription.
schedule: Schedule of the subscription.
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
Expand All @@ -102,6 +105,7 @@ def create(
"product_variant_id": product_variant_id,
"quantity": quantity,
"next": next,
"schedule": schedule,
},
subscription_create_params.SubscriptionCreateParams,
),
Expand Down Expand Up @@ -196,6 +200,7 @@ async def create(
product_variant_id: str,
quantity: int,
next: str | NotGiven = NOT_GIVEN,
schedule: subscription_create_params.Schedule | NotGiven = NOT_GIVEN,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
Expand All @@ -221,6 +226,8 @@ async def create(
next: Next shipment and billing date for the subscription.
schedule: Schedule of the subscription.
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
Expand All @@ -240,6 +247,7 @@ async def create(
"product_variant_id": product_variant_id,
"quantity": quantity,
"next": next,
"schedule": schedule,
},
subscription_create_params.SubscriptionCreateParams,
),
Expand Down
22 changes: 19 additions & 3 deletions src/terminal_shop/types/subscription.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,26 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

from typing import Optional
from typing_extensions import Literal
from typing import Union, Optional
from typing_extensions import Literal, TypeAlias

from pydantic import Field as FieldInfo

from .._models import BaseModel

__all__ = ["Subscription"]
__all__ = ["Subscription", "Schedule", "ScheduleType", "ScheduleUnionMember1"]


class ScheduleType(BaseModel):
type: Literal["fixed"]


class ScheduleUnionMember1(BaseModel):
interval: int

type: Literal["weekly"]


Schedule: TypeAlias = Union[ScheduleType, ScheduleUnionMember1]


class Subscription(BaseModel):
Expand All @@ -31,3 +44,6 @@ class Subscription(BaseModel):

next: Optional[str] = None
"""Next shipment and billing date for the subscription."""

schedule: Optional[Schedule] = None
"""Schedule of the subscription."""
21 changes: 19 additions & 2 deletions src/terminal_shop/types/subscription_create_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@

from __future__ import annotations

from typing_extensions import Literal, Required, Annotated, TypedDict
from typing import Union
from typing_extensions import Literal, Required, Annotated, TypeAlias, TypedDict

from .._utils import PropertyInfo

__all__ = ["SubscriptionCreateParams"]
__all__ = ["SubscriptionCreateParams", "Schedule", "ScheduleType", "ScheduleUnionMember1"]


class SubscriptionCreateParams(TypedDict, total=False):
Expand All @@ -30,3 +31,19 @@ class SubscriptionCreateParams(TypedDict, total=False):

next: str
"""Next shipment and billing date for the subscription."""

schedule: Schedule
"""Schedule of the subscription."""


class ScheduleType(TypedDict, total=False):
type: Required[Literal["fixed"]]


class ScheduleUnionMember1(TypedDict, total=False):
interval: Required[int]

type: Required[Literal["weekly"]]


Schedule: TypeAlias = Union[ScheduleType, ScheduleUnionMember1]
8 changes: 8 additions & 0 deletions tests/api_resources/test_subscription.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ def test_method_create_with_all_params(self, client: Terminal) -> None:
product_variant_id="var_XXXXXXXXXXXXXXXXXXXXXXXXX",
quantity=1,
next="2025-02-01T19:36:19.000Z",
schedule={
"interval": 3,
"type": "weekly",
},
)
assert_matches_type(SubscriptionCreateResponse, subscription, path=["response"])

Expand Down Expand Up @@ -169,6 +173,10 @@ async def test_method_create_with_all_params(self, async_client: AsyncTerminal)
product_variant_id="var_XXXXXXXXXXXXXXXXXXXXXXXXX",
quantity=1,
next="2025-02-01T19:36:19.000Z",
schedule={
"interval": 3,
"type": "weekly",
},
)
assert_matches_type(SubscriptionCreateResponse, subscription, path=["response"])

Expand Down

0 comments on commit 578ba4a

Please sign in to comment.