-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
155 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
name: run tests | ||
|
||
on: [push] | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: 'read' | ||
id-token: 'write' | ||
|
||
steps: | ||
- name: Authenticate to Google Cloud | ||
id: auth | ||
uses: google-github-actions/auth@v1 | ||
with: | ||
token_format: access_token | ||
workload_identity_provider: projects/949875736540/locations/global/workloadIdentityPools/external-pool/providers/github-provider | ||
service_account: [email protected] | ||
- name: Login to GAR | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: europe-west3-docker.pkg.dev | ||
username: oauth2accesstoken | ||
password: ${{ steps.auth.outputs.access_token }} | ||
- uses: actions/checkout@v4 | ||
- uses: hoverkraft-tech/[email protected] | ||
- name: Set up Python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: '3.x' | ||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install -r requirements.txt | ||
- name: Run example | ||
run: | | ||
python example.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
services: | ||
api-service: | ||
image: eu.gcr.io/talon-farm2/talon-one/talon-service/master:latest | ||
depends_on: | ||
- database-service | ||
ports: | ||
- "9000:9000" | ||
environment: | ||
- TALON_DB_NAME=talon | ||
- TALON_DB_USER=talon | ||
- TALON_DB_PASSWORD=talon.one.9000 | ||
- TALON_DB_HOST=database-service | ||
- TALON_DB_PORT=5432 | ||
- TALON_ENABLE_WEBHOOK_WORKER_POOL=false | ||
- TZ=UTC | ||
- RELEASE_STAGE=ci | ||
- TALON_CH_ENABLED=false | ||
- TALON_DISABLE_PROFILER=true | ||
- USE_REPLICA_DB=false | ||
command: | ||
- /talon/talon | ||
healthcheck: | ||
test: ["CMD", "curl", "-f", "http://localhost:9000/v1/status/health"] | ||
interval: 10s | ||
timeout: 5s | ||
retries: 10 | ||
restart: "on-failure:10" | ||
|
||
database-service: | ||
image: docker.io/bitnami/postgresql:15 | ||
volumes: | ||
- 'postgresql_master_data:/bitnami/postgresql' | ||
ports: | ||
- "5433:5432" | ||
environment: | ||
- POSTGRESQL_DATABASE=talon | ||
- POSTGRESQL_USERNAME=talon | ||
- POSTGRESQL_PASSWORD=talon.one.9000 | ||
healthcheck: | ||
test: ["CMD-SHELL", "pg_isready -U talon -d talon"] | ||
interval: 10s | ||
timeout: 5s | ||
retries: 5 | ||
restart: "on-failure:10" | ||
|
||
volumes: | ||
postgresql_master_data: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import talon_one | ||
from talon_one.rest import ApiException | ||
from pprint import pprint | ||
import json | ||
|
||
# Create configuration with your host destination and authorization using api_key_v1 | ||
configuration = talon_one.Configuration( | ||
host = "http://localhost:9000", | ||
api_key_prefix = { | ||
"Authorization": "ApiKey-v1" | ||
}, | ||
api_key = { | ||
"Authorization": "e18149e88f42247f0123456789abcdef9302722577ad60cebc86c4333b6fb70" | ||
} | ||
) | ||
|
||
# Integration API example to send a session update | ||
integration_api = talon_one.IntegrationApi(talon_one.ApiClient(configuration)) | ||
|
||
# Preparing a NewCustomerSessionV2 object | ||
customer_session = talon_one.NewCustomerSessionV2( | ||
"PROFILE_ID" | ||
) | ||
customer_session.cart _items = [ | ||
talon_one.CartItem(name="Red Spring Blouse", | ||
sku="rdbs-1111", | ||
quantity=1, | ||
price=49, | ||
category="Shirts"), | ||
talon_one.CartItem(name="Denim Trousers", | ||
sku="dtr-2222", | ||
quantity=1, | ||
price=74, | ||
category="Trousers"), | ||
] | ||
customer_session.coupon_codes = [ | ||
"Cool_Stuff" | ||
] | ||
|
||
# Instantiating a new IntegrationRequest object | ||
integration_request = talon_one.IntegrationRequest( | ||
customer_session, | ||
# Optional list of requested information to be present on the response. | ||
# See models/integration_request.py for full list | ||
# ["customerSession", "loyalty"] | ||
) | ||
|
||
# Create/update a customer session using `update_customer_session_v2` function | ||
api_response = integration_api.update_customer_session_v2("my_unique_session_v2_id", integration_request) | ||
encoded_data = json.dumps(api_response.to_dict(), default=str) | ||
pprint(encoded_data) | ||
|
||
# Parsing the returned effects list, please consult https://developers.talon.one/Integration-API/handling-effects-v2 for the full list of effects and their corresponding properties | ||
for effect in api_response.effects: | ||
if effect.effect_type == "setDiscount": | ||
# Initiating right props instance according to the effect type | ||
setDiscountProps = integration_api.api_client.deserialize_model(effect.props, talon_one.SetDiscountEffectProps) | ||
|
||
# Access the specific effect's properties | ||
print("Set a discount '{name}' of {value}".format( | ||
name = setDiscountProps.name, | ||
value = setDiscountProps.value | ||
)) | ||
elif effect.effect_type == "rejectCoupon": | ||
rejectCouponEffectProps = integration_api.api_client.deserialize_model(effect.props, talon_one.RejectCouponEffectProps) | ||
|
||
# Work with AcceptCouponEffectProps' properties | ||
# ... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
pytest~=4.6.7 # needed for python 2.7+3.4 | ||
pytest~=8.3.3 # needed for python 2.7+3.4 | ||
pytest-cov>=2.8.1 | ||
pytest-randomly==1.2.3 # needed for python 2.7+3.4 | ||
pytest-randomly==3.16.0 # needed for python 2.7+3.4 |