Metadata-Version: 2.4
Name: apimatic-tql-sdk
Version: 0.0.1
Summary: this is a sample SDK generated by APIMatic
Author-email: developer sdksio <developer+sdksio@apimatic.io>
Project-URL: Documentation, https://apimatic.io
Keywords: Apimatic,sdksio
Requires-Python: >=3.7
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: apimatic-core>=0.2.24,~=0.2.0
Requires-Dist: apimatic-core-interfaces>=0.1.8,~=0.1.0
Requires-Dist: apimatic-requests-client-adapter>=0.1.10,~=0.1.0
Requires-Dist: python-dotenv<2.0,>=0.21
Provides-Extra: testutils
Requires-Dist: pytest>=7.2.2; extra == "testutils"
Dynamic: license-file


# Getting Started with TQL <> OTR — Factoring Data Exchange

## Introduction

### Overview

The **TQL &lt;&gt; OTR Factoring Data Exchange** API enables factoring clients to submit carrier invoices against loads managed by TQL, upload supporting documentation, search for invoices, and check processing status including any outstanding exceptions.

#### Key Capabilities

- **Invoice Submission** — `POST /api/invoices` — Submit a factoring company invoice referencing a TQL load, including carrier details, stops, charges, and reference numbers.
- **Invoice Search** — `POST /api/invoices/search` — Search and retrieve a paginated list of invoices with status and last-updated timestamps.
- **Invoice Status** — `GET /api/invoices/{invoiceNumber}` — Retrieve the current processing status of an invoice, including any outstanding exceptions.
- **Document Upload** — `POST /api/documents` — Upload a supporting document (BOL, rate confirmation, proof of delivery, etc.) via `multipart/form-data` and link it to an invoice. Supports arbitrary key-value tags for metadata.
- **Carrier Assignment** — `PUT /api/assignments` — Notify TQL that a factoring company has been assigned to (or unassigned from) a carrier, including the effective date.
- **Load Lookup** — `GET /api/loads/{loadNumber}` — Verify a load exists in TQL's system and retrieve basic details (carrier, status, dates).
- **Load Search** — `POST /api/loads/search` — Search for TQL loads by carrier, date range, or status.

#### Authentication

This API uses **[OAuth 2.0 Client Credentials](https://datatracker.ietf.org/doc/html/rfc6749#section-4.4)** for authentication. TQL will provision each factoring partner with a unique **Client ID** and **Client Secret** during onboarding.

**How it works:**

1. **Obtain an access token** — Make a `POST` request to the TQL
   token endpoint with your Client ID and Client Secret using the
   `client_credentials` grant type.

2. **Include the token** — Pass the access token as a Bearer token
   in the `Authorization` header on every API request:
   `Authorization: Bearer <access_token>`

3. **Token expiry** — Access tokens have a limited lifetime
   (typically 1 hour). When the token expires, request a new one from
   the token endpoint. Do **not** request a new token on every API
   call — cache and reuse the token until it expires.

**Required scopes:**

- **`Factoring.Write`** — Submit invoices, upload documents, manage assignments
- **`Factoring.Read`** — Query invoice status, search invoices
  The scopes your client is allowed to request are configured during onboarding. Include the required scope(s) in the `scope` parameter when requesting a token.

**Example token request:**

POST /oauth2/token HTTP/1.1
Content-Type: application/x-www-form-urlencoded

    grant_type=client_credentials
    &client_id=<your_client_id>
    &client_secret=<your_client_secret>
    &scope=Factoring.Write Factoring.Read

TQL will provide the exact token endpoint URL, Client ID, and Client Secret during partner onboarding.

#### Philosophy

- **Authentication** — All endpoints require a valid OAuth 2.0 Bearer token in the `Authorization` header. See the **Authentication** section above for details.
- **Asynchronous processing** — Write endpoints return `202 Accepted` immediately; poll `GET /api/invoices/{invoiceNumber}` for completion and exceptions.
- **Error handling** — Non-2xx responses follow [RFC 7807 Problem Details](https://datatracker.ietf.org/doc/html/rfc7807) with `title`, `status`, and `detail` fields.

## Install the Package

The package is compatible with Python versions `3.7+`.
Install the package from PyPi using the following pip command:

```bash
pip install apimatic-tql-sdk==0.0.1
```

You can also view the package at:
https://pypi.python.org/pypi/apimatic-tql-sdk/0.0.1

## Initialize the API Client

**_Note:_** Documentation for the client can be found [here.](https://www.github.com/sdks-io/apimatic-tql-python-sdk/tree/0.0.1/doc/client.md)

The following parameters are configurable for the API Client:

| Parameter | Type | Description |
|  --- | --- | --- |
| http_client_instance | `Union[Session, HttpClientProvider]` | 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 |
| timeout | `float` | The value to use for connection timeout. <br> **Default: 30** |
| max_retries | `int` | The number of times to retry an endpoint call if it fails. <br> **Default: 0** |
| 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"]** |
| proxy_settings | [`ProxySettings`](https://www.github.com/sdks-io/apimatic-tql-python-sdk/tree/0.0.1/doc/proxy-settings.md) | Optional proxy configuration to route HTTP requests through a proxy server. |
| logging_configuration | [`LoggingConfiguration`](https://www.github.com/sdks-io/apimatic-tql-python-sdk/tree/0.0.1/doc/logging-configuration.md) | The SDK logging configuration for API calls |
| client_credentials_auth_credentials | [`ClientCredentialsAuthCredentials`](https://www.github.com/sdks-io/apimatic-tql-python-sdk/tree/0.0.1/doc/auth/oauth-2-client-credentials-grant.md) | The credential object for OAuth 2 Client Credentials Grant |

The API client can be initialized as follows:

### Code-Based Client Initialization

```python
import logging

from tqlotrfactoringdataexchange.configuration import Environment
from tqlotrfactoringdataexchange.http.auth.oauth_2 import ClientCredentialsAuthCredentials
from tqlotrfactoringdataexchange.logging.configuration.api_logging_configuration import LoggingConfiguration
from tqlotrfactoringdataexchange.logging.configuration.api_logging_configuration import RequestLoggingConfiguration
from tqlotrfactoringdataexchange.logging.configuration.api_logging_configuration import ResponseLoggingConfiguration
from tqlotrfactoringdataexchange.models.oauth_scope import OauthScope
from tqlotrfactoringdataexchange.tqlotrfactoringdataexchange_client import TqlotrfactoringdataexchangeClient

client = TqlotrfactoringdataexchangeClient(
    client_credentials_auth_credentials=ClientCredentialsAuthCredentials(
        oauth_client_id='OAuthClientId',
        oauth_client_secret='OAuthClientSecret',
        oauth_scopes=[
            OauthScope.FACTORING_WRITE,
            OauthScope.FACTORING_READ
        ]
    ),
    environment=Environment.PRODUCTION,
    logging_configuration=LoggingConfiguration(
        log_level=logging.INFO,
        request_logging_config=RequestLoggingConfiguration(
            log_body=True
        ),
        response_logging_config=ResponseLoggingConfiguration(
            log_headers=True
        )
    )
)
```

### Environment-Based Client Initialization

```python
from tqlotrfactoringdataexchange.tqlotrfactoringdataexchange_client import TqlotrfactoringdataexchangeClient

# Specify the path to your .env file if it’s located outside the project’s root directory.
client = TqlotrfactoringdataexchangeClient.from_environment(dotenv_path='/path/to/.env')
```

See the [Environment-Based Client Initialization](https://www.github.com/sdks-io/apimatic-tql-python-sdk/tree/0.0.1/doc/environment-based-client-initialization.md) section for details.

## Authorization

This API uses the following authentication schemes.

* [`bearerAuth (OAuth 2 Client Credentials Grant)`](https://www.github.com/sdks-io/apimatic-tql-python-sdk/tree/0.0.1/doc/auth/oauth-2-client-credentials-grant.md)

## List of APIs

* [Invoices](https://www.github.com/sdks-io/apimatic-tql-python-sdk/tree/0.0.1/doc/controllers/invoices.md)
* [Documents](https://www.github.com/sdks-io/apimatic-tql-python-sdk/tree/0.0.1/doc/controllers/documents.md)
* [Assignments](https://www.github.com/sdks-io/apimatic-tql-python-sdk/tree/0.0.1/doc/controllers/assignments.md)
* [Loads](https://www.github.com/sdks-io/apimatic-tql-python-sdk/tree/0.0.1/doc/controllers/loads.md)

## SDK Infrastructure

### Configuration

* [ProxySettings](https://www.github.com/sdks-io/apimatic-tql-python-sdk/tree/0.0.1/doc/proxy-settings.md)
* [Environment-Based Client Initialization](https://www.github.com/sdks-io/apimatic-tql-python-sdk/tree/0.0.1/doc/environment-based-client-initialization.md)
* [AbstractLogger](https://www.github.com/sdks-io/apimatic-tql-python-sdk/tree/0.0.1/doc/abstract-logger.md)
* [LoggingConfiguration](https://www.github.com/sdks-io/apimatic-tql-python-sdk/tree/0.0.1/doc/logging-configuration.md)
* [RequestLoggingConfiguration](https://www.github.com/sdks-io/apimatic-tql-python-sdk/tree/0.0.1/doc/request-logging-configuration.md)
* [ResponseLoggingConfiguration](https://www.github.com/sdks-io/apimatic-tql-python-sdk/tree/0.0.1/doc/response-logging-configuration.md)

### HTTP

* [HttpResponse](https://www.github.com/sdks-io/apimatic-tql-python-sdk/tree/0.0.1/doc/http-response.md)
* [HttpRequest](https://www.github.com/sdks-io/apimatic-tql-python-sdk/tree/0.0.1/doc/http-request.md)

### Utilities

* [ApiResponse](https://www.github.com/sdks-io/apimatic-tql-python-sdk/tree/0.0.1/doc/api-response.md)
* [ApiHelper](https://www.github.com/sdks-io/apimatic-tql-python-sdk/tree/0.0.1/doc/api-helper.md)
* [HttpDateTime](https://www.github.com/sdks-io/apimatic-tql-python-sdk/tree/0.0.1/doc/http-date-time.md)
* [RFC3339DateTime](https://www.github.com/sdks-io/apimatic-tql-python-sdk/tree/0.0.1/doc/rfc3339-date-time.md)
* [UnixDateTime](https://www.github.com/sdks-io/apimatic-tql-python-sdk/tree/0.0.1/doc/unix-date-time.md)

