# pnap-invoicing-api
List, fetch and pay invoices with the Invoicing API.


This Python package is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project:

- API version: 1.0
- Package version: 1.0.3
- Build package: org.openapitools.codegen.languages.PythonClientCodegen
For more information, please visit [https://phoenixnap.com/](https://phoenixnap.com/)

## Requirements.

Python 3.7+

## Installation & Usage
### pip install

You can install this package directly from the [Python Package Index](https://pypi.org/) using:

```sh
$ pip install pnap_invoicing_api
```

Then import the package:
```python
import pnap_invoicing_api
```

### Setuptools

Install via [Setuptools](http://pypi.python.org/pypi/setuptools).

```sh
python setup.py install --user
```
(or `sudo python setup.py install` to install the package for all users)

Then import the package:
```python
import pnap_invoicing_api
```

```python

import time
import pnap_invoicing_api
from pnap_invoicing_api.rest import ApiException
from pprint import pprint

# Defining the host is optional and defaults to https://api.phoenixnap.com/invoicing/v1
# See configuration.py for a list of all supported configuration parameters.
configuration = pnap_invoicing_api.Configuration(
    host = "https://api.phoenixnap.com/invoicing/v1"
)

# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.

configuration.access_token = os.environ["ACCESS_TOKEN"]


# Enter a context with an instance of the API client
with pnap_invoicing_api.ApiClient(configuration) as api_client:
    # Create an instance of the API class
    api_instance = pnap_invoicing_api.InvoicesApi(api_client)
    number = '13218-1180326' # str | A user-friendly reference number assigned to the invoice. (optional)
    status = 'status_example' # str | Payment status of the invoice. (optional)
    sent_on_from = '2020-04-13T00:00:00.000Z' # datetime | Minimum value to filter invoices by sent on date. (optional)
    sent_on_to = '2022-04-13T00:00:00.000Z' # datetime | Maximum value to filter invoices by sent on date. (optional)
    limit = 100 # int | The limit of the number of results returned. The number of records returned may be smaller than the limit. (optional) (default to 100)
    offset = 0 # int | The number of items to skip in the results. (optional) (default to 0)
    sort_field = 'sentOn' # str | If a sortField is requested, pagination will be done after sorting. Default sorting is by number. (optional) (default to 'sentOn')
    sort_direction = 'DESC' # str | Sort Given Field depending on the desired direction. Default sorting is descending. (optional) (default to 'DESC')

    try:
        # List invoices.
        api_response = api_instance.invoices_get(number=number, status=status, sent_on_from=sent_on_from, sent_on_to=sent_on_to, limit=limit, offset=offset, sort_field=sort_field, sort_direction=sort_direction)
        print("The response of InvoicesApi->invoices_get:\n")
        pprint(api_response)
    except ApiException as e:
        print("Exception when calling InvoicesApi->invoices_get: %s\n" % e)

```

To generate a token using the [python-keycloak](https://pypi.org/project/python-keycloak/) library:
```python
from keycloak import KeycloakOpenID

clientId = "YOUR_CLIENT_ID"
clientSecret = "YOUR_CLIENT_SECRET"
serverUrl = "https://auth.phoenixnap.com/auth/"
realmName = "BMC"
grantType = "client_credentials"

keycloakOpenId =  KeycloakOpenID(server_url=serverUrl,
                        realm_name=realmName,
                        client_id=clientId,
                        client_secret_key=clientSecret)

ACCESS_TOKEN = keycloakOpenId.token(grant_type=grantType)['access_token']


## Documentation for API Endpoints

All URIs are relative to *https://api.phoenixnap.com/invoicing/v1*

Class | Method | HTTP request | Description
------------ | ------------- | ------------- | -------------
*InvoicesApi* | [**invoices_get**](docs/InvoicesApi.md#invoices_get) | **GET** /invoices | List invoices.
*InvoicesApi* | [**invoices_invoice_id_generate_pdf_post**](docs/InvoicesApi.md#invoices_invoice_id_generate_pdf_post) | **POST** /invoices/{invoiceId}/actions/generate-pdf | Generate invoice details as PDF.
*InvoicesApi* | [**invoices_invoice_id_get**](docs/InvoicesApi.md#invoices_invoice_id_get) | **GET** /invoices/{invoiceId} | Get invoice details.
*InvoicesApi* | [**invoices_invoice_id_pay_post**](docs/InvoicesApi.md#invoices_invoice_id_pay_post) | **POST** /invoices/{invoiceId}/actions/pay | Pay an invoice.


## Documentation For Models

 - [Error](docs/Error.md)
 - [Invoice](docs/Invoice.md)
 - [PaginatedInvoices](docs/PaginatedInvoices.md)
 - [PaginatedResponse](docs/PaginatedResponse.md)


<a id="documentation-for-authorization"></a>
## Documentation For Authorization


Authentication schemes defined for the API:
<a id="OAuth2"></a>
### OAuth2

- **Type**: OAuth
- **Flow**: application
- **Authorization URL**: 
- **Scopes**: 
 - **invoices**: Grants full access to Invoicing API.
 - **invoices.read**: Grants read only access to Invoicing API.


## Author

support@phoenixnap.com

