aiokeepin


Nameaiokeepin JSON
Version 0.2.2 PyPI version JSON
download
home_pagehttps://github.com/radzih/aiokeepin
SummaryAsync python wrapper for KeepinCRM API
upload_time2023-06-08 15:53:15
maintainer
docs_urlNone
authorVadim Radzih
requires_python>=3.10,<4.0
licenseMIT
keywords keepin keepincrm api wrapper async httpx aiokeepin
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Async Python Wrapper for KeepinCRM API

This is an async Python wrapper for the KeepinCRM API that allows you to interact with the API using simple and convenient methods. The wrapper provides a `KeepinClient` class with async methods for making HTTP requests and retrieving data from the API.

## Installation

You can install the library using pip:

```shell
pip install aiokeepin
```

## Usage

To use the KeepinCRM async Python wrapper, import the `KeepinClient` class from the library:

```python
from aiokeepin import KeepinClient
```

### Initializing the Client

Create an instance of the `KeepinClient` class by providing your API key:

```python
client = KeepinClient(api_key='YOUR_API_KEY')
```

### Making API Requests

The `KeepinClient` instance provides async methods that correspond to the different HTTP request methods (`GET`, `POST`, `PATCH`, `PUT`, `DELETE`). Each method returns a dictionary containing the response from the API.

#### GET Request Example

```python
response = await client.get('/clients')
print(response)
```

#### POST Request Example

```python
data = {
  "email": "pib@example.com",
  "company": "Назва чи ПІБ",
  "lead": True,
  "source_id": 5,
  "status_id": 1,
  "phones": [
    "+380000000001"
  ],
  "tag_names": [
    "VIP"
  ],
  "contacts_attributes": [
    {
      "fullname": "Прізвище Імʼя По батькові",
      "phones": [
        "+380000000002"
      ],
      "custom_fields": [
        {
          "name": "Посада",
          "value": "Директор"
        }
      ]
    }
  ]
}

response = await client.post('/clients', data=data)
print(response)
```

#### PATCH Request Example

```python
data = {
  "email": "new_email@example.com"
}

response = await client.patch('/clients/{client_id}', data=data)
print(response)
```

#### PUT Request Example

```python
data = {
  "email": "updated_email@example.com"
}

response = await client.put('/clients/{client_id}', data=data)
print(response)
```

#### DELETE Request Example

```python
response = await client.delete('/clients/{client_id}')
print(response)
```

#### GET Paginated Items Example

```python
response = await client.get_paginated_items('/clients')
```

## Error Handling

In case of an error response from the KeepinCRM API, an exception will be raised. The exceptions provided by the aiokeepin library inherit from the base `KeepinException` class. There are several specific exceptions available for different types of errors:

- `KeepinStatusError`: This exception is raised for non-2xx status codes. It contains the `status_code` and `response` attributes, providing information about the error.

- `InvalidAPIKeyError`: This exception is raised specifically for an invalid API key.

- `ValidationError`: This exception is raised for invalid data.

- `NotFoundError`: This exception is raised when the requested resource is not found.

- `InternalServerError`: This exception is raised for internal server errors.

When making API requests, you can handle exceptions using try-except blocks to capture and handle specific types of errors. Here's an example:

```python
from aiokeepin.exceptions import KeepinStatusError, InvalidAPIKeyError

try:
    response = await client.get('/nonexistent_endpoint')
except InvalidAPIKeyError:
    print("Invalid API key provided.")
except KeepinStatusError as e:
    print(f"Error: {e.status_code} - {e.response}")
```

You can customize the exception handling based on your specific needs. By catching the appropriate exceptions, you can handle different error scenarios and provide appropriate error messages or take specific actions. Make sure to refer to the documentation for the KeepinCRM API for more details on the possible error responses and their corresponding status codes.

## Documentation

For detailed information on the KeepinCRM API, refer to the official API documentation: [KeepinCRM API Documentation](https://app.swaggerhub.com/apis/KeepInCRM/keepincrm-api/0.12.3)

## License

This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for more information.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/radzih/aiokeepin",
    "name": "aiokeepin",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.10,<4.0",
    "maintainer_email": "",
    "keywords": "keepin,keepincrm,api,wrapper,async,httpx,aiokeepin",
    "author": "Vadim Radzih",
    "author_email": "iphonevadim2003@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/e3/8e/45f5bac184125bc8ef4197d3d26e9ded50509ea31c2116ac68a89c21b69f/aiokeepin-0.2.2.tar.gz",
    "platform": null,
    "description": "# Async Python Wrapper for KeepinCRM API\n\nThis is an async Python wrapper for the KeepinCRM API that allows you to interact with the API using simple and convenient methods. The wrapper provides a `KeepinClient` class with async methods for making HTTP requests and retrieving data from the API.\n\n## Installation\n\nYou can install the library using pip:\n\n```shell\npip install aiokeepin\n```\n\n## Usage\n\nTo use the KeepinCRM async Python wrapper, import the `KeepinClient` class from the library:\n\n```python\nfrom aiokeepin import KeepinClient\n```\n\n### Initializing the Client\n\nCreate an instance of the `KeepinClient` class by providing your API key:\n\n```python\nclient = KeepinClient(api_key='YOUR_API_KEY')\n```\n\n### Making API Requests\n\nThe `KeepinClient` instance provides async methods that correspond to the different HTTP request methods (`GET`, `POST`, `PATCH`, `PUT`, `DELETE`). Each method returns a dictionary containing the response from the API.\n\n#### GET Request Example\n\n```python\nresponse = await client.get('/clients')\nprint(response)\n```\n\n#### POST Request Example\n\n```python\ndata = {\n  \"email\": \"pib@example.com\",\n  \"company\": \"\u041d\u0430\u0437\u0432\u0430 \u0447\u0438 \u041f\u0406\u0411\",\n  \"lead\": True,\n  \"source_id\": 5,\n  \"status_id\": 1,\n  \"phones\": [\n    \"+380000000001\"\n  ],\n  \"tag_names\": [\n    \"VIP\"\n  ],\n  \"contacts_attributes\": [\n    {\n      \"fullname\": \"\u041f\u0440\u0456\u0437\u0432\u0438\u0449\u0435 \u0406\u043c\u02bc\u044f \u041f\u043e \u0431\u0430\u0442\u044c\u043a\u043e\u0432\u0456\",\n      \"phones\": [\n        \"+380000000002\"\n      ],\n      \"custom_fields\": [\n        {\n          \"name\": \"\u041f\u043e\u0441\u0430\u0434\u0430\",\n          \"value\": \"\u0414\u0438\u0440\u0435\u043a\u0442\u043e\u0440\"\n        }\n      ]\n    }\n  ]\n}\n\nresponse = await client.post('/clients', data=data)\nprint(response)\n```\n\n#### PATCH Request Example\n\n```python\ndata = {\n  \"email\": \"new_email@example.com\"\n}\n\nresponse = await client.patch('/clients/{client_id}', data=data)\nprint(response)\n```\n\n#### PUT Request Example\n\n```python\ndata = {\n  \"email\": \"updated_email@example.com\"\n}\n\nresponse = await client.put('/clients/{client_id}', data=data)\nprint(response)\n```\n\n#### DELETE Request Example\n\n```python\nresponse = await client.delete('/clients/{client_id}')\nprint(response)\n```\n\n#### GET Paginated Items Example\n\n```python\nresponse = await client.get_paginated_items('/clients')\n```\n\n## Error Handling\n\nIn case of an error response from the KeepinCRM API, an exception will be raised. The exceptions provided by the aiokeepin library inherit from the base `KeepinException` class. There are several specific exceptions available for different types of errors:\n\n- `KeepinStatusError`: This exception is raised for non-2xx status codes. It contains the `status_code` and `response` attributes, providing information about the error.\n\n- `InvalidAPIKeyError`: This exception is raised specifically for an invalid API key.\n\n- `ValidationError`: This exception is raised for invalid data.\n\n- `NotFoundError`: This exception is raised when the requested resource is not found.\n\n- `InternalServerError`: This exception is raised for internal server errors.\n\nWhen making API requests, you can handle exceptions using try-except blocks to capture and handle specific types of errors. Here's an example:\n\n```python\nfrom aiokeepin.exceptions import KeepinStatusError, InvalidAPIKeyError\n\ntry:\n    response = await client.get('/nonexistent_endpoint')\nexcept InvalidAPIKeyError:\n    print(\"Invalid API key provided.\")\nexcept KeepinStatusError as e:\n    print(f\"Error: {e.status_code} - {e.response}\")\n```\n\nYou can customize the exception handling based on your specific needs. By catching the appropriate exceptions, you can handle different error scenarios and provide appropriate error messages or take specific actions. Make sure to refer to the documentation for the KeepinCRM API for more details on the possible error responses and their corresponding status codes.\n\n## Documentation\n\nFor detailed information on the KeepinCRM API, refer to the official API documentation: [KeepinCRM API Documentation](https://app.swaggerhub.com/apis/KeepInCRM/keepincrm-api/0.12.3)\n\n## License\n\nThis project is licensed under the MIT License. See the [LICENSE](LICENSE) file for more information.\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Async python wrapper for KeepinCRM API",
    "version": "0.2.2",
    "project_urls": {
        "Homepage": "https://github.com/radzih/aiokeepin",
        "Repository": "https://github.com/radzih/aiokeepin"
    },
    "split_keywords": [
        "keepin",
        "keepincrm",
        "api",
        "wrapper",
        "async",
        "httpx",
        "aiokeepin"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "e6727be7ea5ef8e29413c9eb44ae5a6be830e858196f9ffe4d92588a52306ef0",
                "md5": "9328cc9fad01b65597ee5cc4d250896a",
                "sha256": "9e59a8731412a2c14cc50ec82acf35b9e682b1aea2bf44b930519cfed0eecf7f"
            },
            "downloads": -1,
            "filename": "aiokeepin-0.2.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "9328cc9fad01b65597ee5cc4d250896a",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10,<4.0",
            "size": 6735,
            "upload_time": "2023-06-08T15:53:12",
            "upload_time_iso_8601": "2023-06-08T15:53:12.663761Z",
            "url": "https://files.pythonhosted.org/packages/e6/72/7be7ea5ef8e29413c9eb44ae5a6be830e858196f9ffe4d92588a52306ef0/aiokeepin-0.2.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "e38e45f5bac184125bc8ef4197d3d26e9ded50509ea31c2116ac68a89c21b69f",
                "md5": "8b208d9076e05c920665694b9f8d7258",
                "sha256": "90a158d31ddec33614bab63c71fd6e02c6d8762f7e07f9f143b4d7f871449924"
            },
            "downloads": -1,
            "filename": "aiokeepin-0.2.2.tar.gz",
            "has_sig": false,
            "md5_digest": "8b208d9076e05c920665694b9f8d7258",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10,<4.0",
            "size": 4957,
            "upload_time": "2023-06-08T15:53:15",
            "upload_time_iso_8601": "2023-06-08T15:53:15.482104Z",
            "url": "https://files.pythonhosted.org/packages/e3/8e/45f5bac184125bc8ef4197d3d26e9ded50509ea31c2116ac68a89c21b69f/aiokeepin-0.2.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-06-08 15:53:15",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "radzih",
    "github_project": "aiokeepin",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "aiokeepin"
}
        
Elapsed time: 0.07796s