Skip to content

Commit

Permalink
feat(api): add methods to prices and invoices (#321)
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-app[bot] authored and stainless-bot committed Jul 17, 2024
1 parent 6dc313b commit 0eaba5f
Show file tree
Hide file tree
Showing 19 changed files with 1,427 additions and 5 deletions.
4 changes: 2 additions & 2 deletions .stats.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
configured_endpoints: 90
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb-3c64831407a4e2d742e93f5ebf78391c83a2ec833e3026518c91515240294e0b.yml
configured_endpoints: 93
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb-36672419987ce3762474f5fe41ded634068ca8780d7e2a835943ff294a88d031.yml
3 changes: 3 additions & 0 deletions api.md
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ from orb.types import Invoice, InvoiceFetchUpcomingResponse
Methods:

- <code title="post /invoices">client.invoices.<a href="./src/orb/resources/invoices.py">create</a>(\*\*<a href="src/orb/types/invoice_create_params.py">params</a>) -> <a href="./src/orb/types/invoice.py">Invoice</a></code>
- <code title="put /invoices/{invoice_id}">client.invoices.<a href="./src/orb/resources/invoices.py">update</a>(invoice_id, \*\*<a href="src/orb/types/invoice_update_params.py">params</a>) -> <a href="./src/orb/types/invoice.py">Invoice</a></code>
- <code title="get /invoices">client.invoices.<a href="./src/orb/resources/invoices.py">list</a>(\*\*<a href="src/orb/types/invoice_list_params.py">params</a>) -> <a href="./src/orb/types/invoice.py">SyncPage[Invoice]</a></code>
- <code title="get /invoices/{invoice_id}">client.invoices.<a href="./src/orb/resources/invoices.py">fetch</a>(invoice_id) -> <a href="./src/orb/types/invoice.py">Invoice</a></code>
- <code title="get /invoices/upcoming">client.invoices.<a href="./src/orb/resources/invoices.py">fetch_upcoming</a>(\*\*<a href="src/orb/types/invoice_fetch_upcoming_params.py">params</a>) -> <a href="./src/orb/types/invoice_fetch_upcoming_response.py">InvoiceFetchUpcomingResponse</a></code>
Expand Down Expand Up @@ -296,6 +297,7 @@ from orb.types import EvaluatePriceGroup, Price, PriceEvaluateResponse
Methods:

- <code title="post /prices">client.prices.<a href="./src/orb/resources/prices/prices.py">create</a>(\*\*<a href="src/orb/types/price_create_params.py">params</a>) -> <a href="./src/orb/types/price.py">Price</a></code>
- <code title="put /prices/{price_id}">client.prices.<a href="./src/orb/resources/prices/prices.py">update</a>(price_id, \*\*<a href="src/orb/types/price_update_params.py">params</a>) -> <a href="./src/orb/types/price.py">Price</a></code>
- <code title="get /prices">client.prices.<a href="./src/orb/resources/prices/prices.py">list</a>(\*\*<a href="src/orb/types/price_list_params.py">params</a>) -> <a href="./src/orb/types/price.py">SyncPage[Price]</a></code>
- <code title="post /prices/{price_id}/evaluate">client.prices.<a href="./src/orb/resources/prices/prices.py">evaluate</a>(price_id, \*\*<a href="src/orb/types/price_evaluate_params.py">params</a>) -> <a href="./src/orb/types/price_evaluate_response.py">PriceEvaluateResponse</a></code>
- <code title="get /prices/{price_id}">client.prices.<a href="./src/orb/resources/prices/prices.py">fetch</a>(price_id) -> <a href="./src/orb/types/price.py">Price</a></code>
Expand All @@ -304,6 +306,7 @@ Methods:

Methods:

- <code title="put /prices/external_price_id/{external_price_id}">client.prices.external_price_id.<a href="./src/orb/resources/prices/external_price_id.py">update</a>(external_price_id, \*\*<a href="src/orb/types/prices/external_price_id_update_params.py">params</a>) -> <a href="./src/orb/types/price.py">Price</a></code>
- <code title="get /prices/external_price_id/{external_price_id}">client.prices.external_price_id.<a href="./src/orb/resources/prices/external_price_id.py">fetch</a>(external_price_id) -> <a href="./src/orb/types/price.py">Price</a></code>

# Subscriptions
Expand Down
115 changes: 115 additions & 0 deletions src/orb/resources/invoices.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
shared_params,
invoice_list_params,
invoice_create_params,
invoice_update_params,
invoice_mark_paid_params,
invoice_fetch_upcoming_params,
)
Expand Down Expand Up @@ -131,6 +132,57 @@ def create(
cast_to=Invoice,
)

def update(
self,
invoice_id: str,
*,
metadata: Optional[Dict[str, Optional[str]]] | 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,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
idempotency_key: str | None = None,
) -> Invoice:
"""This endpoint allows you to update the `metadata` property on an invoice.
If you
pass null for the metadata value, it will clear any existing metadata for that
invoice.
`metadata` can be modified regardless of invoice state.
Args:
metadata: User-specified key/value pairs for the resource. Individual keys can be removed
by setting the value to `null`, and the entire metadata mapping can be cleared
by setting `metadata` to `null`.
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
idempotency_key: Specify a custom idempotency key for this request
"""
if not invoice_id:
raise ValueError(f"Expected a non-empty value for `invoice_id` but received {invoice_id!r}")
return self._put(
f"/invoices/{invoice_id}",
body=maybe_transform({"metadata": metadata}, invoice_update_params.InvoiceUpdateParams),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
idempotency_key=idempotency_key,
),
cast_to=Invoice,
)

def list(
self,
*,
Expand Down Expand Up @@ -546,6 +598,57 @@ async def create(
cast_to=Invoice,
)

async def update(
self,
invoice_id: str,
*,
metadata: Optional[Dict[str, Optional[str]]] | 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,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
idempotency_key: str | None = None,
) -> Invoice:
"""This endpoint allows you to update the `metadata` property on an invoice.
If you
pass null for the metadata value, it will clear any existing metadata for that
invoice.
`metadata` can be modified regardless of invoice state.
Args:
metadata: User-specified key/value pairs for the resource. Individual keys can be removed
by setting the value to `null`, and the entire metadata mapping can be cleared
by setting `metadata` to `null`.
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
idempotency_key: Specify a custom idempotency key for this request
"""
if not invoice_id:
raise ValueError(f"Expected a non-empty value for `invoice_id` but received {invoice_id!r}")
return await self._put(
f"/invoices/{invoice_id}",
body=await async_maybe_transform({"metadata": metadata}, invoice_update_params.InvoiceUpdateParams),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
idempotency_key=idempotency_key,
),
cast_to=Invoice,
)

def list(
self,
*,
Expand Down Expand Up @@ -869,6 +972,9 @@ def __init__(self, invoices: Invoices) -> None:
self.create = _legacy_response.to_raw_response_wrapper(
invoices.create,
)
self.update = _legacy_response.to_raw_response_wrapper(
invoices.update,
)
self.list = _legacy_response.to_raw_response_wrapper(
invoices.list,
)
Expand Down Expand Up @@ -896,6 +1002,9 @@ def __init__(self, invoices: AsyncInvoices) -> None:
self.create = _legacy_response.async_to_raw_response_wrapper(
invoices.create,
)
self.update = _legacy_response.async_to_raw_response_wrapper(
invoices.update,
)
self.list = _legacy_response.async_to_raw_response_wrapper(
invoices.list,
)
Expand Down Expand Up @@ -923,6 +1032,9 @@ def __init__(self, invoices: Invoices) -> None:
self.create = to_streamed_response_wrapper(
invoices.create,
)
self.update = to_streamed_response_wrapper(
invoices.update,
)
self.list = to_streamed_response_wrapper(
invoices.list,
)
Expand Down Expand Up @@ -950,6 +1062,9 @@ def __init__(self, invoices: AsyncInvoices) -> None:
self.create = async_to_streamed_response_wrapper(
invoices.create,
)
self.update = async_to_streamed_response_wrapper(
invoices.update,
)
self.list = async_to_streamed_response_wrapper(
invoices.list,
)
Expand Down
127 changes: 126 additions & 1 deletion src/orb/resources/prices/external_price_id.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,22 @@

from __future__ import annotations

from typing import Any, cast
from typing import Any, Dict, Optional, cast

import httpx

from ... import _legacy_response
from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven
from ..._utils import (
maybe_transform,
async_maybe_transform,
)
from ..._compat import cached_property
from ..._resource import SyncAPIResource, AsyncAPIResource
from ..._response import to_streamed_response_wrapper, async_to_streamed_response_wrapper
from ...types.price import Price
from ..._base_client import make_request_options
from ...types.prices import external_price_id_update_params

__all__ = ["ExternalPriceID", "AsyncExternalPriceID"]

Expand All @@ -26,6 +31,60 @@ def with_raw_response(self) -> ExternalPriceIDWithRawResponse:
def with_streaming_response(self) -> ExternalPriceIDWithStreamingResponse:
return ExternalPriceIDWithStreamingResponse(self)

def update(
self,
external_price_id: str,
*,
metadata: Optional[Dict[str, Optional[str]]] | 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,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
idempotency_key: str | None = None,
) -> Price:
"""This endpoint allows you to update the `metadata` property on a price.
If you
pass null for the metadata value, it will clear any existing metadata for that
price.
Args:
metadata: User-specified key/value pairs for the resource. Individual keys can be removed
by setting the value to `null`, and the entire metadata mapping can be cleared
by setting `metadata` to `null`.
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
idempotency_key: Specify a custom idempotency key for this request
"""
if not external_price_id:
raise ValueError(f"Expected a non-empty value for `external_price_id` but received {external_price_id!r}")
return cast(
Price,
self._put(
f"/prices/external_price_id/{external_price_id}",
body=maybe_transform(
{"metadata": metadata}, external_price_id_update_params.ExternalPriceIDUpdateParams
),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
idempotency_key=idempotency_key,
),
cast_to=cast(Any, Price), # Union types cannot be passed in as arguments in the type system
),
)

def fetch(
self,
external_price_id: str,
Expand Down Expand Up @@ -75,6 +134,60 @@ def with_raw_response(self) -> AsyncExternalPriceIDWithRawResponse:
def with_streaming_response(self) -> AsyncExternalPriceIDWithStreamingResponse:
return AsyncExternalPriceIDWithStreamingResponse(self)

async def update(
self,
external_price_id: str,
*,
metadata: Optional[Dict[str, Optional[str]]] | 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,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
idempotency_key: str | None = None,
) -> Price:
"""This endpoint allows you to update the `metadata` property on a price.
If you
pass null for the metadata value, it will clear any existing metadata for that
price.
Args:
metadata: User-specified key/value pairs for the resource. Individual keys can be removed
by setting the value to `null`, and the entire metadata mapping can be cleared
by setting `metadata` to `null`.
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
idempotency_key: Specify a custom idempotency key for this request
"""
if not external_price_id:
raise ValueError(f"Expected a non-empty value for `external_price_id` but received {external_price_id!r}")
return cast(
Price,
await self._put(
f"/prices/external_price_id/{external_price_id}",
body=await async_maybe_transform(
{"metadata": metadata}, external_price_id_update_params.ExternalPriceIDUpdateParams
),
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
idempotency_key=idempotency_key,
),
cast_to=cast(Any, Price), # Union types cannot be passed in as arguments in the type system
),
)

async def fetch(
self,
external_price_id: str,
Expand Down Expand Up @@ -119,6 +232,9 @@ class ExternalPriceIDWithRawResponse:
def __init__(self, external_price_id: ExternalPriceID) -> None:
self._external_price_id = external_price_id

self.update = _legacy_response.to_raw_response_wrapper(
external_price_id.update,
)
self.fetch = _legacy_response.to_raw_response_wrapper(
external_price_id.fetch,
)
Expand All @@ -128,6 +244,9 @@ class AsyncExternalPriceIDWithRawResponse:
def __init__(self, external_price_id: AsyncExternalPriceID) -> None:
self._external_price_id = external_price_id

self.update = _legacy_response.async_to_raw_response_wrapper(
external_price_id.update,
)
self.fetch = _legacy_response.async_to_raw_response_wrapper(
external_price_id.fetch,
)
Expand All @@ -137,6 +256,9 @@ class ExternalPriceIDWithStreamingResponse:
def __init__(self, external_price_id: ExternalPriceID) -> None:
self._external_price_id = external_price_id

self.update = to_streamed_response_wrapper(
external_price_id.update,
)
self.fetch = to_streamed_response_wrapper(
external_price_id.fetch,
)
Expand All @@ -146,6 +268,9 @@ class AsyncExternalPriceIDWithStreamingResponse:
def __init__(self, external_price_id: AsyncExternalPriceID) -> None:
self._external_price_id = external_price_id

self.update = async_to_streamed_response_wrapper(
external_price_id.update,
)
self.fetch = async_to_streamed_response_wrapper(
external_price_id.fetch,
)
Loading

0 comments on commit 0eaba5f

Please sign in to comment.