Python client SDK for Orb's API
Project description
orb
SDK Installation
pip install orb-billing
SDK Example Usage
import orb
from orb.models import shared
s = orb.Orb(
security=shared.Security(
api_key_auth="",
),
)
res = s.availability.ping()
if res.ping_response is not None:
# handle response
Available Resources and Operations
availability
- ping - Check availability
coupon
- archive - Archive coupon
- create - Create coupon
- fetch - Fetch coupon
- list - List coupons
- list_subscriptions - List coupon subscriptions
credit
- add_by_external_id - Create ledger entry by external ID
- create - Create ledger entry
- fetch_balance - Fetch customer credit balance
- fetch_balance_by_external_id - Fetch customer credit balance by external customer id
- fetch_ledger - Fetch customer credits ledger
- fetch_ledger_by_external_id - Fetch customer credits ledger by external ID
credit_note
customer
- amend - Amend usage
- amend_by_external_id - Amend usage by external ID
- create - Create customer
- create_balance_transaction - Create customer balance transaction
- delete - Delete customer
- fetch - Fetch customer
- fetch_by_external_id - Fetch customer by external ID
- fetch_costs - Fetch customer costs
- fetch_costs_by_external_id - Fetch customer costs by external ID
- list - List customers
- list_balance_transactions - List balance transactions
- update_by_external_id - Update customer by external ID
- update_customer - Update customer
event
- amend - Amend event
- close_backfill - Close backfill
- create - Create backfill
- deprecate_event - Deprecate event
- fetch - Fetch backfill
- ingest - Ingest events
- list_backfills - List backfills
- revert_backfill - Revert backfill
- search - Search events
invoice
- create - Create a one-off invoice
- create_line_item - Create invoice line item
- fetch - Fetch invoice
- fetch_upcoming - Fetch upcoming invoice
- issue - Issue invoice
- list - List invoices
- mark_invoice_as_paid - Mark invoice as paid
- void - Void invoice
item
metric
plan
- create - Create plan
- fetch - Fetch plan
- fetch_by_external_id - Fetch plan by external ID
- list - List plans
- update_plan - Update plan by id
- update_plan_external - Update plan by external ID
price
- create - Create price
- fetch - Fetch price
- fetch_by_external_id - Fetch price by external price id
- list - List prices
price_interval
- add_edit_price_intervals - Add or edit price intervals
subscription
- cancel - Cancel subscription
- create - Create subscription
- fetch - Fetch subscription
- fetch_costs - Fetch subscription costs
- fetch_schedule - Fetch subscription schedule
- fetch_usage - Fetch subscription usage
- list - List subscriptions
- schedule_plan_change - Schedule plan change
- trigger_phase - Trigger phase
- unschedule_cancellation - Unschedule subscription cancellation
- unschedule_fixed_fee_quantity - Unschedule fixed fee quantity updates
- unschedule_plan_change - Unschedule plan change
- update_fixed_fee_quantity - Update price quantity
Pagination
Some of the endpoints in this SDK support pagination. To use pagination, you make your SDK calls as usual, but the
returned response object will have a Next
method that can be called to pull down the next group of results. If the
return value of Next
is None
, then there are no more pages to be fetched.
Here's an example of one such pagination call:
import orb
# Initialize the SDK.
s = orb.Orb(api_key_auth="my-orb-key")
cursor = None
keep_fetching = True
# We start by attempting to fetch at least one page of results.
while keep_fetching:
# The SDK call takes the cursor and any additional arguments to filter the
# coupon data.
response = s.coupon.list(cursor=cursor, show_archived=False)
if response.status_code != 200:
raise Exception(f"Unexpected status code received from server: {response.status_code}")
# Ensure the response from the server contains coupon data.
if response.coupons is None:
break
# Check if we received an empty page of results. This is a signal that we
# should stop requesting more data from the server.
page = response.coupons.data
if not page:
break
# Capture the cursor for the next loop. If there is no cursor then use that
# as a signal to stop iteration.
cursor = response.coupons.pagination_metadata.next_cursor
keep_fetching = cursor is not None
# At this point we have a page of coupon entries that we can collect or
# iterate through as shown below.
for coupon in page:
code = coupon.redemption_code
redeem_count = coupon.times_redeemed
print(f"Coupon ${code} was redeemed ${redeem_count} times.")
Maturity
This SDK is in beta, and there may be breaking changes between versions without a major version update. Therefore, we recommend pinning usage to a specific package version. This way, you can install the same version each time without breaking changes unless you are intentionally looking for the latest version.
Contributions
While we value open-source contributions to this SDK, this library is generated programmatically. Feel free to open a PR or a Github issue as a proof of concept and we'll do our best to include it in a future release !
SDK Created by Speakeasy
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file orb-billing-1.23.1.tar.gz
.
File metadata
- Download URL: orb-billing-1.23.1.tar.gz
- Upload date:
- Size: 136.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.18
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 76230abdb6a92b0dc294ea31c5f0d03905c814869e6af3adf5aa4f07bac4303e |
|
MD5 | d8e2fa8bcebaf575b9284708be1cd6cc |
|
BLAKE2b-256 | a03255a83b502fc3e42803dd514dc1fc7c354dd0876b97aeb3043457e12c200e |
File details
Details for the file orb_billing-1.23.1-py3-none-any.whl
.
File metadata
- Download URL: orb_billing-1.23.1-py3-none-any.whl
- Upload date:
- Size: 320.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.18
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c2f01e1a0a1edd61ae1d1df493fe4589cf30339ba4052130b997be72df913429 |
|
MD5 | d8ec95d01a62ffbb5cb2c988426bbecc |
|
BLAKE2b-256 | cab4db71f97cdaea235e767a93e2d8867bb8a46f426dc5f6582280d5c3c80d9e |