Skip to content
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 .fern/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
}
]
},
"originGitCommit": "067e0ade1fa8f371bf795e252e5c2f5049e8756d",
"originGitCommit": "1d6a1c9cf0e1d72ea8ede6e7e8f84d35ffbd8be3",
"originGitCommitIsDirty": false,
"invokedBy": "ci",
"requestedVersion": "1.4.2",
Expand Down
8 changes: 7 additions & 1 deletion .fern/replay.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

941 changes: 538 additions & 403 deletions poetry.lock

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions src/schematic/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@
BillingCustomerWithSubscriptionsResponseData,
BillingLinkedResourceResponseData,
BillingMeterResponseData,
BillingPlanCreditGrantBillingMode,
BillingPlanCreditGrantPriceTierResponseData,
BillingPlanCreditGrantResetCadence,
BillingPlanCreditGrantResetStart,
BillingPlanCreditGrantResetType,
Expand Down Expand Up @@ -177,6 +179,7 @@
CreditEventType,
CreditGrantDetail,
CreditGrantExpiryRequestBody,
CreditGrantPriceTierRequestBody,
CreditGrantSortOrder,
CreditLeaseResponseData,
CreditReservationResponseData,
Expand Down Expand Up @@ -990,6 +993,8 @@
"BillingCustomerWithSubscriptionsResponseData": ".types",
"BillingLinkedResourceResponseData": ".types",
"BillingMeterResponseData": ".types",
"BillingPlanCreditGrantBillingMode": ".types",
"BillingPlanCreditGrantPriceTierResponseData": ".types",
"BillingPlanCreditGrantResetCadence": ".types",
"BillingPlanCreditGrantResetStart": ".types",
"BillingPlanCreditGrantResetType": ".types",
Expand Down Expand Up @@ -1224,6 +1229,7 @@
"CreditEventType": ".types",
"CreditGrantDetail": ".types",
"CreditGrantExpiryRequestBody": ".types",
"CreditGrantPriceTierRequestBody": ".types",
"CreditGrantSortOrder": ".types",
"CreditLeaseResponseData": ".types",
"CreditReservationResponseData": ".types",
Expand Down Expand Up @@ -1922,6 +1928,8 @@ def __dir__():
"BillingCustomerWithSubscriptionsResponseData",
"BillingLinkedResourceResponseData",
"BillingMeterResponseData",
"BillingPlanCreditGrantBillingMode",
"BillingPlanCreditGrantPriceTierResponseData",
"BillingPlanCreditGrantResetCadence",
"BillingPlanCreditGrantResetStart",
"BillingPlanCreditGrantResetType",
Expand Down Expand Up @@ -2156,6 +2164,7 @@ def __dir__():
"CreditEventType",
"CreditGrantDetail",
"CreditGrantExpiryRequestBody",
"CreditGrantPriceTierRequestBody",
"CreditGrantSortOrder",
"CreditLeaseResponseData",
"CreditReservationResponseData",
Expand Down
103 changes: 103 additions & 0 deletions src/schematic/credits/client.py

Large diffs are not rendered by default.

111 changes: 111 additions & 0 deletions src/schematic/credits/raw_client.py

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions src/schematic/types/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@
from .billing_customer_with_subscriptions_response_data import BillingCustomerWithSubscriptionsResponseData
from .billing_linked_resource_response_data import BillingLinkedResourceResponseData
from .billing_meter_response_data import BillingMeterResponseData
from .billing_plan_credit_grant_billing_mode import BillingPlanCreditGrantBillingMode
from .billing_plan_credit_grant_price_tier_response_data import BillingPlanCreditGrantPriceTierResponseData
from .billing_plan_credit_grant_reset_cadence import BillingPlanCreditGrantResetCadence
from .billing_plan_credit_grant_reset_start import BillingPlanCreditGrantResetStart
from .billing_plan_credit_grant_reset_type import BillingPlanCreditGrantResetType
Expand Down Expand Up @@ -180,6 +182,7 @@
from .credit_event_type import CreditEventType
from .credit_grant_detail import CreditGrantDetail
from .credit_grant_expiry_request_body import CreditGrantExpiryRequestBody
from .credit_grant_price_tier_request_body import CreditGrantPriceTierRequestBody
from .credit_grant_sort_order import CreditGrantSortOrder
from .credit_lease_response_data import CreditLeaseResponseData
from .credit_reservation_response_data import CreditReservationResponseData
Expand Down Expand Up @@ -533,6 +536,8 @@
"BillingCustomerWithSubscriptionsResponseData": ".billing_customer_with_subscriptions_response_data",
"BillingLinkedResourceResponseData": ".billing_linked_resource_response_data",
"BillingMeterResponseData": ".billing_meter_response_data",
"BillingPlanCreditGrantBillingMode": ".billing_plan_credit_grant_billing_mode",
"BillingPlanCreditGrantPriceTierResponseData": ".billing_plan_credit_grant_price_tier_response_data",
"BillingPlanCreditGrantResetCadence": ".billing_plan_credit_grant_reset_cadence",
"BillingPlanCreditGrantResetStart": ".billing_plan_credit_grant_reset_start",
"BillingPlanCreditGrantResetType": ".billing_plan_credit_grant_reset_type",
Expand Down Expand Up @@ -664,6 +669,7 @@
"CreditEventType": ".credit_event_type",
"CreditGrantDetail": ".credit_grant_detail",
"CreditGrantExpiryRequestBody": ".credit_grant_expiry_request_body",
"CreditGrantPriceTierRequestBody": ".credit_grant_price_tier_request_body",
"CreditGrantSortOrder": ".credit_grant_sort_order",
"CreditLeaseResponseData": ".credit_lease_response_data",
"CreditReservationResponseData": ".credit_reservation_response_data",
Expand Down Expand Up @@ -1037,6 +1043,8 @@ def __dir__():
"BillingCustomerWithSubscriptionsResponseData",
"BillingLinkedResourceResponseData",
"BillingMeterResponseData",
"BillingPlanCreditGrantBillingMode",
"BillingPlanCreditGrantPriceTierResponseData",
"BillingPlanCreditGrantResetCadence",
"BillingPlanCreditGrantResetStart",
"BillingPlanCreditGrantResetType",
Expand Down Expand Up @@ -1168,6 +1176,7 @@ def __dir__():
"CreditEventType",
"CreditGrantDetail",
"CreditGrantExpiryRequestBody",
"CreditGrantPriceTierRequestBody",
"CreditGrantSortOrder",
"CreditLeaseResponseData",
"CreditReservationResponseData",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# This file was auto-generated by Fern from our API Definition.

import typing

BillingPlanCreditGrantBillingMode = typing.Union[typing.Literal["granted", "billed"], typing.Any]
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# This file was auto-generated by Fern from our API Definition.

import typing

import pydantic
import typing_extensions
from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel
from ..core.serialization import FieldMetadata


class BillingPlanCreditGrantPriceTierResponseData(UniversalBaseModel):
from_: typing_extensions.Annotated[
int,
FieldMetadata(alias="from"),
pydantic.Field(alias="from", description="Lower bound of the tier, in credits per invoice (inclusive)."),
]
"""
Lower bound of the tier, in credits per invoice (inclusive).
"""

per_unit_price: typing.Optional[int] = pydantic.Field(default=None)
"""
Price per credit in this tier, in the plan currency's smallest unit.
"""

per_unit_price_decimal: typing.Optional[str] = pydantic.Field(default=None)
"""
Price per credit in this tier as a decimal, for rates below one cent.
"""

to: typing.Optional[int] = pydantic.Field(default=None)
"""
Upper bound of the tier, in credits per invoice (inclusive). Null marks the final, unbounded tier.
"""

if IS_PYDANTIC_V2:
model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2
else:

class Config:
frozen = True
smart_union = True
extra = pydantic.Extra.allow
34 changes: 34 additions & 0 deletions src/schematic/types/billing_plan_credit_grant_response_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,13 @@
from .billing_credit_expiry_type import BillingCreditExpiryType
from .billing_credit_expiry_unit import BillingCreditExpiryUnit
from .billing_credit_response_data import BillingCreditResponseData
from .billing_plan_credit_grant_billing_mode import BillingPlanCreditGrantBillingMode
from .billing_plan_credit_grant_price_tier_response_data import BillingPlanCreditGrantPriceTierResponseData
from .billing_plan_credit_grant_reset_cadence import BillingPlanCreditGrantResetCadence
from .billing_plan_credit_grant_reset_start import BillingPlanCreditGrantResetStart
from .billing_plan_credit_grant_reset_type import BillingPlanCreditGrantResetType
from .billing_price_response_data import BillingPriceResponseData
from .billing_tiers_mode import BillingTiersMode
from .plan_credit_grant_scaling import PlanCreditGrantScaling
from .preview_object_response_data import PreviewObjectResponseData

Expand Down Expand Up @@ -47,6 +51,11 @@ class BillingPlanCreditGrantResponseData(UniversalBaseModel):

auto_topup_threshold_credits: typing.Optional[int] = None
auto_topup_threshold_percent: typing.Optional[int] = None
billing_mode: BillingPlanCreditGrantBillingMode = pydantic.Field()
"""
Whether the credits are included in the plan price (granted) or billed as their own subscription line at a price per credit (billed).
"""

can_buy_bundles: bool = pydantic.Field()
"""
Deprecated: bundle availability is a per-bundle plan compatibility set now; use compatible_plan_ids on credit bundles instead.
Expand Down Expand Up @@ -113,6 +122,16 @@ class BillingPlanCreditGrantResponseData(UniversalBaseModel):
Decimal form of postpaid_rate_per_unit, for rates finer than one minor unit.
"""

price: typing.Optional[BillingPriceResponseData] = pydantic.Field(default=None)
"""
The Stripe price a billed grant bills through. Minted when the plan version is published.
"""

price_tiers: typing.List[BillingPlanCreditGrantPriceTierResponseData] = pydantic.Field()
"""
Tier table pricing the credits, cheapest bound first. Empty unless billing_mode is billed and the credits are priced on tiers.
"""

reset_cadence: typing.Optional[BillingPlanCreditGrantResetCadence] = None
reset_start: typing.Optional[BillingPlanCreditGrantResetStart] = None
reset_type: typing.Optional[BillingPlanCreditGrantResetType] = None
Expand All @@ -126,6 +145,21 @@ class BillingPlanCreditGrantResponseData(UniversalBaseModel):
Whether the grant is a fixed amount per company, or issued once per license the company holds.
"""

tier_mode: typing.Optional[BillingTiersMode] = pydantic.Field(default=None)
"""
How price_tiers apply: volume prices every credit at the rate of the tier the total lands in, graduated prices each tier's own credits at its own rate. Set only when price_tiers is non-empty.
"""

unit_price: typing.Optional[int] = pydantic.Field(default=None)
"""
Price per credit in the plan currency's smallest unit. Set only when billing_mode is billed and the credits are priced at one rate.
"""

unit_price_decimal: typing.Optional[str] = pydantic.Field(default=None)
"""
Price per credit as a decimal in the plan currency's smallest unit. Set only when billing_mode is billed and the rate is below one cent.
"""

updated_at: dt.datetime

if IS_PYDANTIC_V2:
Expand Down
5 changes: 5 additions & 0 deletions src/schematic/types/company_plan_credit_grant_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@
from .billing_credit_expiry_type import BillingCreditExpiryType
from .billing_credit_expiry_unit import BillingCreditExpiryUnit
from .billing_credit_view import BillingCreditView
from .billing_plan_credit_grant_billing_mode import BillingPlanCreditGrantBillingMode
from .billing_plan_credit_grant_reset_cadence import BillingPlanCreditGrantResetCadence
from .billing_plan_credit_grant_reset_start import BillingPlanCreditGrantResetStart
from .billing_plan_credit_grant_reset_type import BillingPlanCreditGrantResetType
from .billing_price_view import BillingPriceView
from .generic_preview_object import GenericPreviewObject
from .plan_credit_grant_scaling import PlanCreditGrantScaling

Expand All @@ -36,6 +38,8 @@ class CompanyPlanCreditGrantView(UniversalBaseModel):
billing_credit_postpaid_enabled: bool
billing_credit_postpaid_rate_per_unit: typing.Optional[int] = None
billing_credit_postpaid_rate_per_unit_decimal: typing.Optional[str] = None
billing_mode: BillingPlanCreditGrantBillingMode
billing_product_price_id: typing.Optional[str] = None
company_auto_topup_amount: typing.Optional[int] = None
company_auto_topup_enabled: typing.Optional[bool] = None
company_auto_topup_threshold_credits: typing.Optional[int] = None
Expand Down Expand Up @@ -72,6 +76,7 @@ class CompanyPlanCreditGrantView(UniversalBaseModel):
Deprecated field, will be removed in the future. Use Credit.PluralName instead.
"""

price: typing.Optional[BillingPriceView] = None
reset_cadence: typing.Optional[BillingPlanCreditGrantResetCadence] = None
reset_start: typing.Optional[BillingPlanCreditGrantResetStart] = None
reset_type: BillingPlanCreditGrantResetType
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,13 @@
from .billing_credit_auto_topup_availability import BillingCreditAutoTopupAvailability
from .billing_credit_expiry_type import BillingCreditExpiryType
from .billing_credit_expiry_unit import BillingCreditExpiryUnit
from .billing_plan_credit_grant_billing_mode import BillingPlanCreditGrantBillingMode
from .billing_plan_credit_grant_reset_cadence import BillingPlanCreditGrantResetCadence
from .billing_plan_credit_grant_reset_start import BillingPlanCreditGrantResetStart
from .billing_plan_credit_grant_reset_type import BillingPlanCreditGrantResetType
from .billing_tiers_mode import BillingTiersMode
from .credit_auto_topup_amount_type import CreditAutoTopupAmountType
from .credit_grant_price_tier_request_body import CreditGrantPriceTierRequestBody
from .plan_credit_grant_scaling import PlanCreditGrantScaling


Expand All @@ -38,6 +41,11 @@ class CreateBillingPlanCreditGrantRequestBody(UniversalBaseModel):
auto_topup_self_service: typing.Optional[bool] = None
auto_topup_threshold_credits: typing.Optional[int] = None
auto_topup_threshold_percent: typing.Optional[int] = None
billing_mode: typing.Optional[BillingPlanCreditGrantBillingMode] = pydantic.Field(default=None)
"""
Whether the credits are included in the plan price (granted) or billed as their own subscription line at a price per credit (billed). Billed is only available on custom plans. Defaults to granted.
"""

can_buy_bundles: typing.Optional[bool] = pydantic.Field(default=None)
"""
Deprecated: use compatible_plan_ids on credit bundles instead. Still accepted; writes through to the credit's bundle compatibility.
Expand Down Expand Up @@ -80,6 +88,11 @@ class CreateBillingPlanCreditGrantRequestBody(UniversalBaseModel):
Decimal string form of postpaid_rate_per_unit, for rates finer than one minor unit (for example 0.0002). Takes precedence over postpaid_rate_per_unit when both are set, matching how the credit's own price_per_unit_decimal behaves.
"""

price_tiers: typing.Optional[typing.List[CreditGrantPriceTierRequestBody]] = pydantic.Field(default=None)
"""
Tier table pricing the credits on this grant, cheapest bound first, the last tier unbounded. Give this instead of unit_price to charge a rate that changes with the number of credits on the invoice. Requires tier_mode.
"""

reset_cadence: BillingPlanCreditGrantResetCadence
reset_start: BillingPlanCreditGrantResetStart
reset_type: typing.Optional[BillingPlanCreditGrantResetType] = None
Expand All @@ -93,6 +106,21 @@ class CreateBillingPlanCreditGrantRequestBody(UniversalBaseModel):
Whether the grant is a fixed amount per company, or issued once per license the company holds. Defaults to fixed.
"""

tier_mode: typing.Optional[BillingTiersMode] = pydantic.Field(default=None)
"""
How price_tiers apply: volume prices every credit at the rate of the tier the total lands in, graduated prices each tier's own credits at its own rate. Required with price_tiers.
"""

unit_price: typing.Optional[int] = pydantic.Field(default=None)
"""
Price per credit in the plan currency's smallest unit. Required when billing_mode is billed, unless unit_price_decimal or price_tiers is set.
"""

unit_price_decimal: typing.Optional[str] = pydantic.Field(default=None)
"""
Price per credit as a decimal in the plan currency's smallest unit, for prices below one cent.
"""

if IS_PYDANTIC_V2:
model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2
else:
Expand Down
32 changes: 32 additions & 0 deletions src/schematic/types/credit_grant_price_tier_request_body.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# This file was auto-generated by Fern from our API Definition.

import typing

import pydantic
from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel


class CreditGrantPriceTierRequestBody(UniversalBaseModel):
per_unit_price: typing.Optional[int] = pydantic.Field(default=None)
"""
Price per credit in this tier, in the plan currency's smallest unit.
"""

per_unit_price_decimal: typing.Optional[str] = pydantic.Field(default=None)
"""
Price per credit in this tier as a decimal in the plan currency's smallest unit, for prices below one cent.
"""

up_to: typing.Optional[int] = pydantic.Field(default=None)
"""
Inclusive upper bound of this tier, counted in credits per invoice. Null marks the final, unbounded tier.
"""

if IS_PYDANTIC_V2:
model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2
else:

class Config:
frozen = True
smart_union = True
extra = pydantic.Extra.allow
5 changes: 5 additions & 0 deletions src/schematic/types/plan_credit_grant_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@
from .billing_credit_expiry_type import BillingCreditExpiryType
from .billing_credit_expiry_unit import BillingCreditExpiryUnit
from .billing_credit_view import BillingCreditView
from .billing_plan_credit_grant_billing_mode import BillingPlanCreditGrantBillingMode
from .billing_plan_credit_grant_reset_cadence import BillingPlanCreditGrantResetCadence
from .billing_plan_credit_grant_reset_start import BillingPlanCreditGrantResetStart
from .billing_plan_credit_grant_reset_type import BillingPlanCreditGrantResetType
from .billing_price_view import BillingPriceView
from .generic_preview_object import GenericPreviewObject
from .plan_credit_grant_scaling import PlanCreditGrantScaling

Expand All @@ -36,6 +38,8 @@ class PlanCreditGrantView(UniversalBaseModel):
billing_credit_postpaid_enabled: bool
billing_credit_postpaid_rate_per_unit: typing.Optional[int] = None
billing_credit_postpaid_rate_per_unit_decimal: typing.Optional[str] = None
billing_mode: BillingPlanCreditGrantBillingMode
billing_product_price_id: typing.Optional[str] = None
company_credit_amount: int
created_at: dt.datetime
credit: typing.Optional[BillingCreditView] = None
Expand Down Expand Up @@ -69,6 +73,7 @@ class PlanCreditGrantView(UniversalBaseModel):
Deprecated field, will be removed in the future. Use Credit.PluralName instead.
"""

price: typing.Optional[BillingPriceView] = None
reset_cadence: typing.Optional[BillingPlanCreditGrantResetCadence] = None
reset_start: typing.Optional[BillingPlanCreditGrantResetStart] = None
reset_type: BillingPlanCreditGrantResetType
Expand Down
Loading
Loading