652 lines
18 KiB
YAML
652 lines
18 KiB
YAML
overlay: 1.0.0
|
|
info:
|
|
title: CodeSamples overlay for python target
|
|
version: 0.0.0
|
|
actions:
|
|
- target: $["paths"]["/v1/balances.check"]["post"]
|
|
update:
|
|
x-codeSamples:
|
|
- lang: python
|
|
label: Python (SDK)
|
|
source: |-
|
|
from autumn_sdk import Autumn
|
|
|
|
|
|
with Autumn(
|
|
x_api_version="2.1",
|
|
secret_key="<YOUR_BEARER_TOKEN_HERE>",
|
|
) as autumn:
|
|
|
|
res = autumn.check(customer_id="cus_123", feature_id="messages")
|
|
|
|
# Handle response
|
|
print(res)
|
|
- target: $["paths"]["/v1/balances.create"]["post"]
|
|
update:
|
|
x-codeSamples:
|
|
- lang: python
|
|
label: Python (SDK)
|
|
source: |-
|
|
from autumn_sdk import Autumn
|
|
|
|
|
|
with Autumn(
|
|
x_api_version="2.1",
|
|
secret_key="<YOUR_BEARER_TOKEN_HERE>",
|
|
) as autumn:
|
|
|
|
res = autumn.balances.create(customer_id="cus_123", feature_id="api_calls", included=1000, reset={
|
|
"interval": "month",
|
|
})
|
|
|
|
# Handle response
|
|
print(res)
|
|
- target: $["paths"]["/v1/balances.track"]["post"]
|
|
update:
|
|
x-codeSamples:
|
|
- lang: python
|
|
label: Python (SDK)
|
|
source: |-
|
|
from autumn_sdk import Autumn
|
|
|
|
|
|
with Autumn(
|
|
x_api_version="2.1",
|
|
secret_key="<YOUR_BEARER_TOKEN_HERE>",
|
|
) as autumn:
|
|
|
|
res = autumn.track(customer_id="cus_123", feature_id="messages", value=1)
|
|
|
|
# Handle response
|
|
print(res)
|
|
- target: $["paths"]["/v1/balances.update"]["post"]
|
|
update:
|
|
x-codeSamples:
|
|
- lang: python
|
|
label: Python (SDK)
|
|
source: |-
|
|
from autumn_sdk import Autumn
|
|
|
|
|
|
with Autumn(
|
|
x_api_version="2.1",
|
|
secret_key="<YOUR_BEARER_TOKEN_HERE>",
|
|
) as autumn:
|
|
|
|
res = autumn.balances.update(customer_id="cus_123", feature_id="api_calls", remaining=5)
|
|
|
|
# Handle response
|
|
print(res)
|
|
- target: $["paths"]["/v1/billing.attach"]["post"]
|
|
update:
|
|
x-codeSamples:
|
|
- lang: python
|
|
label: Python (SDK)
|
|
source: |-
|
|
from autumn_sdk import Autumn
|
|
|
|
|
|
with Autumn(
|
|
x_api_version="2.1",
|
|
secret_key="<YOUR_BEARER_TOKEN_HERE>",
|
|
) as autumn:
|
|
|
|
res = autumn.billing.attach(customer_id="cus_123", plan_id="pro_plan")
|
|
|
|
# Handle response
|
|
print(res)
|
|
- target: $["paths"]["/v1/billing.multi_attach"]["post"]
|
|
update:
|
|
x-codeSamples:
|
|
- lang: python
|
|
label: Python (SDK)
|
|
source: |-
|
|
from autumn_sdk import Autumn
|
|
|
|
|
|
with Autumn(
|
|
x_api_version="2.1",
|
|
secret_key="<YOUR_BEARER_TOKEN_HERE>",
|
|
) as autumn:
|
|
|
|
res = autumn.billing.multi_attach(customer_id="cus_123", plans=[
|
|
{
|
|
"plan_id": "pro_plan",
|
|
},
|
|
{
|
|
"plan_id": "addon_seats",
|
|
"feature_quantities": [
|
|
{
|
|
"feature_id": "seats",
|
|
"quantity": 5,
|
|
},
|
|
],
|
|
},
|
|
], redirect_mode="if_required")
|
|
|
|
# Handle response
|
|
print(res)
|
|
- target: $["paths"]["/v1/billing.open_customer_portal"]["post"]
|
|
update:
|
|
x-codeSamples:
|
|
- lang: python
|
|
label: Python (SDK)
|
|
source: |-
|
|
from autumn_sdk import Autumn
|
|
|
|
|
|
with Autumn(
|
|
x_api_version="2.1",
|
|
secret_key="<YOUR_BEARER_TOKEN_HERE>",
|
|
) as autumn:
|
|
|
|
res = autumn.billing.open_customer_portal(customer_id="cus_123", return_url="https://useautumn.com")
|
|
|
|
# Handle response
|
|
print(res)
|
|
- target: $["paths"]["/v1/billing.preview_attach"]["post"]
|
|
update:
|
|
x-codeSamples:
|
|
- lang: python
|
|
label: Python (SDK)
|
|
source: |-
|
|
from autumn_sdk import Autumn
|
|
|
|
|
|
with Autumn(
|
|
x_api_version="2.1",
|
|
secret_key="<YOUR_BEARER_TOKEN_HERE>",
|
|
) as autumn:
|
|
|
|
res = autumn.billing.preview_attach(customer_id="cus_123", plan_id="pro_plan")
|
|
|
|
# Handle response
|
|
print(res)
|
|
- target: $["paths"]["/v1/billing.preview_multi_attach"]["post"]
|
|
update:
|
|
x-codeSamples:
|
|
- lang: python
|
|
label: Python (SDK)
|
|
source: |-
|
|
from autumn_sdk import Autumn
|
|
|
|
|
|
with Autumn(
|
|
x_api_version="2.1",
|
|
secret_key="<YOUR_BEARER_TOKEN_HERE>",
|
|
) as autumn:
|
|
|
|
res = autumn.billing.preview_multi_attach(customer_id="cus_123", plans=[
|
|
{
|
|
"plan_id": "pro_plan",
|
|
},
|
|
{
|
|
"plan_id": "addon_seats",
|
|
"feature_quantities": [
|
|
{
|
|
"feature_id": "seats",
|
|
"quantity": 5,
|
|
},
|
|
],
|
|
},
|
|
], redirect_mode="if_required")
|
|
|
|
# Handle response
|
|
print(res)
|
|
- target: $["paths"]["/v1/billing.preview_update"]["post"]
|
|
update:
|
|
x-codeSamples:
|
|
- lang: python
|
|
label: Python (SDK)
|
|
source: |-
|
|
from autumn_sdk import Autumn
|
|
|
|
|
|
with Autumn(
|
|
x_api_version="2.1",
|
|
secret_key="<YOUR_BEARER_TOKEN_HERE>",
|
|
) as autumn:
|
|
|
|
res = autumn.billing.preview_update(customer_id="cus_123", plan_id="pro_plan", feature_quantities=[
|
|
{
|
|
"feature_id": "seats",
|
|
"quantity": 15,
|
|
},
|
|
])
|
|
|
|
# Handle response
|
|
print(res)
|
|
- target: $["paths"]["/v1/billing.setup_payment"]["post"]
|
|
update:
|
|
x-codeSamples:
|
|
- lang: python
|
|
label: Python (SDK)
|
|
source: |-
|
|
from autumn_sdk import Autumn
|
|
|
|
|
|
with Autumn(
|
|
x_api_version="2.1",
|
|
secret_key="<YOUR_BEARER_TOKEN_HERE>",
|
|
) as autumn:
|
|
|
|
res = autumn.billing.setup_payment(customer_id="cus_123", success_url="https://example.com/account/billing")
|
|
|
|
# Handle response
|
|
print(res)
|
|
- target: $["paths"]["/v1/billing.update"]["post"]
|
|
update:
|
|
x-codeSamples:
|
|
- lang: python
|
|
label: Python (SDK)
|
|
source: |-
|
|
from autumn_sdk import Autumn
|
|
|
|
|
|
with Autumn(
|
|
x_api_version="2.1",
|
|
secret_key="<YOUR_BEARER_TOKEN_HERE>",
|
|
) as autumn:
|
|
|
|
res = autumn.billing.update(customer_id="cus_123", plan_id="pro_plan", feature_quantities=[
|
|
{
|
|
"feature_id": "seats",
|
|
"quantity": 10,
|
|
},
|
|
])
|
|
|
|
# Handle response
|
|
print(res)
|
|
- target: $["paths"]["/v1/customers.delete"]["post"]
|
|
update:
|
|
x-codeSamples:
|
|
- lang: python
|
|
label: Python (SDK)
|
|
source: |-
|
|
from autumn_sdk import Autumn
|
|
|
|
|
|
with Autumn(
|
|
x_api_version="2.1",
|
|
secret_key="<YOUR_BEARER_TOKEN_HERE>",
|
|
) as autumn:
|
|
|
|
res = autumn.customers.delete(customer_id="cus_123", delete_in_stripe=False)
|
|
|
|
# Handle response
|
|
print(res)
|
|
- target: $["paths"]["/v1/customers.get_or_create"]["post"]
|
|
update:
|
|
x-codeSamples:
|
|
- lang: python
|
|
label: Python (SDK)
|
|
source: |-
|
|
from autumn_sdk import Autumn
|
|
|
|
|
|
with Autumn(
|
|
x_api_version="2.1",
|
|
secret_key="<YOUR_BEARER_TOKEN_HERE>",
|
|
) as autumn:
|
|
|
|
res = autumn.customers.get_or_create(customer_id="cus_123", name="John Doe", email="john@example.com")
|
|
|
|
# Handle response
|
|
print(res)
|
|
- target: $["paths"]["/v1/customers.list"]["post"]
|
|
update:
|
|
x-codeSamples:
|
|
- lang: python
|
|
label: Python (SDK)
|
|
source: |-
|
|
from autumn_sdk import Autumn
|
|
|
|
|
|
with Autumn(
|
|
x_api_version="2.1",
|
|
secret_key="<YOUR_BEARER_TOKEN_HERE>",
|
|
) as autumn:
|
|
|
|
res = autumn.customers.list(request={})
|
|
|
|
# Handle response
|
|
print(res)
|
|
- target: $["paths"]["/v1/customers.update"]["post"]
|
|
update:
|
|
x-codeSamples:
|
|
- lang: python
|
|
label: Python (SDK)
|
|
source: |-
|
|
from autumn_sdk import Autumn
|
|
|
|
|
|
with Autumn(
|
|
x_api_version="2.1",
|
|
secret_key="<YOUR_BEARER_TOKEN_HERE>",
|
|
) as autumn:
|
|
|
|
res = autumn.customers.update(customer_id="cus_123", name="Jane Doe", email="jane@example.com")
|
|
|
|
# Handle response
|
|
print(res)
|
|
- target: $["paths"]["/v1/entities.create"]["post"]
|
|
update:
|
|
x-codeSamples:
|
|
- lang: python
|
|
label: Python (SDK)
|
|
source: |-
|
|
from autumn_sdk import Autumn
|
|
|
|
|
|
with Autumn(
|
|
x_api_version="2.1",
|
|
secret_key="<YOUR_BEARER_TOKEN_HERE>",
|
|
) as autumn:
|
|
|
|
res = autumn.entities.create(feature_id="seats", customer_id="cus_123", entity_id="seat_42", name="Seat 42")
|
|
|
|
# Handle response
|
|
print(res)
|
|
- target: $["paths"]["/v1/entities.delete"]["post"]
|
|
update:
|
|
x-codeSamples:
|
|
- lang: python
|
|
label: Python (SDK)
|
|
source: |-
|
|
from autumn_sdk import Autumn
|
|
|
|
|
|
with Autumn(
|
|
x_api_version="2.1",
|
|
secret_key="<YOUR_BEARER_TOKEN_HERE>",
|
|
) as autumn:
|
|
|
|
res = autumn.entities.delete(entity_id="seat_42", customer_id="cus_123")
|
|
|
|
# Handle response
|
|
print(res)
|
|
- target: $["paths"]["/v1/entities.get"]["post"]
|
|
update:
|
|
x-codeSamples:
|
|
- lang: python
|
|
label: Python (SDK)
|
|
source: |-
|
|
from autumn_sdk import Autumn
|
|
|
|
|
|
with Autumn(
|
|
x_api_version="2.1",
|
|
secret_key="<YOUR_BEARER_TOKEN_HERE>",
|
|
) as autumn:
|
|
|
|
res = autumn.entities.get(entity_id="seat_42")
|
|
|
|
# Handle response
|
|
print(res)
|
|
- target: $["paths"]["/v1/events.aggregate"]["post"]
|
|
update:
|
|
x-codeSamples:
|
|
- lang: python
|
|
label: Python (SDK)
|
|
source: |-
|
|
from autumn_sdk import Autumn
|
|
|
|
|
|
with Autumn(
|
|
x_api_version="2.1",
|
|
secret_key="<YOUR_BEARER_TOKEN_HERE>",
|
|
) as autumn:
|
|
|
|
res = autumn.events.aggregate(customer_id="cus_123", feature_id="api_calls", range="30d", bin_size="day")
|
|
|
|
# Handle response
|
|
print(res)
|
|
- target: $["paths"]["/v1/events.list"]["post"]
|
|
update:
|
|
x-codeSamples:
|
|
- lang: python
|
|
label: Python (SDK)
|
|
source: |-
|
|
from autumn_sdk import Autumn
|
|
|
|
|
|
with Autumn(
|
|
x_api_version="2.1",
|
|
secret_key="<YOUR_BEARER_TOKEN_HERE>",
|
|
) as autumn:
|
|
|
|
res = autumn.events.list(offset=0, limit=50, customer_id="cus_123")
|
|
|
|
# Handle response
|
|
print(res)
|
|
- target: $["paths"]["/v1/features.create"]["post"]
|
|
update:
|
|
x-codeSamples:
|
|
- lang: python
|
|
label: Python (SDK)
|
|
source: |-
|
|
from autumn_sdk import Autumn
|
|
|
|
|
|
with Autumn(
|
|
x_api_version="2.1",
|
|
secret_key="<YOUR_BEARER_TOKEN_HERE>",
|
|
) as autumn:
|
|
|
|
res = autumn.features.create(name="API Calls", type_="metered", feature_id="api-calls", consumable=True)
|
|
|
|
# Handle response
|
|
print(res)
|
|
- target: $["paths"]["/v1/features.delete"]["post"]
|
|
update:
|
|
x-codeSamples:
|
|
- lang: python
|
|
label: Python (SDK)
|
|
source: |-
|
|
from autumn_sdk import Autumn
|
|
|
|
|
|
with Autumn(
|
|
x_api_version="2.1",
|
|
secret_key="<YOUR_BEARER_TOKEN_HERE>",
|
|
) as autumn:
|
|
|
|
res = autumn.features.delete(feature_id="old-feature")
|
|
|
|
# Handle response
|
|
print(res)
|
|
- target: $["paths"]["/v1/features.get"]["post"]
|
|
update:
|
|
x-codeSamples:
|
|
- lang: python
|
|
label: Python (SDK)
|
|
source: |-
|
|
from autumn_sdk import Autumn
|
|
|
|
|
|
with Autumn(
|
|
x_api_version="2.1",
|
|
secret_key="<YOUR_BEARER_TOKEN_HERE>",
|
|
) as autumn:
|
|
|
|
res = autumn.features.get(feature_id="api-calls")
|
|
|
|
# Handle response
|
|
print(res)
|
|
- target: $["paths"]["/v1/features.list"]["post"]
|
|
update:
|
|
x-codeSamples:
|
|
- lang: python
|
|
label: Python (SDK)
|
|
source: |-
|
|
from autumn_sdk import Autumn
|
|
|
|
|
|
with Autumn(
|
|
x_api_version="2.1",
|
|
secret_key="<YOUR_BEARER_TOKEN_HERE>",
|
|
) as autumn:
|
|
|
|
res = autumn.features.list()
|
|
|
|
# Handle response
|
|
print(res)
|
|
- target: $["paths"]["/v1/features.update"]["post"]
|
|
update:
|
|
x-codeSamples:
|
|
- lang: python
|
|
label: Python (SDK)
|
|
source: |-
|
|
from autumn_sdk import Autumn
|
|
|
|
|
|
with Autumn(
|
|
x_api_version="2.1",
|
|
secret_key="<YOUR_BEARER_TOKEN_HERE>",
|
|
) as autumn:
|
|
|
|
res = autumn.features.update(feature_id="api-calls", name="API Requests", display={
|
|
"singular": "API request",
|
|
"plural": "API requests",
|
|
})
|
|
|
|
# Handle response
|
|
print(res)
|
|
- target: $["paths"]["/v1/plans.create"]["post"]
|
|
update:
|
|
x-codeSamples:
|
|
- lang: python
|
|
label: Python (SDK)
|
|
source: |-
|
|
from autumn_sdk import Autumn
|
|
|
|
|
|
with Autumn(
|
|
x_api_version="2.1",
|
|
secret_key="<YOUR_BEARER_TOKEN_HERE>",
|
|
) as autumn:
|
|
|
|
res = autumn.plans.create(plan_id="free_plan", name="Free", group="", add_on=False, auto_enable=True, items=[
|
|
{
|
|
"feature_id": "messages",
|
|
"included": 100,
|
|
"reset": {
|
|
"interval": "month",
|
|
},
|
|
},
|
|
])
|
|
|
|
# Handle response
|
|
print(res)
|
|
- target: $["paths"]["/v1/plans.delete"]["post"]
|
|
update:
|
|
x-codeSamples:
|
|
- lang: python
|
|
label: Python (SDK)
|
|
source: |-
|
|
from autumn_sdk import Autumn
|
|
|
|
|
|
with Autumn(
|
|
x_api_version="2.1",
|
|
secret_key="<YOUR_BEARER_TOKEN_HERE>",
|
|
) as autumn:
|
|
|
|
res = autumn.plans.delete(plan_id="unused_plan", all_versions=False)
|
|
|
|
# Handle response
|
|
print(res)
|
|
- target: $["paths"]["/v1/plans.get"]["post"]
|
|
update:
|
|
x-codeSamples:
|
|
- lang: python
|
|
label: Python (SDK)
|
|
source: |-
|
|
from autumn_sdk import Autumn
|
|
|
|
|
|
with Autumn(
|
|
x_api_version="2.1",
|
|
secret_key="<YOUR_BEARER_TOKEN_HERE>",
|
|
) as autumn:
|
|
|
|
res = autumn.plans.get(plan_id="pro_plan")
|
|
|
|
# Handle response
|
|
print(res)
|
|
- target: $["paths"]["/v1/plans.list"]["post"]
|
|
update:
|
|
x-codeSamples:
|
|
- lang: python
|
|
label: Python (SDK)
|
|
source: |-
|
|
from autumn_sdk import Autumn
|
|
|
|
|
|
with Autumn(
|
|
x_api_version="2.1",
|
|
secret_key="<YOUR_BEARER_TOKEN_HERE>",
|
|
) as autumn:
|
|
|
|
res = autumn.plans.list(request={})
|
|
|
|
# Handle response
|
|
print(res)
|
|
- target: $["paths"]["/v1/plans.update"]["post"]
|
|
update:
|
|
x-codeSamples:
|
|
- lang: python
|
|
label: Python (SDK)
|
|
source: |-
|
|
from autumn_sdk import Autumn
|
|
|
|
|
|
with Autumn(
|
|
x_api_version="2.1",
|
|
secret_key="<YOUR_BEARER_TOKEN_HERE>",
|
|
) as autumn:
|
|
|
|
res = autumn.plans.update(plan_id="pro_plan", group="", name="Pro Plan (Updated)", price={
|
|
"amount": 15,
|
|
"interval": "month",
|
|
}, archived=False)
|
|
|
|
# Handle response
|
|
print(res)
|
|
- target: $["paths"]["/v1/referrals.create_code"]["post"]
|
|
update:
|
|
x-codeSamples:
|
|
- lang: python
|
|
label: Python (SDK)
|
|
source: |-
|
|
from autumn_sdk import Autumn
|
|
|
|
|
|
with Autumn(
|
|
x_api_version="2.1",
|
|
secret_key="<YOUR_BEARER_TOKEN_HERE>",
|
|
) as autumn:
|
|
|
|
res = autumn.referrals.create_code(customer_id="cus_123", program_id="prog_123")
|
|
|
|
# Handle response
|
|
print(res)
|
|
- target: $["paths"]["/v1/referrals.redeem_code"]["post"]
|
|
update:
|
|
x-codeSamples:
|
|
- lang: python
|
|
label: Python (SDK)
|
|
source: |-
|
|
from autumn_sdk import Autumn
|
|
|
|
|
|
with Autumn(
|
|
x_api_version="2.1",
|
|
secret_key="<YOUR_BEARER_TOKEN_HERE>",
|
|
) as autumn:
|
|
|
|
res = autumn.referrals.redeem_code(code="REF123", customer_id="cus_456")
|
|
|
|
# Handle response
|
|
print(res)
|