Metadata-Version: 2.1
Name: stigg-api-client
Version: 0.0.1
Summary: 
Author: Stigg
Author-email: support@stigg.io
Requires-Python: >=3.10,<4.0
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Requires-Dist: black (>=22.8.0,<23.0.0)
Requires-Dist: flake8 (>=5.0.4,<6.0.0)
Requires-Dist: graphql-core (==3.1.6)
Requires-Dist: requests (>=2.28.1,<3.0.0)
Requires-Dist: sgqlc (>=16.0,<17.0)
Description-Content-Type: text/markdown

# stigg-api-client

This library provides a python wrapper to [Stigg's GraphQL API](https://docs.stigg.io/docs/graphql-api) based on
the operations the [Stigg's Node.js SDK](https://docs.stigg.io/docs/nodejs-sdk) is using under the hood.

It leverages the [sgqlc](https://github.com/profusion/sgqlc) library to generate Python classes for GraphQL types, and
utilizes the `sgqlc.endpoint.requests.RequestsEndpoint` class to send the API requests. The responses are being
automatically converted into native Python types.

## Documentation

See https://docs.stigg.io/docs/python-sdk

## Installation

    pip install stigg-api-client

## Usage examples

Initialize the client:

```python

import os
from stigg import Stigg

api_key = os.environ.get("STIGG_SERVER_API_KEY")

stigg_client = Stigg.create_client(api_key)

```

Provision a customer

```python

import os
from stigg import Stigg

api_key = os.environ.get("STIGG_SERVER_API_KEY")

client = Stigg.create_client(api_key)

data = client.request(Stigg.mutation.provision_customer, {
    "input": {
        "refId": "customer-id",
        "name": "Acme",
        "email": "hello@acme.com",
        "couponRefId": "coupon-id",
        "billingInformation": {
            "language": "en",
            "timezone": "America/New_York",
            "billingAddress": {
                "country": "US",
                "city": "New York",
                "state": "NY",
                "addressLine1": "123 Main Street",
                "addressLine2": "Apt. 1",
                "phoneNumber": "+1 212-499-5321",
                "postalCode": "10164"
            },
            "shippingAddress": {
                "country": "US",
                "city": "New York",
                "state": "NY",
                "addressLine1": "123 Main Street",
                "addressLine2": "Apt. 1",
                "phoneNumber": "+1 212-499-5321",
                "postalCode": "10164"
            }
        },
        "additionalMetaData": {
            "key": "value"
        },
        "subscriptionParams": {
            "planId": "plan-revvenu-basic"
        }
    }
})

print(data.provision_customer.customer.name)

```

Get a customer by ID

```python

import os
from stigg import Stigg

api_key = os.environ.get("STIGG_SERVER_API_KEY")

client = Stigg.create_client(api_key)

data = client.request(Stigg.query.get_customer_by_id, {'customerId': 'customer-id'})
customer_edge = next(iter(data.customers.edges), None)
if customer_edge:
    customer = customer_edge.node
    print(customer.name)
else:
    print('Customer not found')

```
