Skip to content

Commit

Permalink
Automated commit message
Browse files Browse the repository at this point in the history
  • Loading branch information
maxio-sdk committed Jan 10, 2024
1 parent f059e51 commit 285e613
Show file tree
Hide file tree
Showing 326 changed files with 3,389 additions and 897 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
*.pyc
.env
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ License:
The MIT License (MIT)
http://opensource.org/licenses/MIT

Copyright (c) 2014 - 2023 APIMATIC Limited
Copyright (c) 2014 - 2024 APIMATIC Limited

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
90 changes: 45 additions & 45 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -272,15 +272,15 @@ 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==0.0.3
pip install maxio-advanced-billing-sdk==0.0.4
```

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

## Initialize the API Client

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

The following parameters are configurable for the API Client:

Expand All @@ -297,18 +297,16 @@ 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_user_name` | `str` | The username to use with basic authentication |
| `basic_auth_password` | `str` | The password to use with basic authentication |
| `basic_auth_credentials` | [`BasicAuthCredentials`](https://www.github.com/maxio-com/ab-python-sdk/tree/0.0.4/doc/$a/https://www.github.com/maxio-com/ab-python-sdk/tree/0.0.4/basic-authentication.md) | The credential object for Basic Authentication |

The API client can be initialized as follows:

```python
from advancedbilling.advanced_billing_client import AdvancedBillingClient
from advancedbilling.configuration import Environment

client = AdvancedBillingClient(
basic_auth_user_name='BasicAuthUserName',
basic_auth_password='BasicAuthPassword'
basic_auth_credentials=BasicAuthCredentials(
username='BasicAuthUserName',
password='BasicAuthPassword'
)
)
```

Expand All @@ -325,45 +323,47 @@ The SDK can be configured to use a different environment for making API calls. A

## Authorization

This API uses `Basic Authentication`.
This API uses the following authentication schemes.

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

## List of APIs

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

## Classes Documentation

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

44 changes: 17 additions & 27 deletions advancedbilling/advanced_billing_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@


class AdvancedBillingClient(object):

@LazyProperty
def api_exports(self):
return APIExportsController(self.global_configuration)
Expand Down Expand Up @@ -198,38 +197,29 @@ def webhooks(self):
def __init__(self, http_client_instance=None,
override_http_client_configuration=False, http_call_back=None,
timeout=30, max_retries=0, backoff_factor=2,
retry_statuses=[408, 413, 429, 500, 502, 503, 504, 521, 522, 524],
retry_methods=['GET', 'PUT'],
retry_statuses=None, retry_methods=None,
environment=Environment.PRODUCTION, subdomain='subdomain',
domain='chargify.com', basic_auth_user_name='TODO: Replace',
basic_auth_password='TODO: Replace', config=None):
if config is None:
self.config = 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,
basic_auth_user_name=basic_auth_user_name,
basic_auth_password=basic_auth_password)
else:
self.config = config
domain='chargify.com', basic_auth_user_name=None,
basic_auth_password=None, 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,
basic_auth_user_name=basic_auth_user_name,
basic_auth_password=basic_auth_password,
basic_auth_credentials=basic_auth_credentials)

self.global_configuration = GlobalConfiguration(self.config)\
.global_errors(BaseController.global_errors())\
.base_uri_executor(self.config.get_base_uri)\
.user_agent(BaseController.user_agent(), BaseController.user_agent_parameters())
self.initialize_auth_managers(self.global_configuration)

self.auth_managers = {key: None for key in ['BasicAuth']}
self.auth_managers['BasicAuth'] = BasicAuth(
self.config.basic_auth_credentials)
self.global_configuration = self.global_configuration.auth_managers(self.auth_managers)

def initialize_auth_managers(self, global_config):
http_client_config = global_config.get_http_client_configuration()
self.auth_managers = { key: None for key in ['global']}
self.auth_managers['global'] = BasicAuth(http_client_config.basic_auth_user_name, http_client_config.basic_auth_password)
return self.auth_managers
74 changes: 51 additions & 23 deletions advancedbilling/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
https://www.apimatic.io ).
"""

import warnings
from enum import Enum
from advancedbilling.api_helper import APIHelper
from apimatic_core.http.configurations.http_client_configuration import HttpClientConfiguration
Expand Down Expand Up @@ -44,24 +45,32 @@ def domain(self):

@property
def basic_auth_user_name(self):
return self._basic_auth_user_name
return self._basic_auth_credentials.username

@property
def basic_auth_password(self):
return self._basic_auth_password

def __init__(
self, http_client_instance=None,
override_http_client_configuration=False, http_call_back=None,
timeout=30, max_retries=0, backoff_factor=2,
retry_statuses=[408, 413, 429, 500, 502, 503, 504, 521, 522, 524],
retry_methods=['GET', 'PUT'], environment=Environment.PRODUCTION,
subdomain='subdomain', domain='chargify.com',
basic_auth_user_name='TODO: Replace',
basic_auth_password='TODO: Replace'
):
return self._basic_auth_credentials.password

@property
def basic_auth_credentials(self):
return self._basic_auth_credentials

def __init__(self, http_client_instance=None,
override_http_client_configuration=False, http_call_back=None,
timeout=30, max_retries=0, backoff_factor=2,
retry_statuses=None, retry_methods=None,
environment=Environment.PRODUCTION, subdomain='subdomain',
domain='chargify.com', basic_auth_user_name=None,
basic_auth_password=None, basic_auth_credentials=None):
if retry_methods is None:
retry_methods = ['GET', 'PUT']

if retry_statuses is None:
retry_statuses = [408, 413, 429, 500, 502, 503, 504, 521, 522, 524]

super().__init__(http_client_instance, override_http_client_configuration, http_call_back, timeout, max_retries,
backoff_factor, retry_statuses, retry_methods)

# Current API environment
self._environment = environment

Expand All @@ -71,11 +80,8 @@ def __init__(
# The Chargify server domain.
self._domain = domain

# The username to use with basic authentication
self._basic_auth_user_name = basic_auth_user_name

# The password to use with basic authentication
self._basic_auth_password = basic_auth_password
self._basic_auth_credentials = self.create_auth_credentials_object(
basic_auth_user_name, basic_auth_password, basic_auth_credentials)

# The Http Client to use for making requests.
self.set_http_client(self.create_http_client())
Expand All @@ -85,7 +91,7 @@ def clone_with(self, http_client_instance=None,
timeout=None, max_retries=None, backoff_factor=None,
retry_statuses=None, retry_methods=None, environment=None,
subdomain=None, domain=None, basic_auth_user_name=None,
basic_auth_password=None):
basic_auth_password=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 @@ -97,17 +103,18 @@ def clone_with(self, http_client_instance=None,
environment = environment or self.environment
subdomain = subdomain or self.subdomain
domain = domain or self.domain
basic_auth_user_name = basic_auth_user_name or self.basic_auth_user_name
basic_auth_password = basic_auth_password or self.basic_auth_password
basic_auth_credentials = self.create_auth_credentials_object(
basic_auth_user_name, basic_auth_password,
basic_auth_credentials or self.basic_auth_credentials,
stack_level=3)
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,
basic_auth_user_name=basic_auth_user_name,
basic_auth_password=basic_auth_password
basic_auth_credentials=basic_auth_credentials
)

def create_http_client(self):
Expand Down Expand Up @@ -150,3 +157,24 @@ def get_base_uri(self, server=Server.DEFAULT):
return APIHelper.append_url_with_template_parameters(
self.environments[self.environment][server], parameters
)

@staticmethod
def create_auth_credentials_object(basic_auth_user_name,
basic_auth_password,
basic_auth_credentials, stack_level=4):
if basic_auth_user_name is None \
and basic_auth_password is None:
return basic_auth_credentials

warnings.warn(message=('The \'basic_auth_user_name\', \'basic_auth_pass'
'word\' params are deprecated. Use \'basic_auth_'
'credentials\' param instead.'),
category=DeprecationWarning,
stacklevel=stack_level)

if basic_auth_credentials is not None:
return basic_auth_credentials.clone_with(basic_auth_user_name,
basic_auth_password)

from advancedbilling.http.auth.basic_auth import BasicAuthCredentials
return BasicAuthCredentials(basic_auth_user_name, basic_auth_password)
Loading

0 comments on commit 285e613

Please sign in to comment.