Skip to content

Commit 4a0fc1e

Browse files
committed
feat(api): updates (#189)
1 parent 4cfeac2 commit 4a0fc1e

8 files changed

+945
-2
lines changed

src/orb/resources/prices/prices.py

+298-2
Large diffs are not rendered by default.

src/orb/types/plan_create_params.py

+41
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
"PriceNewPlanThresholdTotalAmountPrice",
3333
"PriceNewPlanTieredPackagePrice",
3434
"PriceNewPlanTieredWithMinimumPrice",
35+
"PriceNewPlanUnitWithPercentPrice",
3536
"PriceNewPlanPackageWithAllocationPrice",
3637
]
3738

@@ -632,6 +633,45 @@ class PriceNewPlanTieredWithMinimumPrice(TypedDict, total=False):
632633
"""The property used to group this price on an invoice"""
633634

634635

636+
class PriceNewPlanUnitWithPercentPrice(TypedDict, total=False):
637+
cadence: Required[Literal["annual", "monthly", "quarterly", "one_time"]]
638+
"""The cadence to bill for this price on."""
639+
640+
item_id: Required[str]
641+
"""The id of the item the plan will be associated with."""
642+
643+
model_type: Required[Literal["unit_with_percent"]]
644+
645+
name: Required[str]
646+
"""The name of the price."""
647+
648+
unit_with_percent_config: Required[Dict[str, object]]
649+
650+
billable_metric_id: Optional[str]
651+
"""The id of the billable metric for the price.
652+
653+
Only needed if the price is usage-based.
654+
"""
655+
656+
billed_in_advance: Optional[bool]
657+
"""
658+
If the Price represents a fixed cost, the price will be billed in-advance if
659+
this is true, and in-arrears if this is false.
660+
"""
661+
662+
external_price_id: Optional[str]
663+
"""An alias for the price."""
664+
665+
fixed_price_quantity: Optional[float]
666+
"""
667+
If the Price represents a fixed cost, this represents the quantity of units
668+
applied.
669+
"""
670+
671+
invoice_grouping_key: Optional[str]
672+
"""The property used to group this price on an invoice"""
673+
674+
635675
class PriceNewPlanPackageWithAllocationPrice(TypedDict, total=False):
636676
cadence: Required[Literal["annual", "monthly", "quarterly", "one_time"]]
637677
"""The cadence to bill for this price on."""
@@ -683,5 +723,6 @@ class PriceNewPlanPackageWithAllocationPrice(TypedDict, total=False):
683723
PriceNewPlanThresholdTotalAmountPrice,
684724
PriceNewPlanTieredPackagePrice,
685725
PriceNewPlanTieredWithMinimumPrice,
726+
PriceNewPlanUnitWithPercentPrice,
686727
PriceNewPlanPackageWithAllocationPrice,
687728
]

src/orb/types/price.py

+76
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,11 @@
8484
"PackageWithAllocationPriceItem",
8585
"PackageWithAllocationPriceMaximum",
8686
"PackageWithAllocationPriceMinimum",
87+
"UnitWithPercentPrice",
88+
"UnitWithPercentPriceBillableMetric",
89+
"UnitWithPercentPriceItem",
90+
"UnitWithPercentPriceMaximum",
91+
"UnitWithPercentPriceMinimum",
8792
]
8893

8994

@@ -1057,6 +1062,76 @@ class PackageWithAllocationPrice(BaseModel):
10571062
price_type: Literal["usage_price", "fixed_price"]
10581063

10591064

1065+
class UnitWithPercentPriceBillableMetric(BaseModel):
1066+
id: str
1067+
1068+
1069+
class UnitWithPercentPriceItem(BaseModel):
1070+
id: str
1071+
1072+
name: str
1073+
1074+
1075+
class UnitWithPercentPriceMaximum(BaseModel):
1076+
applies_to_price_ids: List[str]
1077+
"""List of price_ids that this maximum amount applies to.
1078+
1079+
For plan/plan phase maximums, this can be a subset of prices.
1080+
"""
1081+
1082+
maximum_amount: str
1083+
"""Maximum amount applied"""
1084+
1085+
1086+
class UnitWithPercentPriceMinimum(BaseModel):
1087+
applies_to_price_ids: List[str]
1088+
"""List of price_ids that this minimum amount applies to.
1089+
1090+
For plan/plan phase minimums, this can be a subset of prices.
1091+
"""
1092+
1093+
minimum_amount: str
1094+
"""Minimum amount applied"""
1095+
1096+
1097+
class UnitWithPercentPrice(BaseModel):
1098+
id: str
1099+
1100+
billable_metric: Optional[UnitWithPercentPriceBillableMetric] = None
1101+
1102+
cadence: Literal["one_time", "monthly", "quarterly", "annual"]
1103+
1104+
created_at: datetime
1105+
1106+
currency: str
1107+
1108+
discount: Optional[Discount] = None
1109+
1110+
external_price_id: Optional[str] = None
1111+
1112+
fixed_price_quantity: Optional[float] = None
1113+
1114+
item: UnitWithPercentPriceItem
1115+
1116+
maximum: Optional[UnitWithPercentPriceMaximum] = None
1117+
1118+
maximum_amount: Optional[str] = None
1119+
1120+
minimum: Optional[UnitWithPercentPriceMinimum] = None
1121+
1122+
minimum_amount: Optional[str] = None
1123+
1124+
price_model_type: Literal["unit_with_percent"] = FieldInfo(alias="model_type")
1125+
1126+
name: str
1127+
1128+
plan_phase_order: Optional[int] = None
1129+
1130+
price_type: Literal["usage_price", "fixed_price"]
1131+
1132+
unit_with_percent_config: Dict[str, object]
1133+
1134+
10601135
Price = Union[
10611136
UnitPrice,
10621137
PackagePrice,
@@ -1070,4 +1145,5 @@ class PackageWithAllocationPrice(BaseModel):
10701145
TieredPackagePrice,
10711146
TieredWithMinimumPrice,
10721147
PackageWithAllocationPrice,
1148+
UnitWithPercentPrice,
10731149
]

src/orb/types/price_create_params.py

+88
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232
"NewFloatingTieredPackagePrice",
3333
"NewFloatingTieredWithMinimumPrice",
3434
"NewFloatingPackageWithAllocationPrice",
35+
"NewFloatingTieredPackageWithMinimumPrice",
36+
"NewFloatingUnitWithPercentPrice",
3537
]
3638

3739

@@ -669,6 +671,90 @@ class NewFloatingPackageWithAllocationPrice(TypedDict, total=False):
669671
"""The property used to group this price on an invoice"""
670672

671673

674+
class NewFloatingTieredPackageWithMinimumPrice(TypedDict, total=False):
675+
cadence: Required[Literal["annual", "monthly", "quarterly", "one_time"]]
676+
"""The cadence to bill for this price on."""
677+
678+
currency: Required[str]
679+
"""An ISO 4217 currency string for which this price is billed in."""
680+
681+
item_id: Required[str]
682+
"""The id of the item the plan will be associated with."""
683+
684+
model_type: Required[Literal["tiered_package_with_minimum"]]
685+
686+
name: Required[str]
687+
"""The name of the price."""
688+
689+
tiered_package_with_minimum_config: Required[Dict[str, object]]
690+
691+
billable_metric_id: Optional[str]
692+
"""The id of the billable metric for the price.
693+
694+
Only needed if the price is usage-based.
695+
"""
696+
697+
billed_in_advance: Optional[bool]
698+
"""
699+
If the Price represents a fixed cost, the price will be billed in-advance if
700+
this is true, and in-arrears if this is false.
701+
"""
702+
703+
external_price_id: Optional[str]
704+
"""An alias for the price."""
705+
706+
fixed_price_quantity: Optional[float]
707+
"""
708+
If the Price represents a fixed cost, this represents the quantity of units
709+
applied.
710+
"""
711+
712+
invoice_grouping_key: Optional[str]
713+
"""The property used to group this price on an invoice"""
714+
715+
716+
class NewFloatingUnitWithPercentPrice(TypedDict, total=False):
717+
cadence: Required[Literal["annual", "monthly", "quarterly", "one_time"]]
718+
"""The cadence to bill for this price on."""
719+
720+
currency: Required[str]
721+
"""An ISO 4217 currency string for which this price is billed in."""
722+
723+
item_id: Required[str]
724+
"""The id of the item the plan will be associated with."""
725+
726+
model_type: Required[Literal["unit_with_percent"]]
727+
728+
name: Required[str]
729+
"""The name of the price."""
730+
731+
unit_with_percent_config: Required[Dict[str, object]]
732+
733+
billable_metric_id: Optional[str]
734+
"""The id of the billable metric for the price.
735+
736+
Only needed if the price is usage-based.
737+
"""
738+
739+
billed_in_advance: Optional[bool]
740+
"""
741+
If the Price represents a fixed cost, the price will be billed in-advance if
742+
this is true, and in-arrears if this is false.
743+
"""
744+
745+
external_price_id: Optional[str]
746+
"""An alias for the price."""
747+
748+
fixed_price_quantity: Optional[float]
749+
"""
750+
If the Price represents a fixed cost, this represents the quantity of units
751+
applied.
752+
"""
753+
754+
invoice_grouping_key: Optional[str]
755+
"""The property used to group this price on an invoice"""
756+
757+
672758
PriceCreateParams = Union[
673759
NewFloatingUnitPrice,
674760
NewFloatingPackagePrice,
@@ -682,4 +768,6 @@ class NewFloatingPackageWithAllocationPrice(TypedDict, total=False):
682768
NewFloatingTieredPackagePrice,
683769
NewFloatingTieredWithMinimumPrice,
684770
NewFloatingPackageWithAllocationPrice,
771+
NewFloatingTieredPackageWithMinimumPrice,
772+
NewFloatingUnitWithPercentPrice,
685773
]

src/orb/types/subscription_create_params.py

+51
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@
4848
"PriceOverrideOverrideTieredWithMinimumPriceDiscount",
4949
"PriceOverrideOverridePackageWithAllocationPrice",
5050
"PriceOverrideOverridePackageWithAllocationPriceDiscount",
51+
"PriceOverrideOverrideUnitWithPercentPrice",
52+
"PriceOverrideOverrideUnitWithPercentPriceDiscount",
5153
]
5254

5355

@@ -813,6 +815,54 @@ class PriceOverrideOverridePackageWithAllocationPrice(TypedDict, total=False):
813815
"""The subscription's override minimum amount for the plan."""
814816

815817

818+
class PriceOverrideOverrideUnitWithPercentPriceDiscount(TypedDict, total=False):
819+
discount_type: Required[Literal["percentage", "trial", "usage", "amount"]]
820+
821+
amount_discount: Optional[str]
822+
"""Only available if discount_type is `amount`."""
823+
824+
applies_to_price_ids: Optional[List[str]]
825+
"""List of price_ids that this discount applies to.
826+
827+
For plan/plan phase discounts, this can be a subset of prices.
828+
"""
829+
830+
percentage_discount: Optional[float]
831+
"""Only available if discount_type is `percentage`.
832+
833+
This is a number between 0 and 1.
834+
"""
835+
836+
trial_amount_discount: Optional[str]
837+
"""Only available if discount_type is `trial`"""
838+
839+
usage_discount: Optional[float]
840+
"""Only available if discount_type is `usage`.
841+
842+
Number of usage units that this discount is for
843+
"""
844+
845+
846+
class PriceOverrideOverrideUnitWithPercentPrice(TypedDict, total=False):
847+
id: Required[str]
848+
849+
model_type: Required[Literal["unit_with_percent"]]
850+
851+
unit_with_percent_config: Required[Dict[str, object]]
852+
853+
discount: Optional[PriceOverrideOverrideUnitWithPercentPriceDiscount]
854+
"""The subscription's override discount for the plan."""
855+
856+
fixed_price_quantity: Optional[float]
857+
"""The starting quantity of the price, if the price is a fixed price."""
858+
859+
maximum_amount: Optional[str]
860+
"""The subscription's override maximum amount for the plan."""
861+
862+
minimum_amount: Optional[str]
863+
"""The subscription's override minimum amount for the plan."""
864+
865+
816866
PriceOverride = Union[
817867
PriceOverrideOverrideUnitPrice,
818868
PriceOverrideOverridePackagePrice,
@@ -826,4 +876,5 @@ class PriceOverrideOverridePackageWithAllocationPrice(TypedDict, total=False):
826876
PriceOverrideOverrideTieredPackagePrice,
827877
PriceOverrideOverrideTieredWithMinimumPrice,
828878
PriceOverrideOverridePackageWithAllocationPrice,
879+
PriceOverrideOverrideUnitWithPercentPrice,
829880
]

0 commit comments

Comments
 (0)