Skip to content

Commit

Permalink
Use python client api
Browse files Browse the repository at this point in the history
  • Loading branch information
serra committed Sep 4, 2024
1 parent c2305f9 commit d24b50a
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 106 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ authors = [
]
requires-python = ">=3.10"
urls = { "project" = "https://github.com/serraict/vine-floriday-adapter", "docs" = "https://github.com/serraict/vine-floriday-adapter/blob/main/README.md" }
dependencies = ["typer", "minio", "requests"]
dependencies = ["typer", "minio", "requests", "floriday-supplier-client"]
dynamic = ["version"]
license.file = "LICENCE"

Expand Down
78 changes: 0 additions & 78 deletions src/floridayvine/floriday.py

This file was deleted.

26 changes: 8 additions & 18 deletions src/floridayvine/floriday/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
from pprint import pprint
import requests

from floriday_supplier_client import TradeItemsApi, api_factory

CLIENT_ID = os.getenv("FLORIDAY_CLIENT_ID")
CLIENT_SECRET = os.getenv("FLORIDAY_CLIENT_SECRET")
API_KEY = os.getenv("FLORIDAY_API_KEY")
Expand All @@ -27,6 +29,9 @@ def get_access_token():
return response.json().get("access_token")


_api_factory = api_factory.ApiFactory()


def get_organizations():
access_token = get_access_token()
url = f"{BASE_URL}/auth/key"
Expand All @@ -43,24 +48,9 @@ def get_organizations():


def get_trade_items():
access_token = get_access_token()
url = f"{BASE_URL}/trade-items"

headers = {
"X-Api-Key": API_KEY,
"Accept": "application/json",
"Authorization": f"Bearer {access_token}",
}
base_sync_number = 0
sync_items = sync_trade_items(base_sync_number)
max_sync_number = sync_items.get("maximumSequenceNumber")
results = sync_items.get("results")
print(f"{len(results)} trade items synced ({base_sync_number}..{max_sync_number})")
# pprint(items)

response = requests.get(url, headers=headers)
response.raise_for_status()
return response.json()
api = TradeItemsApi(_api_factory.get_api_client())
items = api.get_trade_items()
return items


def sync_trade_items(base_sync_number=0):
Expand Down
18 changes: 9 additions & 9 deletions work/backlog.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,25 @@ Containers are pushed to <ghcr.io/serraict/vine-floriday-adapter>.

## Doing

* Retrieve trade-item information.
* generate an api client

## Next

* Goal: connect to Floriday.
* Understand and implement a client for Floriday synchronization mechanism
* implement it for trade items
* Experiment: generate mock server from api definition for local development

## Later

* Goal: have a decent developer experience
* generate an api
* use the api to implement a generic sync implementation
* learn about typer wrt exceptions and exit codes
* document versioning strategy: what will we do when the api updates
* organize typer commands into submodules
* Experiment: generate mock server from api definition for local development

## Later

* Goal: show open quotations for a supplier on Floriday.
* retrieve "Supply Line" information
* create a Serra Vine dashboard for open quotations
* Goal: learn/ understand the FLoriday api
* Watch Floriday instruction videos and read som tutorials
* Understand and implement a client for Floriday synchronization mechanism
* implement it for trade items

## Out of Scope

0 comments on commit d24b50a

Please sign in to comment.