Skip to content

Latest commit

 

History

History
106 lines (76 loc) · 2.22 KB

USAGE.md

File metadata and controls

106 lines (76 loc) · 2.22 KB

Sign in

First you need to send an authentication request to the API by providing your username and password. In the request body, you should specify the type of token you would like to receive: API key or JSON Web Token. If your credentials are valid, you will receive a token in the response object: res.object.token: str.

import speakeasybar
from speakeasybar.models import operations

s = speakeasybar.Speakeasybar()

req = operations.LoginRequestBody(
    type=operations.Type.API_KEY,
)

res = s.authentication.login(req, operations.LoginSecurity(
    password="<PASSWORD>",
    username="<USERNAME>",
))

if res.object is not None:
    # handle response
    pass

Browse available drinks

Once you are authenticated, you can use the token you received for all other authenticated endpoints. For example, you can filter the list of available drinks by type.

import speakeasybar
from speakeasybar.models import shared

s = speakeasybar.Speakeasybar(
    security=shared.Security(
        api_key="<YOUR_API_KEY>",
    ),
)


res = s.drinks.list_drinks(drink_type=shared.DrinkType.SPIRIT)

if res.classes is not None:
    # handle response
    pass

Create an order

When you submit an order, you can include a callback URL along your request. This URL will get called whenever the supplier updates the status of your order.

import speakeasybar
from speakeasybar.models import shared

s = speakeasybar.Speakeasybar(
    security=shared.Security(
        api_key="<YOUR_API_KEY>",
    ),
)


res = s.orders.create_order(request_body=[
    shared.OrderInput(
        product_code='APM-1F2D3',
        quantity=26535,
        type=shared.OrderType.DRINK,
    ),
], callback_url='<value>')

if res.order is not None:
    # handle response
    pass

Subscribe to webhooks to receive stock updates

import speakeasybar
from speakeasybar.models import operations, shared

s = speakeasybar.Speakeasybar(
    security=shared.Security(
        api_key="<YOUR_API_KEY>",
    ),
)

req = [
    operations.RequestBody(),
]

res = s.config.subscribe_to_webhooks(req)

if res is not None:
    # handle response
    pass