Skip to main content

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

credit

credit_note

  • fetch - Fetch credit note
  • list - List credit notes

customer

event

invoice

item

metric

plan

price

price_interval

subscription

Dev Containers

Experience our SDK in an enhanced sandbox environment. Try it now in GitHub Codespaces!

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

orb-billing-1.24.0.tar.gz (137.1 kB view details)

Uploaded Source

Built Distribution

orb_billing-1.24.0-py3-none-any.whl (320.2 kB view details)

Uploaded Python 3

File details

Details for the file orb-billing-1.24.0.tar.gz.

File metadata

  • Download URL: orb-billing-1.24.0.tar.gz
  • Upload date:
  • Size: 137.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.18

File hashes

Hashes for orb-billing-1.24.0.tar.gz
Algorithm Hash digest
SHA256 4f2b73e081c6459eaa5e707c4711d0270c7d883dcdaf6ae81d5a37a4cc5683ee
MD5 498c40d6022f314d3505d5686b47a712
BLAKE2b-256 ae70a364012c57f653d78a92928e42e839218cf36cd07330920111e2cc319e8c

See more details on using hashes here.

File details

Details for the file orb_billing-1.24.0-py3-none-any.whl.

File metadata

  • Download URL: orb_billing-1.24.0-py3-none-any.whl
  • Upload date:
  • Size: 320.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.18

File hashes

Hashes for orb_billing-1.24.0-py3-none-any.whl
Algorithm Hash digest
SHA256 33cb39b874545e03f5548a4acfb92a89852698c97a1b45490244756e1da416ef
MD5 2187c794d3c1206246bb90e4290b1f34
BLAKE2b-256 443641dd9ecd4525e4bc10f3d6022c36a3cc45774dc2cdfc0fc08ea114ccc0c0

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page