python-brickscout-api


Namepython-brickscout-api JSON
Version 1.1.2 PyPI version JSON
download
home_pagehttps://github.com/alexanderlhsglobal/python-brickscout-api
SummaryWrapper for the BrickScout API
upload_time2023-11-08 18:36:44
maintainer
docs_urlNone
authorAlexander Schillemans
requires_python
licenseGPL-3.0-or-later
keywords brickscout brick scout brick scout lego api
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # python-brickscout-api
Wrapper for the BrickScout API

## Install
This package is published on PyPi: https://pypi.org/project/python-brickscout-api/

Install with pip

```python
pip install python-brickscout-api
```

## Usage

Usage at this point is minimal. I will extend this package as I go and as I need.

### Create connection

You will need your username and password.

Create a new API connection

```python
from brickscout.api import BrickScoutAPI
api = BrickScoutAPI(username='xxx', password='xxx')
```

### Orders

1. Get all open orders

Orders are considered open if they have not been marked as deleted or shipped.

```python
orders = api.orders.get_open_orders()
for order in orders.iterator():
    print(vars(order))
```

2. Retrieve an order

```python
order = api.orders.get(id)
print(vars(order))
```

3. Update an order

```python
order = api.orders.get(id)
order.internalComment = 'this is my new comment'
api.orders.update(order)
```

4. Mark an order as **PAID**

```python
order = api.orders.get(id)
api.orders.mark_as_paid(order)
```

5. Mark an order as **PACKED**

```python
order = api.orders.get(id)
api.orders.mark_as_packed(order)
```

4. Mark an order as **SHIPPED**

```python
order = api.orders.get(id)
api.orders.mark_as_shipped(order)
```

### Error handling

Basic error handling has been added. You can check if an error has occured during a call by checking the ```has_error``` attribute on an object. If the ```has_error``` has been set to ```True```, an ```Error``` object will be attached to the ```error``` attribute of the same object. The ```Error``` object contains following attributes: ```type```, ```exception_code```, ```developer_message```, ```more_info_url``` and ```timestamp```.

```python
order = api.orders.get(id)

if order.has_error:
    print(order.error.exception_code)
    print(order.error.developer_message)
```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/alexanderlhsglobal/python-brickscout-api",
    "name": "python-brickscout-api",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "brickscout,brick,scout,brick scout,lego,api",
    "author": "Alexander Schillemans",
    "author_email": "alexander.schillemans@hotmail.com",
    "download_url": "https://files.pythonhosted.org/packages/25/19/9d7728d0f2c92adc350dd452a67a8898e90e7bf4b34a5c3362af6e326271/python-brickscout-api-1.1.2.tar.gz",
    "platform": null,
    "description": "# python-brickscout-api\r\nWrapper for the BrickScout API\r\n\r\n## Install\r\nThis package is published on PyPi: https://pypi.org/project/python-brickscout-api/\r\n\r\nInstall with pip\r\n\r\n```python\r\npip install python-brickscout-api\r\n```\r\n\r\n## Usage\r\n\r\nUsage at this point is minimal. I will extend this package as I go and as I need.\r\n\r\n### Create connection\r\n\r\nYou will need your username and password.\r\n\r\nCreate a new API connection\r\n\r\n```python\r\nfrom brickscout.api import BrickScoutAPI\r\napi = BrickScoutAPI(username='xxx', password='xxx')\r\n```\r\n\r\n### Orders\r\n\r\n1. Get all open orders\r\n\r\nOrders are considered open if they have not been marked as deleted or shipped.\r\n\r\n```python\r\norders = api.orders.get_open_orders()\r\nfor order in orders.iterator():\r\n    print(vars(order))\r\n```\r\n\r\n2. Retrieve an order\r\n\r\n```python\r\norder = api.orders.get(id)\r\nprint(vars(order))\r\n```\r\n\r\n3. Update an order\r\n\r\n```python\r\norder = api.orders.get(id)\r\norder.internalComment = 'this is my new comment'\r\napi.orders.update(order)\r\n```\r\n\r\n4. Mark an order as **PAID**\r\n\r\n```python\r\norder = api.orders.get(id)\r\napi.orders.mark_as_paid(order)\r\n```\r\n\r\n5. Mark an order as **PACKED**\r\n\r\n```python\r\norder = api.orders.get(id)\r\napi.orders.mark_as_packed(order)\r\n```\r\n\r\n4. Mark an order as **SHIPPED**\r\n\r\n```python\r\norder = api.orders.get(id)\r\napi.orders.mark_as_shipped(order)\r\n```\r\n\r\n### Error handling\r\n\r\nBasic error handling has been added. You can check if an error has occured during a call by checking the ```has_error``` attribute on an object. If the ```has_error``` has been set to ```True```, an ```Error``` object will be attached to the ```error``` attribute of the same object. The ```Error``` object contains following attributes: ```type```, ```exception_code```, ```developer_message```, ```more_info_url``` and ```timestamp```.\r\n\r\n```python\r\norder = api.orders.get(id)\r\n\r\nif order.has_error:\r\n    print(order.error.exception_code)\r\n    print(order.error.developer_message)\r\n```\r\n",
    "bugtrack_url": null,
    "license": "GPL-3.0-or-later",
    "summary": "Wrapper for the BrickScout API",
    "version": "1.1.2",
    "project_urls": {
        "Download": "https://github.com/alexanderlhsglobal/python-brickscout-api/archive/refs/tags/1.1.2.tar.gz",
        "Homepage": "https://github.com/alexanderlhsglobal/python-brickscout-api"
    },
    "split_keywords": [
        "brickscout",
        "brick",
        "scout",
        "brick scout",
        "lego",
        "api"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "25199d7728d0f2c92adc350dd452a67a8898e90e7bf4b34a5c3362af6e326271",
                "md5": "2fe43e596f4c5666382b55c2cc0c6595",
                "sha256": "b9ac478c863411a29a03bd4c469ebf97eec5a6340fa879511cbc9a1e86a0bfda"
            },
            "downloads": -1,
            "filename": "python-brickscout-api-1.1.2.tar.gz",
            "has_sig": false,
            "md5_digest": "2fe43e596f4c5666382b55c2cc0c6595",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 22656,
            "upload_time": "2023-11-08T18:36:44",
            "upload_time_iso_8601": "2023-11-08T18:36:44.691624Z",
            "url": "https://files.pythonhosted.org/packages/25/19/9d7728d0f2c92adc350dd452a67a8898e90e7bf4b34a5c3362af6e326271/python-brickscout-api-1.1.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-11-08 18:36:44",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "alexanderlhsglobal",
    "github_project": "python-brickscout-api",
    "github_not_found": true,
    "lcname": "python-brickscout-api"
}
        
Elapsed time: 0.17154s