Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DE-1091] Release 6.0.0 #54

Merged
merged 2 commits into from
Dec 13, 2024
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
96 changes: 47 additions & 49 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,24 +30,23 @@ curl -u <api_key>:x -H Accept:application/json -H Content-Type:application/json
The package is compatible with Python versions `3 >=3.7, <= 3.11`.
Install the package from PyPi using the following pip command:

```python
pip install maxio-advanced-billing-sdk==5.2.0
```bash
pip install maxio-advanced-billing-sdk==6.0.0
```

You can also view the package at:
https://pypi.python.org/pypi/maxio-advanced-billing-sdk/5.2.0
https://pypi.python.org/pypi/maxio-advanced-billing-sdk/6.0.0

## Initialize the API Client

**_Note:_** Documentation for the client can be found [here.](https://www.github.com/maxio-com/ab-python-sdk/tree/5.2.0/doc/client.md)
**_Note:_** Documentation for the client can be found [here.](https://www.github.com/maxio-com/ab-python-sdk/tree/6.0.0/doc/client.md)

The following parameters are configurable for the API Client:

| Parameter | Type | Description |
| --- | --- | --- |
| `subdomain` | `str` | The subdomain for your Advanced Billing site.<br>*Default*: `'subdomain'` |
| `domain` | `str` | The Advanced Billing server domain.<br>*Default*: `'chargify.com'` |
| `environment` | `Environment` | The API environment. <br> **Default: `Environment.PRODUCTION`** |
| `site` | `str` | The subdomain for your Advanced Billing site.<br>*Default*: `'subdomain'` |
| `environment` | `Environment` | The API environment. <br> **Default: `Environment.US`** |
| `http_client_instance` | `HttpClient` | The Http Client passed from the sdk user for making requests |
| `override_http_client_configuration` | `bool` | The value which determines to override properties of the passed Http Client from the sdk user |
| `http_call_back` | `HttpCallBack` | The callback value that is invoked before and after an HTTP call is made to an endpoint |
Expand All @@ -56,7 +55,7 @@ The following parameters are configurable for the API Client:
| `backoff_factor` | `float` | A backoff factor to apply between attempts after the second try. <br> **Default: 2** |
| `retry_statuses` | `Array of int` | The http statuses on which retry is to be done. <br> **Default: [408, 413, 429, 500, 502, 503, 504, 521, 522, 524]** |
| `retry_methods` | `Array of string` | The http methods on which retry is to be done. <br> **Default: ['GET', 'PUT']** |
| `basic_auth_credentials` | [`BasicAuthCredentials`](https://www.github.com/maxio-com/ab-python-sdk/tree/5.2.0/doc/auth/basic-authentication.md) | The credential object for Basic Authentication |
| `basic_auth_credentials` | [`BasicAuthCredentials`](https://www.github.com/maxio-com/ab-python-sdk/tree/6.0.0/doc/auth/basic-authentication.md) | The credential object for Basic Authentication |

The API client can be initialized as follows:

Expand All @@ -66,9 +65,8 @@ client = AdvancedBillingClient(
username='BasicAuthUserName',
password='BasicAuthPassword'
),
environment=Environment.PRODUCTION,
subdomain='subdomain',
domain='chargify.com'
environment=Environment.US,
site='subdomain'
)
```

Expand All @@ -80,53 +78,53 @@ The SDK can be configured to use a different environment for making API calls. A

| Name | Description |
| --- | --- |
| production | **Default** Production server |
| environment2 | Production server |
| US | **Default** Default Advanced Billing environment hosted in US. Valid for the majority of our customers. |
| EU | Advanced Billing environment hosted in EU. Use only when you requested EU hosting for your AB account. |

## Authorization

This API uses the following authentication schemes.

* [`BasicAuth (Basic Authentication)`](https://www.github.com/maxio-com/ab-python-sdk/tree/5.2.0/doc/auth/basic-authentication.md)
* [`BasicAuth (Basic Authentication)`](https://www.github.com/maxio-com/ab-python-sdk/tree/6.0.0/doc/auth/basic-authentication.md)

## List of APIs

* [API Exports](https://www.github.com/maxio-com/ab-python-sdk/tree/5.2.0/doc/controllers/api-exports.md)
* [Advance Invoice](https://www.github.com/maxio-com/ab-python-sdk/tree/5.2.0/doc/controllers/advance-invoice.md)
* [Billing Portal](https://www.github.com/maxio-com/ab-python-sdk/tree/5.2.0/doc/controllers/billing-portal.md)
* [Component Price Points](https://www.github.com/maxio-com/ab-python-sdk/tree/5.2.0/doc/controllers/component-price-points.md)
* [Custom Fields](https://www.github.com/maxio-com/ab-python-sdk/tree/5.2.0/doc/controllers/custom-fields.md)
* [Events-Based Billing Segments](https://www.github.com/maxio-com/ab-python-sdk/tree/5.2.0/doc/controllers/events-based-billing-segments.md)
* [Payment Profiles](https://www.github.com/maxio-com/ab-python-sdk/tree/5.2.0/doc/controllers/payment-profiles.md)
* [Product Families](https://www.github.com/maxio-com/ab-python-sdk/tree/5.2.0/doc/controllers/product-families.md)
* [Product Price Points](https://www.github.com/maxio-com/ab-python-sdk/tree/5.2.0/doc/controllers/product-price-points.md)
* [Proforma Invoices](https://www.github.com/maxio-com/ab-python-sdk/tree/5.2.0/doc/controllers/proforma-invoices.md)
* [Reason Codes](https://www.github.com/maxio-com/ab-python-sdk/tree/5.2.0/doc/controllers/reason-codes.md)
* [Referral Codes](https://www.github.com/maxio-com/ab-python-sdk/tree/5.2.0/doc/controllers/referral-codes.md)
* [Sales Commissions](https://www.github.com/maxio-com/ab-python-sdk/tree/5.2.0/doc/controllers/sales-commissions.md)
* [Subscription Components](https://www.github.com/maxio-com/ab-python-sdk/tree/5.2.0/doc/controllers/subscription-components.md)
* [Subscription Groups](https://www.github.com/maxio-com/ab-python-sdk/tree/5.2.0/doc/controllers/subscription-groups.md)
* [Subscription Group Invoice Account](https://www.github.com/maxio-com/ab-python-sdk/tree/5.2.0/doc/controllers/subscription-group-invoice-account.md)
* [Subscription Group Status](https://www.github.com/maxio-com/ab-python-sdk/tree/5.2.0/doc/controllers/subscription-group-status.md)
* [Subscription Invoice Account](https://www.github.com/maxio-com/ab-python-sdk/tree/5.2.0/doc/controllers/subscription-invoice-account.md)
* [Subscription Notes](https://www.github.com/maxio-com/ab-python-sdk/tree/5.2.0/doc/controllers/subscription-notes.md)
* [Subscription Products](https://www.github.com/maxio-com/ab-python-sdk/tree/5.2.0/doc/controllers/subscription-products.md)
* [Subscription Status](https://www.github.com/maxio-com/ab-python-sdk/tree/5.2.0/doc/controllers/subscription-status.md)
* [Coupons](https://www.github.com/maxio-com/ab-python-sdk/tree/5.2.0/doc/controllers/coupons.md)
* [Components](https://www.github.com/maxio-com/ab-python-sdk/tree/5.2.0/doc/controllers/components.md)
* [Customers](https://www.github.com/maxio-com/ab-python-sdk/tree/5.2.0/doc/controllers/customers.md)
* [Events](https://www.github.com/maxio-com/ab-python-sdk/tree/5.2.0/doc/controllers/events.md)
* [Insights](https://www.github.com/maxio-com/ab-python-sdk/tree/5.2.0/doc/controllers/insights.md)
* [Invoices](https://www.github.com/maxio-com/ab-python-sdk/tree/5.2.0/doc/controllers/invoices.md)
* [Offers](https://www.github.com/maxio-com/ab-python-sdk/tree/5.2.0/doc/controllers/offers.md)
* [Products](https://www.github.com/maxio-com/ab-python-sdk/tree/5.2.0/doc/controllers/products.md)
* [Sites](https://www.github.com/maxio-com/ab-python-sdk/tree/5.2.0/doc/controllers/sites.md)
* [Subscriptions](https://www.github.com/maxio-com/ab-python-sdk/tree/5.2.0/doc/controllers/subscriptions.md)
* [Webhooks](https://www.github.com/maxio-com/ab-python-sdk/tree/5.2.0/doc/controllers/webhooks.md)
* [API Exports](https://www.github.com/maxio-com/ab-python-sdk/tree/6.0.0/doc/controllers/api-exports.md)
* [Advance Invoice](https://www.github.com/maxio-com/ab-python-sdk/tree/6.0.0/doc/controllers/advance-invoice.md)
* [Billing Portal](https://www.github.com/maxio-com/ab-python-sdk/tree/6.0.0/doc/controllers/billing-portal.md)
* [Component Price Points](https://www.github.com/maxio-com/ab-python-sdk/tree/6.0.0/doc/controllers/component-price-points.md)
* [Custom Fields](https://www.github.com/maxio-com/ab-python-sdk/tree/6.0.0/doc/controllers/custom-fields.md)
* [Events-Based Billing Segments](https://www.github.com/maxio-com/ab-python-sdk/tree/6.0.0/doc/controllers/events-based-billing-segments.md)
* [Payment Profiles](https://www.github.com/maxio-com/ab-python-sdk/tree/6.0.0/doc/controllers/payment-profiles.md)
* [Product Families](https://www.github.com/maxio-com/ab-python-sdk/tree/6.0.0/doc/controllers/product-families.md)
* [Product Price Points](https://www.github.com/maxio-com/ab-python-sdk/tree/6.0.0/doc/controllers/product-price-points.md)
* [Proforma Invoices](https://www.github.com/maxio-com/ab-python-sdk/tree/6.0.0/doc/controllers/proforma-invoices.md)
* [Reason Codes](https://www.github.com/maxio-com/ab-python-sdk/tree/6.0.0/doc/controllers/reason-codes.md)
* [Referral Codes](https://www.github.com/maxio-com/ab-python-sdk/tree/6.0.0/doc/controllers/referral-codes.md)
* [Sales Commissions](https://www.github.com/maxio-com/ab-python-sdk/tree/6.0.0/doc/controllers/sales-commissions.md)
* [Subscription Components](https://www.github.com/maxio-com/ab-python-sdk/tree/6.0.0/doc/controllers/subscription-components.md)
* [Subscription Groups](https://www.github.com/maxio-com/ab-python-sdk/tree/6.0.0/doc/controllers/subscription-groups.md)
* [Subscription Group Invoice Account](https://www.github.com/maxio-com/ab-python-sdk/tree/6.0.0/doc/controllers/subscription-group-invoice-account.md)
* [Subscription Group Status](https://www.github.com/maxio-com/ab-python-sdk/tree/6.0.0/doc/controllers/subscription-group-status.md)
* [Subscription Invoice Account](https://www.github.com/maxio-com/ab-python-sdk/tree/6.0.0/doc/controllers/subscription-invoice-account.md)
* [Subscription Notes](https://www.github.com/maxio-com/ab-python-sdk/tree/6.0.0/doc/controllers/subscription-notes.md)
* [Subscription Products](https://www.github.com/maxio-com/ab-python-sdk/tree/6.0.0/doc/controllers/subscription-products.md)
* [Subscription Status](https://www.github.com/maxio-com/ab-python-sdk/tree/6.0.0/doc/controllers/subscription-status.md)
* [Coupons](https://www.github.com/maxio-com/ab-python-sdk/tree/6.0.0/doc/controllers/coupons.md)
* [Components](https://www.github.com/maxio-com/ab-python-sdk/tree/6.0.0/doc/controllers/components.md)
* [Customers](https://www.github.com/maxio-com/ab-python-sdk/tree/6.0.0/doc/controllers/customers.md)
* [Events](https://www.github.com/maxio-com/ab-python-sdk/tree/6.0.0/doc/controllers/events.md)
* [Insights](https://www.github.com/maxio-com/ab-python-sdk/tree/6.0.0/doc/controllers/insights.md)
* [Invoices](https://www.github.com/maxio-com/ab-python-sdk/tree/6.0.0/doc/controllers/invoices.md)
* [Offers](https://www.github.com/maxio-com/ab-python-sdk/tree/6.0.0/doc/controllers/offers.md)
* [Products](https://www.github.com/maxio-com/ab-python-sdk/tree/6.0.0/doc/controllers/products.md)
* [Sites](https://www.github.com/maxio-com/ab-python-sdk/tree/6.0.0/doc/controllers/sites.md)
* [Subscriptions](https://www.github.com/maxio-com/ab-python-sdk/tree/6.0.0/doc/controllers/subscriptions.md)
* [Webhooks](https://www.github.com/maxio-com/ab-python-sdk/tree/6.0.0/doc/controllers/webhooks.md)

## Classes Documentation

* [Utility Classes](https://www.github.com/maxio-com/ab-python-sdk/tree/5.2.0/doc/utility-classes.md)
* [HttpResponse](https://www.github.com/maxio-com/ab-python-sdk/tree/5.2.0/doc/http-response.md)
* [HttpRequest](https://www.github.com/maxio-com/ab-python-sdk/tree/5.2.0/doc/http-request.md)
* [Utility Classes](https://www.github.com/maxio-com/ab-python-sdk/tree/6.0.0/doc/utility-classes.md)
* [HttpResponse](https://www.github.com/maxio-com/ab-python-sdk/tree/6.0.0/doc/http-response.md)
* [HttpRequest](https://www.github.com/maxio-com/ab-python-sdk/tree/6.0.0/doc/http-request.md)

7 changes: 3 additions & 4 deletions advancedbilling/advanced_billing_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,16 +204,15 @@ def __init__(self, http_client_instance=None,
override_http_client_configuration=False, http_call_back=None,
timeout=120, max_retries=0, backoff_factor=2,
retry_statuses=None, retry_methods=None,
environment=Environment.PRODUCTION, subdomain='subdomain',
domain='chargify.com', basic_auth_credentials=None,
config=None):
environment=Environment.US, site='subdomain',
basic_auth_credentials=None, config=None):
self.config = config or Configuration(
http_client_instance=http_client_instance,
override_http_client_configuration=override_http_client_configuration,
http_call_back=http_call_back, timeout=timeout,
max_retries=max_retries, backoff_factor=backoff_factor,
retry_statuses=retry_statuses, retry_methods=retry_methods,
environment=environment, subdomain=subdomain, domain=domain,
environment=environment, site=site,
basic_auth_credentials=basic_auth_credentials)

self.global_configuration = GlobalConfiguration(self.config)\
Expand Down
50 changes: 22 additions & 28 deletions advancedbilling/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,16 @@

class Environment(Enum):
"""An enum for SDK environments"""
# Production server
PRODUCTION = 0
# Production server
ENVIRONMENT2 = 1
# Default Advanced Billing environment hosted in US. Valid for the majority of our customers.
US = 0
# Advanced Billing environment hosted in EU. Use only when you requested EU hosting for your AB account.
EU = 1


class Server(Enum):
"""An enum for API servers"""
DEFAULT = 0
PRODUCTION = 0
EBB = 1


class Configuration(HttpClientConfiguration):
Expand All @@ -35,12 +36,8 @@ def environment(self):
return self._environment

@property
def subdomain(self):
return self._subdomain

@property
def domain(self):
return self._domain
def site(self):
return self._site

@property
def basic_auth_credentials(self):
Expand All @@ -50,8 +47,8 @@ def __init__(self, http_client_instance=None,
override_http_client_configuration=False, http_call_back=None,
timeout=120, max_retries=0, backoff_factor=2,
retry_statuses=None, retry_methods=None,
environment=Environment.PRODUCTION, subdomain='subdomain',
domain='chargify.com', basic_auth_credentials=None):
environment=Environment.US, site='subdomain',
basic_auth_credentials=None):
if retry_methods is None:
retry_methods = ['GET', 'PUT']

Expand All @@ -67,10 +64,7 @@ def __init__(self, http_client_instance=None,
self._environment = environment

# The subdomain for your Advanced Billing site.
self._subdomain = subdomain

# The Advanced Billing server domain.
self._domain = domain
self._site = site

self._basic_auth_credentials = basic_auth_credentials

Expand All @@ -81,7 +75,7 @@ def clone_with(self, http_client_instance=None,
override_http_client_configuration=None, http_call_back=None,
timeout=None, max_retries=None, backoff_factor=None,
retry_statuses=None, retry_methods=None, environment=None,
subdomain=None, domain=None, basic_auth_credentials=None):
site=None, basic_auth_credentials=None):
http_client_instance = http_client_instance or self.http_client_instance
override_http_client_configuration = override_http_client_configuration or self.override_http_client_configuration
http_call_back = http_call_back or self.http_callback
Expand All @@ -91,16 +85,15 @@ def clone_with(self, http_client_instance=None,
retry_statuses = retry_statuses or self.retry_statuses
retry_methods = retry_methods or self.retry_methods
environment = environment or self.environment
subdomain = subdomain or self.subdomain
domain = domain or self.domain
site = site or self.site
basic_auth_credentials = basic_auth_credentials or self.basic_auth_credentials
return Configuration(
http_client_instance=http_client_instance,
override_http_client_configuration=override_http_client_configuration,
http_call_back=http_call_back, timeout=timeout,
max_retries=max_retries, backoff_factor=backoff_factor,
retry_statuses=retry_statuses, retry_methods=retry_methods,
environment=environment, subdomain=subdomain, domain=domain,
environment=environment, site=site,
basic_auth_credentials=basic_auth_credentials
)

Expand All @@ -116,15 +109,17 @@ def create_http_client(self):

# All the environments the SDK can run in
environments = {
Environment.PRODUCTION: {
Server.DEFAULT: 'https://{subdomain}.{domain}'
Environment.US: {
Server.PRODUCTION: 'https://{site}.chargify.com',
Server.EBB: 'https://events.chargify.com/{site}'
},
Environment.ENVIRONMENT2: {
Server.DEFAULT: 'https://events.chargify.com'
Environment.EU: {
Server.PRODUCTION: 'https://{site}.ebilling.maxio.com',
Server.EBB: 'https://events.chargify.com/{site}'
}
}

def get_base_uri(self, server=Server.DEFAULT):
def get_base_uri(self, server=Server.PRODUCTION):
"""Generates the appropriate base URI for the environment and the
server.

Expand All @@ -137,8 +132,7 @@ def get_base_uri(self, server=Server.DEFAULT):

"""
parameters = {
"subdomain": {'value': self.subdomain, 'encode': False},
"domain": {'value': self.domain, 'encode': False},
"site": {'value': self.site, 'encode': False},
}

return APIHelper.append_url_with_template_parameters(
Expand Down
6 changes: 3 additions & 3 deletions advancedbilling/controllers/advance_invoice_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def issue_advance_invoice(self,
"""

return super().new_api_call_builder.request(
RequestBuilder().server(Server.DEFAULT)
RequestBuilder().server(Server.PRODUCTION)
.path('/subscriptions/{subscription_id}/advance_invoice/issue.json')
.http_method(HttpMethodEnum.POST)
.template_param(Parameter()
Expand Down Expand Up @@ -115,7 +115,7 @@ def read_advance_invoice(self,
"""

return super().new_api_call_builder.request(
RequestBuilder().server(Server.DEFAULT)
RequestBuilder().server(Server.PRODUCTION)
.path('/subscriptions/{subscription_id}/advance_invoice.json')
.http_method(HttpMethodEnum.GET)
.template_param(Parameter()
Expand Down Expand Up @@ -163,7 +163,7 @@ def void_advance_invoice(self,
"""

return super().new_api_call_builder.request(
RequestBuilder().server(Server.DEFAULT)
RequestBuilder().server(Server.PRODUCTION)
.path('/subscriptions/{subscription_id}/advance_invoice/void.json')
.http_method(HttpMethodEnum.POST)
.template_param(Parameter()
Expand Down
Loading
Loading