odoo-somconnexio-python-client


Nameodoo-somconnexio-python-client JSON
Version 0.1.37 PyPI version JSON
download
home_pagehttps://gitlab.com/coopdevs/odoo-somconnexio-python-client
SummaryPython wrapper for SomConnexio's Odoo (using REST API)
upload_time2023-07-27 08:06:41
maintainerDaniel Palomar
docs_urlNone
authorCoopdevs
requires_python
license
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            [![pipeline status](https://gitlab.com/coopdevs/odoo-somconnexio-python-client/badges/master/pipeline.svg)](https://gitlab.com/coopdevs/odoo-somconnexio-python-client/commits/master)
[![coverage report](https://gitlab.com/coopdevs/odoo-somconnexio-python-client/badges/master/coverage.svg)](https://gitlab.com/coopdevs/odoo-somconnexio-python-client/commits/master)

:warning: WORK IN PROGRESS :warning:

This library is a Python wrapper for accessing Somconnexio's Odoo (Odoo v12 with customizations).
More info about the customizations in [SomConnexio Odoo module](https://gitlab.com/coopdevs/odoo-somconnexio).

## Resources

* SubscriptionRequest - Customer order
* CRMLead - Service order
* Provider - Service providers
* DiscoveryChannel
* Partner - Customer information
* Contract - Contract information

## Installation

```commandline
$ pip install odoo-somconnexio-python-client
```

## Configuration Environment

You need define the Odoo API-KEY and URL as environment variables. You need define:

```
ODOO_BASEURL=<YOUR ODOO HOST>/api
ODOO_APIKEY=<YOUR ODOO API KEY>
```

If this envvars are not defined, a exception will be raised with the name of the envvar not defined.
More info about the API-KEY in [Auth API Key](https://github.com/OCA/server-auth/tree/12.0/auth_api_key) Odoo module.

## Usage

#### Search providers by service

```python
>>> from odoo_somconnexio_python_client.resources.provider import Provider
>>>
>>> mobile_providers = Provider.mobile_list()
>>> mobile_providers[0].id
123
>>> mobile_providers[0].name
"SomConnexió"
```

#### Get Partner with ref

```python
>>> from odoo_somconnexio_python_client.resources.partner import Partner
>>>
>>> partner = Partner.get(1234)
>>> partner.id
123
>>> partner.ref
"1234"
```

#### Search Partner by VAT number

```python
>>> from odoo_somconnexio_python_client.resources.partner import Partner
>>>
>>> partner = Partner.search_by_vat(vat="XXXX")
>>> partner.id
123
>>> partner.ref
"1234"
```

#### Search Contracts by partner's VAT number

```python
>>> from odoo_somconnexio_python_client.resources.contract import Contract
>>>
>>> contracts = Contract.search_by_customer_vat(vat="XXXX")
>>> contracts[0].id
123
>>> contracts[0].phone_number
"972445566"
```

### Create new mapper

Create a class that exposes a dict object with the next structure:

#### Create a SubscriptionRequest

```json
{
  "name": "string",
  "email": "string",
  "ordered_parts": 0,
  "share_product": 0,
  "address": {
    "street": "string",
    "street2": "string",
    "zip_code": "string",
    "city": "string",
    "country": "string",
    "state": "string"
  },
  "lang": "string",
  "iban": "string",
  "vat": "string",
  "coop_agreement": "string",
  "voluntary_contribution": 0,
  "nationality": "string",
  "payment_type": "string"
}
```

#### Create a CRMLead

```json
{
  "iban": "string",
  "subscription_request_id": 0,
  "partner_id": 0,
  "lead_line_ids": [
    {
      "product_code": "string",
      "broadband_isp_info": {
        "phone_number": "string",
        "type": "string",
        "delivery_address": {
          "street": "string",
          "street2": "string",
          "zip_code": "string",
          "city": "string",
          "country": "string",
          "state": "string"
        },
        "previous_provider": 0,
        "previous_owner_vat_number": "string",
        "previous_owner_name": "string",
        "previous_owner_first_name": "string",
        "service_address": {
          "street": "string",
          "street2": "string",
          "zip_code": "string",
          "city": "string",
          "country": "string",
          "state": "string"
        },
        "previous_service": "string",
        "keep_phone_number": true,
        "change_address": true
      },
      "mobile_isp_info": {
        "phone_number": "string",
        "type": "string",
        "delivery_address": {
          "street": "string",
          "street2": "string",
          "zip_code": "string",
          "city": "string",
          "country": "string",
          "state": "string"
        },
        "previous_provider": 0,
        "previous_owner_vat_number": "string",
        "previous_owner_name": "string",
        "previous_owner_first_name": "string",
        "icc": "string",
        "icc_donor": "string",
        "previous_contract_type": "string"
      }
    }
  ]
}
```

## Development

### Setup environment

1. Install `pyenv`
```sh
curl https://pyenv.run | bash
```
2. Build the Python version
```sh
pyenv install  3.8.13
```
3. Create a virtualenv
```sh
pyenv virtualenv 3.8.13 odoo-somconnexio-python-client
```
4. Install dependencies
```sh
pyenv exec pip install -r requirements-dev.txt
```
5. Install pre-commit hooks
```sh
pyenv exec pre-commit install
```

### Test the HTTP request

We are using the HTTP recording plugin of Pytest: [pytest-recording](https://pytest-vcr.readthedocs.io/).

With VRC we can catch the HTTP responses and then, execute the tests using them.

To add a new test:

* Expose the needed envvars. Look for them at the [Configuration Environment section](#configuration-environment)
* Execute the tests using `pytest` command:
* If you are writing a new test that is making requests, you should run:

```
$ pytest --record-mode=once path/to/your/test
```

* You might need to record requests for an specific tests. In that case make sure to only run the tests affected and run

```
$ pytest --record-mode=rewrite path/to/your/test
```

* Add the new `cassetes` to the commit and push them.
* The CI uses the cassetes to emulate the HTTP response in the test.

### Run test suite

```commandline
$ tox
```
### Formatting

We use [Black](https://github.com/psf/black) as formatter.
First to commit, tun the `black` command:

```commandline
$ black .
All done! ✨ 🍰 ✨
29 files left unchanged.
```

### Release process

Update CHANGELOG.md following this steps:

1. Add any entries missing from merged merge requests.
1. Duplicate the `[Unreleased]` header.
1. Replace the second `Unreleased` with a version number followed by the current date. Copy the exact format from previous releases.

Then, you can release and publish the package to PyPi:

1. Update the `__version__` var in `__init__.py` matching the version you specified in the CHANGELOG.
1. Open a merge request with these changes for the team to approve
1. Merge it, add a git tag on that merge commit and push it.
1. Once the pipeline has successfully passed, go approve the `publish` step.



            

Raw data

            {
    "_id": null,
    "home_page": "https://gitlab.com/coopdevs/odoo-somconnexio-python-client",
    "name": "odoo-somconnexio-python-client",
    "maintainer": "Daniel Palomar",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "",
    "author": "Coopdevs",
    "author_email": "info@coopdevs.org",
    "download_url": "https://files.pythonhosted.org/packages/3f/42/5700f1e0ce31e803c3466cb85fcdbdea9903068c16f971e2959ba00cc6d6/odoo-somconnexio-python-client-0.1.37.tar.gz",
    "platform": null,
    "description": "[![pipeline status](https://gitlab.com/coopdevs/odoo-somconnexio-python-client/badges/master/pipeline.svg)](https://gitlab.com/coopdevs/odoo-somconnexio-python-client/commits/master)\n[![coverage report](https://gitlab.com/coopdevs/odoo-somconnexio-python-client/badges/master/coverage.svg)](https://gitlab.com/coopdevs/odoo-somconnexio-python-client/commits/master)\n\n:warning: WORK IN PROGRESS :warning:\n\nThis library is a Python wrapper for accessing Somconnexio's Odoo (Odoo v12 with customizations).\nMore info about the customizations in [SomConnexio Odoo module](https://gitlab.com/coopdevs/odoo-somconnexio).\n\n## Resources\n\n* SubscriptionRequest - Customer order\n* CRMLead - Service order\n* Provider - Service providers\n* DiscoveryChannel\n* Partner - Customer information\n* Contract - Contract information\n\n## Installation\n\n```commandline\n$ pip install odoo-somconnexio-python-client\n```\n\n## Configuration Environment\n\nYou need define the Odoo API-KEY and URL as environment variables. You need define:\n\n```\nODOO_BASEURL=<YOUR ODOO HOST>/api\nODOO_APIKEY=<YOUR ODOO API KEY>\n```\n\nIf this envvars are not defined, a exception will be raised with the name of the envvar not defined.\nMore info about the API-KEY in [Auth API Key](https://github.com/OCA/server-auth/tree/12.0/auth_api_key) Odoo module.\n\n## Usage\n\n#### Search providers by service\n\n```python\n>>> from odoo_somconnexio_python_client.resources.provider import Provider\n>>>\n>>> mobile_providers = Provider.mobile_list()\n>>> mobile_providers[0].id\n123\n>>> mobile_providers[0].name\n\"SomConnexi\u00f3\"\n```\n\n#### Get Partner with ref\n\n```python\n>>> from odoo_somconnexio_python_client.resources.partner import Partner\n>>>\n>>> partner = Partner.get(1234)\n>>> partner.id\n123\n>>> partner.ref\n\"1234\"\n```\n\n#### Search Partner by VAT number\n\n```python\n>>> from odoo_somconnexio_python_client.resources.partner import Partner\n>>>\n>>> partner = Partner.search_by_vat(vat=\"XXXX\")\n>>> partner.id\n123\n>>> partner.ref\n\"1234\"\n```\n\n#### Search Contracts by partner's VAT number\n\n```python\n>>> from odoo_somconnexio_python_client.resources.contract import Contract\n>>>\n>>> contracts = Contract.search_by_customer_vat(vat=\"XXXX\")\n>>> contracts[0].id\n123\n>>> contracts[0].phone_number\n\"972445566\"\n```\n\n### Create new mapper\n\nCreate a class that exposes a dict object with the next structure:\n\n#### Create a SubscriptionRequest\n\n```json\n{\n  \"name\": \"string\",\n  \"email\": \"string\",\n  \"ordered_parts\": 0,\n  \"share_product\": 0,\n  \"address\": {\n    \"street\": \"string\",\n    \"street2\": \"string\",\n    \"zip_code\": \"string\",\n    \"city\": \"string\",\n    \"country\": \"string\",\n    \"state\": \"string\"\n  },\n  \"lang\": \"string\",\n  \"iban\": \"string\",\n  \"vat\": \"string\",\n  \"coop_agreement\": \"string\",\n  \"voluntary_contribution\": 0,\n  \"nationality\": \"string\",\n  \"payment_type\": \"string\"\n}\n```\n\n#### Create a CRMLead\n\n```json\n{\n  \"iban\": \"string\",\n  \"subscription_request_id\": 0,\n  \"partner_id\": 0,\n  \"lead_line_ids\": [\n    {\n      \"product_code\": \"string\",\n      \"broadband_isp_info\": {\n        \"phone_number\": \"string\",\n        \"type\": \"string\",\n        \"delivery_address\": {\n          \"street\": \"string\",\n          \"street2\": \"string\",\n          \"zip_code\": \"string\",\n          \"city\": \"string\",\n          \"country\": \"string\",\n          \"state\": \"string\"\n        },\n        \"previous_provider\": 0,\n        \"previous_owner_vat_number\": \"string\",\n        \"previous_owner_name\": \"string\",\n        \"previous_owner_first_name\": \"string\",\n        \"service_address\": {\n          \"street\": \"string\",\n          \"street2\": \"string\",\n          \"zip_code\": \"string\",\n          \"city\": \"string\",\n          \"country\": \"string\",\n          \"state\": \"string\"\n        },\n        \"previous_service\": \"string\",\n        \"keep_phone_number\": true,\n        \"change_address\": true\n      },\n      \"mobile_isp_info\": {\n        \"phone_number\": \"string\",\n        \"type\": \"string\",\n        \"delivery_address\": {\n          \"street\": \"string\",\n          \"street2\": \"string\",\n          \"zip_code\": \"string\",\n          \"city\": \"string\",\n          \"country\": \"string\",\n          \"state\": \"string\"\n        },\n        \"previous_provider\": 0,\n        \"previous_owner_vat_number\": \"string\",\n        \"previous_owner_name\": \"string\",\n        \"previous_owner_first_name\": \"string\",\n        \"icc\": \"string\",\n        \"icc_donor\": \"string\",\n        \"previous_contract_type\": \"string\"\n      }\n    }\n  ]\n}\n```\n\n## Development\n\n### Setup environment\n\n1. Install `pyenv`\n```sh\ncurl https://pyenv.run | bash\n```\n2. Build the Python version\n```sh\npyenv install  3.8.13\n```\n3. Create a virtualenv\n```sh\npyenv virtualenv 3.8.13 odoo-somconnexio-python-client\n```\n4. Install dependencies\n```sh\npyenv exec pip install -r requirements-dev.txt\n```\n5. Install pre-commit hooks\n```sh\npyenv exec pre-commit install\n```\n\n### Test the HTTP request\n\nWe are using the HTTP recording plugin of Pytest: [pytest-recording](https://pytest-vcr.readthedocs.io/).\n\nWith VRC we can catch the HTTP responses and then, execute the tests using them.\n\nTo add a new test:\n\n* Expose the needed envvars. Look for them at the [Configuration Environment section](#configuration-environment)\n* Execute the tests using `pytest` command:\n* If you are writing a new test that is making requests, you should run:\n\n```\n$ pytest --record-mode=once path/to/your/test\n```\n\n* You might need to record requests for an specific tests. In that case make sure to only run the tests affected and run\n\n```\n$ pytest --record-mode=rewrite path/to/your/test\n```\n\n* Add the new `cassetes` to the commit and push them.\n* The CI uses the cassetes to emulate the HTTP response in the test.\n\n### Run test suite\n\n```commandline\n$ tox\n```\n### Formatting\n\nWe use [Black](https://github.com/psf/black) as formatter.\nFirst to commit, tun the `black` command:\n\n```commandline\n$ black .\nAll done! \u2728 \ud83c\udf70 \u2728\n29 files left unchanged.\n```\n\n### Release process\n\nUpdate CHANGELOG.md following this steps:\n\n1. Add any entries missing from merged merge requests.\n1. Duplicate the `[Unreleased]` header.\n1. Replace the second `Unreleased` with a version number followed by the current date. Copy the exact format from previous releases.\n\nThen, you can release and publish the package to PyPi:\n\n1. Update the `__version__` var in `__init__.py` matching the version you specified in the CHANGELOG.\n1. Open a merge request with these changes for the team to approve\n1. Merge it, add a git tag on that merge commit and push it.\n1. Once the pipeline has successfully passed, go approve the `publish` step.\n\n\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "Python wrapper for SomConnexio's Odoo (using REST API)",
    "version": "0.1.37",
    "project_urls": {
        "Homepage": "https://gitlab.com/coopdevs/odoo-somconnexio-python-client"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "f5302f93b606bda6b04e2ddf22962f33127c0d28459d313601a345897ecfd103",
                "md5": "59236388f62c7584afd748b2213fff5f",
                "sha256": "abb4f5c4c939ca5e46218bdda60a6da9a726d02e1b6e13a2271f607c615c1e92"
            },
            "downloads": -1,
            "filename": "odoo_somconnexio_python_client-0.1.37-py2.py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "59236388f62c7584afd748b2213fff5f",
            "packagetype": "bdist_wheel",
            "python_version": "py2.py3",
            "requires_python": null,
            "size": 37696,
            "upload_time": "2023-07-27T08:06:40",
            "upload_time_iso_8601": "2023-07-27T08:06:40.353472Z",
            "url": "https://files.pythonhosted.org/packages/f5/30/2f93b606bda6b04e2ddf22962f33127c0d28459d313601a345897ecfd103/odoo_somconnexio_python_client-0.1.37-py2.py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "3f425700f1e0ce31e803c3466cb85fcdbdea9903068c16f971e2959ba00cc6d6",
                "md5": "9b5fd918e37c626e5932634f442c8002",
                "sha256": "f75f8ee1d548658bbb39c11f26f73a29627eebe658d3c00607ee341de38e0abd"
            },
            "downloads": -1,
            "filename": "odoo-somconnexio-python-client-0.1.37.tar.gz",
            "has_sig": false,
            "md5_digest": "9b5fd918e37c626e5932634f442c8002",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 29484,
            "upload_time": "2023-07-27T08:06:41",
            "upload_time_iso_8601": "2023-07-27T08:06:41.600888Z",
            "url": "https://files.pythonhosted.org/packages/3f/42/5700f1e0ce31e803c3466cb85fcdbdea9903068c16f971e2959ba00cc6d6/odoo-somconnexio-python-client-0.1.37.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-07-27 08:06:41",
    "github": false,
    "gitlab": true,
    "bitbucket": false,
    "codeberg": false,
    "gitlab_user": "coopdevs",
    "gitlab_project": "odoo-somconnexio-python-client",
    "lcname": "odoo-somconnexio-python-client"
}
        
Elapsed time: 0.12450s