yango-tech-grocery-client


Nameyango-tech-grocery-client JSON
Version 0.1.2 PyPI version JSON
download
home_pageNone
SummaryA Python client library for interacting with the Yango Tech Grocery API
upload_time2025-08-16 09:19:03
maintainerNone
docs_urlNone
authorNone
requires_python<4.0,>=3.9
licenseMIT
keywords yango grocery api client delivery ecommerce
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Yango Tech Grocery API Client

A Python client library for interacting with the Yango Tech Grocery API. This library provides a comprehensive interface for managing orders, products, prices, stocks, and other grocery-related operations.

## Features

- **Order Management**: Create, update, cancel, and track orders
- **Product Management**: Create and update products, manage product media and VAT
- **Price Management**: Handle price lists, prices, and discounts
- **Stock Management**: Update and retrieve stock information
- **Store Management**: Get store information
- **Receipt Management**: Upload and retrieve receipts
- **Event Handling**: Process order events and state changes
- **Async Support**: Full async/await support for all operations
- **Error Handling**: Comprehensive error handling with retry logic

## Installation

```bash
pip install yango-grocery-client
```

## Quick Start

### Basic Setup

```python
import asyncio
from yango_grocery_client import YangoClient

async def main():
    # Initialize the client
    client = YangoClient(
        domain="https://api.retailtech.yango.com",
        auth_token="your_auth_token_here"
    )
    
    # Your API calls here
    stores = await client.get_stores()
    print(f"Found {len(stores)} stores")

# Run the async function
asyncio.run(main())
```

## API Examples

### Order Management

#### Create an Order

```python
from yango_grocery_client import YangoClient, YangoOrderRecord, YangoShoppingCartItem

async def create_order_example():
    client = YangoClient(domain="https://api.retailtech.yango.com", auth_token="your_token")
    
    # Create shopping cart items
    cart_items = [
        YangoShoppingCartItem(
            product_id="product_123",
            quantity=2,
            price="150.00",
            discount="10.00",
            vat="20.00"
        )
    ]
    
    # Create order record
    order = YangoOrderRecord(
        order_id="order_456",
        store_id="store_789",
        customer_phone="+1234567890",
        customer_name="John Doe",
        delivery_address="123 Main St, City",
        delivery_latitude=55.7558,
        delivery_longitude=37.6176,
        cart_items=cart_items,
        total_price="290.00",
        delivery_fee="50.00",
        payment_method="card"
    )
    
    # Create the order
    result = await client.create_order(order)
    print(f"Order created: {result}")

```

#### Get Order Details

```python
async def get_order_example():
    client = YangoClient(domain="https://api.retailtech.yango.com", auth_token="your_token")
    
    # Get order details
    order_detail = await client.get_order_detail("order_456")
    print(f"Order status: {order_detail['status']}")
    print(f"Order total: {order_detail['total_price']}")

```

#### Cancel an Order

```python
async def cancel_order_example():
    client = YangoClient(domain="https://api.retailtech.yango.com", auth_token="your_token")
    
    # Cancel order with reason
    result = await client.cancel_order(
        order_id="order_456",
        reason="Customer requested cancellation"
    )
    print(f"Order cancelled: {result}")

```

#### Get Orders State

```python
async def get_orders_state_example():
    client = YangoClient(domain="https://api.retailtech.yango.com", auth_token="your_token")
    
    # Get state of multiple orders
    order_ids = ["order_456", "order_789", "order_101"]
    states = await client.get_orders_state(order_ids)
    
    for order_state in states:
        print(f"Order {order_state['order_id']}: {order_state['state']}")

```

### Product Management

#### Get All Products

```python
async def get_products_example():
    client = YangoClient(domain="https://api.retailtech.yango.com", auth_token="your_token")
    
    # Get all active products
    products = await client.get_all_products(only_active=True)
    
    print(f"Found {len(products)} active products")
    for product_id, product in products.items():
        print(f"Product {product_id}: {product.name} - {product.price}")

```

#### Create Products

```python
from yango_grocery_client import YangoProductData, YangoCustomAttributes

async def create_products_example():
    client = YangoClient(domain="https://api.retailtech.yango.com", auth_token="your_token")
    
    # Create product data
    product = YangoProductData(
        product_id="new_product_123",
        name="Fresh Apples",
        description="Sweet and juicy apples",
        price="99.99",
        category_id="fruits",
        barcode="1234567890123",
        weight=0.5,
        unit="kg",
        custom_attributes=YangoCustomAttributes(
            brand="Organic Farm",
            country_of_origin="Poland"
        )
    )
    
    # Create the product
    await client.create_products([product])
    print("Product created successfully")

```

#### Get Product Updates

```python
async def get_product_updates_example():
    client = YangoClient(domain="https://api.retailtech.yango.com", auth_token="your_token")
    
    # Get product updates (streaming)
    async for product in client.get_product_updates():
        print(f"Product update: {product.product_id} - {product.name}")

```

### Price Management

#### Create Price Lists

```python
from yango_grocery_client import YangoPriceListUpdateData

async def create_price_lists_example():
    client = YangoClient(domain="https://api.retailtech.yango.com", auth_token="your_token")
    
    price_list = YangoPriceListUpdateData(
        id="price_list_123",
        name="Regular Prices",
        status="active"
    )
    
    await client.create_price_lists([price_list])
    print("Price list created")

```

#### Get Prices

```python
async def get_prices_example():
    client = YangoClient(domain="https://api.retailtech.yango.com", auth_token="your_token")
    
    # Get prices for specific price lists
    price_list_ids = ["price_list_123", "price_list_456"]
    prices = await client.get_prices(price_list_ids)
    
    for price_list_id, price_data in prices.items():
        print(f"Price list {price_list_id}:")
        for price in price_data:
            print(f"  Product {price.product_id}: {price.price}")

```

### Stock Management

#### Update Stocks

```python
from yango_grocery_client import YangoStockData, YangoStockUpdateMode

async def update_stocks_example():
    client = YangoClient(domain="https://api.retailtech.yango.com", auth_token="your_token")
    
    # Create stock data
    stock = YangoStockData(
        product_id="product_123",
        quantity=100,
        unit="unit"
    )
    
    # Update stocks for a store
    await client.update_stocks(
        wms_store_id="store_789",
        stocks=[stock]
    )
    print("Stocks updated successfully")

```

#### Get Stocks

```python
async def get_stocks_example():
    client = YangoClient(domain="https://api.retailtech.yango.com", auth_token="your_token")
    
    # Get stocks
    stocks = await client.get_stocks()
    print(f"Retrieved {len(stocks['stocks'])} stock records")

```

### Store Management

#### Get Stores

```python
async def get_stores_example():
    client = YangoClient(domain="https://api.retailtech.yango.com", auth_token="your_token")
    
    # Get all stores
    stores = await client.get_stores()
    
    for store in stores:
        print(f"Store {store.store_id}: {store.name}")
        print(f"  Address: {store.address}")
        print(f"  Coordinates: {store.latitude}, {store.longitude}")

```

### Receipt Management

#### Upload Receipt

```python
async def upload_receipt_example():
    client = YangoClient(domain="https://api.retailtech.yango.com", auth_token="your_token")
    
    # Upload receipt document (PDF)
    with open("receipt.pdf", "r") as f:
        document_content = f.read()
    
    await client.upload_receipt(
        receipt_id="receipt_123",
        document=document_content
    )
    print("Receipt uploaded successfully")

```

#### Get Receipt

```python
async def get_receipt_example():
    client = YangoClient(domain="https://api.retailtech.yango.com", auth_token="your_token")
    
    # Get receipt details
    receipt = await client.get_receipt("receipt_123")
    print(f"Receipt amount: {receipt.amount}")
    print(f"Receipt status: {receipt.status}")

```

### Event Handling

#### Get Order Events

```python
async def get_order_events_example():
    client = YangoClient(domain="https://api.retailtech.yango.com", auth_token="your_token")
    
    # Get order events
    events_response = await client.get_orders_events_query()
    
    print(f"Next cursor: {events_response.cursor}")
    for event in events_response.orders_events:
        print(f"Order {event.order_id}: {event.data.type} at {event.occurred}")

```

### Error Handling

```python
from yango_grocery_client import YangoBadRequest, YangoRequestError

async def error_handling_example():
    client = YangoClient(domain="https://api.retailtech.yango.com", auth_token="your_token")
    
    try:
        # This might fail if order doesn't exist
        order = await client.get_order_detail("non_existent_order")
    except YangoBadRequest as e:
        print(f"Bad request error: {e.message}")
        print(f"Error details: {e.payload}")
    except YangoRequestError as e:
        print(f"Request error: {e.message}")
        print(f"Status code: {e.status}")

```

## Configuration

### Client Initialization Options

```python
client = YangoClient(
    domain="https://api.retailtech.yango.com",  # API domain
    auth_token="your_auth_token",           # Authentication token
    error_handler=custom_error_handler,     # Optional custom error handler
    proxy="http://proxy.example.com:8080"   # Optional proxy configuration
)
```

### Environment Variables

You can also configure the client using environment variables:

```bash
export YANGO_DOMAIN="https://api.retailtech.yango.com"
export YANGO_AUTH_TOKEN="your_auth_token"
```

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "yango-tech-grocery-client",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4.0,>=3.9",
    "maintainer_email": null,
    "keywords": "yango, grocery, api, client, delivery, ecommerce",
    "author": null,
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/28/5a/3358d27d490b85b69e80c4517ca1683f62fb94b0f79327f8560dcf5cca23/yango_tech_grocery_client-0.1.2.tar.gz",
    "platform": null,
    "description": "# Yango Tech Grocery API Client\n\nA Python client library for interacting with the Yango Tech Grocery API. This library provides a comprehensive interface for managing orders, products, prices, stocks, and other grocery-related operations.\n\n## Features\n\n- **Order Management**: Create, update, cancel, and track orders\n- **Product Management**: Create and update products, manage product media and VAT\n- **Price Management**: Handle price lists, prices, and discounts\n- **Stock Management**: Update and retrieve stock information\n- **Store Management**: Get store information\n- **Receipt Management**: Upload and retrieve receipts\n- **Event Handling**: Process order events and state changes\n- **Async Support**: Full async/await support for all operations\n- **Error Handling**: Comprehensive error handling with retry logic\n\n## Installation\n\n```bash\npip install yango-grocery-client\n```\n\n## Quick Start\n\n### Basic Setup\n\n```python\nimport asyncio\nfrom yango_grocery_client import YangoClient\n\nasync def main():\n    # Initialize the client\n    client = YangoClient(\n        domain=\"https://api.retailtech.yango.com\",\n        auth_token=\"your_auth_token_here\"\n    )\n    \n    # Your API calls here\n    stores = await client.get_stores()\n    print(f\"Found {len(stores)} stores\")\n\n# Run the async function\nasyncio.run(main())\n```\n\n## API Examples\n\n### Order Management\n\n#### Create an Order\n\n```python\nfrom yango_grocery_client import YangoClient, YangoOrderRecord, YangoShoppingCartItem\n\nasync def create_order_example():\n    client = YangoClient(domain=\"https://api.retailtech.yango.com\", auth_token=\"your_token\")\n    \n    # Create shopping cart items\n    cart_items = [\n        YangoShoppingCartItem(\n            product_id=\"product_123\",\n            quantity=2,\n            price=\"150.00\",\n            discount=\"10.00\",\n            vat=\"20.00\"\n        )\n    ]\n    \n    # Create order record\n    order = YangoOrderRecord(\n        order_id=\"order_456\",\n        store_id=\"store_789\",\n        customer_phone=\"+1234567890\",\n        customer_name=\"John Doe\",\n        delivery_address=\"123 Main St, City\",\n        delivery_latitude=55.7558,\n        delivery_longitude=37.6176,\n        cart_items=cart_items,\n        total_price=\"290.00\",\n        delivery_fee=\"50.00\",\n        payment_method=\"card\"\n    )\n    \n    # Create the order\n    result = await client.create_order(order)\n    print(f\"Order created: {result}\")\n\n```\n\n#### Get Order Details\n\n```python\nasync def get_order_example():\n    client = YangoClient(domain=\"https://api.retailtech.yango.com\", auth_token=\"your_token\")\n    \n    # Get order details\n    order_detail = await client.get_order_detail(\"order_456\")\n    print(f\"Order status: {order_detail['status']}\")\n    print(f\"Order total: {order_detail['total_price']}\")\n\n```\n\n#### Cancel an Order\n\n```python\nasync def cancel_order_example():\n    client = YangoClient(domain=\"https://api.retailtech.yango.com\", auth_token=\"your_token\")\n    \n    # Cancel order with reason\n    result = await client.cancel_order(\n        order_id=\"order_456\",\n        reason=\"Customer requested cancellation\"\n    )\n    print(f\"Order cancelled: {result}\")\n\n```\n\n#### Get Orders State\n\n```python\nasync def get_orders_state_example():\n    client = YangoClient(domain=\"https://api.retailtech.yango.com\", auth_token=\"your_token\")\n    \n    # Get state of multiple orders\n    order_ids = [\"order_456\", \"order_789\", \"order_101\"]\n    states = await client.get_orders_state(order_ids)\n    \n    for order_state in states:\n        print(f\"Order {order_state['order_id']}: {order_state['state']}\")\n\n```\n\n### Product Management\n\n#### Get All Products\n\n```python\nasync def get_products_example():\n    client = YangoClient(domain=\"https://api.retailtech.yango.com\", auth_token=\"your_token\")\n    \n    # Get all active products\n    products = await client.get_all_products(only_active=True)\n    \n    print(f\"Found {len(products)} active products\")\n    for product_id, product in products.items():\n        print(f\"Product {product_id}: {product.name} - {product.price}\")\n\n```\n\n#### Create Products\n\n```python\nfrom yango_grocery_client import YangoProductData, YangoCustomAttributes\n\nasync def create_products_example():\n    client = YangoClient(domain=\"https://api.retailtech.yango.com\", auth_token=\"your_token\")\n    \n    # Create product data\n    product = YangoProductData(\n        product_id=\"new_product_123\",\n        name=\"Fresh Apples\",\n        description=\"Sweet and juicy apples\",\n        price=\"99.99\",\n        category_id=\"fruits\",\n        barcode=\"1234567890123\",\n        weight=0.5,\n        unit=\"kg\",\n        custom_attributes=YangoCustomAttributes(\n            brand=\"Organic Farm\",\n            country_of_origin=\"Poland\"\n        )\n    )\n    \n    # Create the product\n    await client.create_products([product])\n    print(\"Product created successfully\")\n\n```\n\n#### Get Product Updates\n\n```python\nasync def get_product_updates_example():\n    client = YangoClient(domain=\"https://api.retailtech.yango.com\", auth_token=\"your_token\")\n    \n    # Get product updates (streaming)\n    async for product in client.get_product_updates():\n        print(f\"Product update: {product.product_id} - {product.name}\")\n\n```\n\n### Price Management\n\n#### Create Price Lists\n\n```python\nfrom yango_grocery_client import YangoPriceListUpdateData\n\nasync def create_price_lists_example():\n    client = YangoClient(domain=\"https://api.retailtech.yango.com\", auth_token=\"your_token\")\n    \n    price_list = YangoPriceListUpdateData(\n        id=\"price_list_123\",\n        name=\"Regular Prices\",\n        status=\"active\"\n    )\n    \n    await client.create_price_lists([price_list])\n    print(\"Price list created\")\n\n```\n\n#### Get Prices\n\n```python\nasync def get_prices_example():\n    client = YangoClient(domain=\"https://api.retailtech.yango.com\", auth_token=\"your_token\")\n    \n    # Get prices for specific price lists\n    price_list_ids = [\"price_list_123\", \"price_list_456\"]\n    prices = await client.get_prices(price_list_ids)\n    \n    for price_list_id, price_data in prices.items():\n        print(f\"Price list {price_list_id}:\")\n        for price in price_data:\n            print(f\"  Product {price.product_id}: {price.price}\")\n\n```\n\n### Stock Management\n\n#### Update Stocks\n\n```python\nfrom yango_grocery_client import YangoStockData, YangoStockUpdateMode\n\nasync def update_stocks_example():\n    client = YangoClient(domain=\"https://api.retailtech.yango.com\", auth_token=\"your_token\")\n    \n    # Create stock data\n    stock = YangoStockData(\n        product_id=\"product_123\",\n        quantity=100,\n        unit=\"unit\"\n    )\n    \n    # Update stocks for a store\n    await client.update_stocks(\n        wms_store_id=\"store_789\",\n        stocks=[stock]\n    )\n    print(\"Stocks updated successfully\")\n\n```\n\n#### Get Stocks\n\n```python\nasync def get_stocks_example():\n    client = YangoClient(domain=\"https://api.retailtech.yango.com\", auth_token=\"your_token\")\n    \n    # Get stocks\n    stocks = await client.get_stocks()\n    print(f\"Retrieved {len(stocks['stocks'])} stock records\")\n\n```\n\n### Store Management\n\n#### Get Stores\n\n```python\nasync def get_stores_example():\n    client = YangoClient(domain=\"https://api.retailtech.yango.com\", auth_token=\"your_token\")\n    \n    # Get all stores\n    stores = await client.get_stores()\n    \n    for store in stores:\n        print(f\"Store {store.store_id}: {store.name}\")\n        print(f\"  Address: {store.address}\")\n        print(f\"  Coordinates: {store.latitude}, {store.longitude}\")\n\n```\n\n### Receipt Management\n\n#### Upload Receipt\n\n```python\nasync def upload_receipt_example():\n    client = YangoClient(domain=\"https://api.retailtech.yango.com\", auth_token=\"your_token\")\n    \n    # Upload receipt document (PDF)\n    with open(\"receipt.pdf\", \"r\") as f:\n        document_content = f.read()\n    \n    await client.upload_receipt(\n        receipt_id=\"receipt_123\",\n        document=document_content\n    )\n    print(\"Receipt uploaded successfully\")\n\n```\n\n#### Get Receipt\n\n```python\nasync def get_receipt_example():\n    client = YangoClient(domain=\"https://api.retailtech.yango.com\", auth_token=\"your_token\")\n    \n    # Get receipt details\n    receipt = await client.get_receipt(\"receipt_123\")\n    print(f\"Receipt amount: {receipt.amount}\")\n    print(f\"Receipt status: {receipt.status}\")\n\n```\n\n### Event Handling\n\n#### Get Order Events\n\n```python\nasync def get_order_events_example():\n    client = YangoClient(domain=\"https://api.retailtech.yango.com\", auth_token=\"your_token\")\n    \n    # Get order events\n    events_response = await client.get_orders_events_query()\n    \n    print(f\"Next cursor: {events_response.cursor}\")\n    for event in events_response.orders_events:\n        print(f\"Order {event.order_id}: {event.data.type} at {event.occurred}\")\n\n```\n\n### Error Handling\n\n```python\nfrom yango_grocery_client import YangoBadRequest, YangoRequestError\n\nasync def error_handling_example():\n    client = YangoClient(domain=\"https://api.retailtech.yango.com\", auth_token=\"your_token\")\n    \n    try:\n        # This might fail if order doesn't exist\n        order = await client.get_order_detail(\"non_existent_order\")\n    except YangoBadRequest as e:\n        print(f\"Bad request error: {e.message}\")\n        print(f\"Error details: {e.payload}\")\n    except YangoRequestError as e:\n        print(f\"Request error: {e.message}\")\n        print(f\"Status code: {e.status}\")\n\n```\n\n## Configuration\n\n### Client Initialization Options\n\n```python\nclient = YangoClient(\n    domain=\"https://api.retailtech.yango.com\",  # API domain\n    auth_token=\"your_auth_token\",           # Authentication token\n    error_handler=custom_error_handler,     # Optional custom error handler\n    proxy=\"http://proxy.example.com:8080\"   # Optional proxy configuration\n)\n```\n\n### Environment Variables\n\nYou can also configure the client using environment variables:\n\n```bash\nexport YANGO_DOMAIN=\"https://api.retailtech.yango.com\"\nexport YANGO_AUTH_TOKEN=\"your_auth_token\"\n```\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A Python client library for interacting with the Yango Tech Grocery API",
    "version": "0.1.2",
    "project_urls": {
        "Bug Tracker": "https://github.com/yango-tech/yango-tech-grocery-client/issues",
        "Documentation": "https://github.com/yango-tech/yango-tech-grocery-client#readme",
        "Homepage": "https://github.com/yango-tech/yango-tech-grocery-client",
        "Repository": "https://github.com/yango-tech/yango-tech-grocery-client"
    },
    "split_keywords": [
        "yango",
        " grocery",
        " api",
        " client",
        " delivery",
        " ecommerce"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "1ec65828fadd34d5d07e80dc0031cee46c64de7e6a4e98df0f5e08c3ebe5224d",
                "md5": "8a6386bfb769f115818d699f4717ef79",
                "sha256": "985bb18d75993afe2f2bf0083da3eeb41c11bda12386468e911f82f14f877fde"
            },
            "downloads": -1,
            "filename": "yango_tech_grocery_client-0.1.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "8a6386bfb769f115818d699f4717ef79",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.9",
            "size": 16968,
            "upload_time": "2025-08-16T09:19:02",
            "upload_time_iso_8601": "2025-08-16T09:19:02.583113Z",
            "url": "https://files.pythonhosted.org/packages/1e/c6/5828fadd34d5d07e80dc0031cee46c64de7e6a4e98df0f5e08c3ebe5224d/yango_tech_grocery_client-0.1.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "285a3358d27d490b85b69e80c4517ca1683f62fb94b0f79327f8560dcf5cca23",
                "md5": "cec2e7af91d6df2df33f6942b135acfb",
                "sha256": "a9dbbfa69ea08f6b27b7f20605a744f806b77ba4088c01a495985c4cf5706bb2"
            },
            "downloads": -1,
            "filename": "yango_tech_grocery_client-0.1.2.tar.gz",
            "has_sig": false,
            "md5_digest": "cec2e7af91d6df2df33f6942b135acfb",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.9",
            "size": 15497,
            "upload_time": "2025-08-16T09:19:03",
            "upload_time_iso_8601": "2025-08-16T09:19:03.425214Z",
            "url": "https://files.pythonhosted.org/packages/28/5a/3358d27d490b85b69e80c4517ca1683f62fb94b0f79327f8560dcf5cca23/yango_tech_grocery_client-0.1.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-08-16 09:19:03",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "yango-tech",
    "github_project": "yango-tech-grocery-client",
    "github_not_found": true,
    "lcname": "yango-tech-grocery-client"
}
        
Elapsed time: 0.67591s