Metadata-Version: 2.1
Name: odoo-addon-base_external_api
Version: 17.0.1.2.1
Requires-Python: >=3.10
Requires-Dist: odoo-addon-queue_job>=17.0dev,<17.1dev
Requires-Dist: odoo>=17.0a,<17.1dev
Requires-Dist: requests
Summary: Tools to manage external api connections.
Home-page: https://github.com/sygel-technology/sy-server-backend
License: AGPL-3
Author: Sygel, Odoo Community Association (OCA)
Author-email: support@odoo-community.org
Classifier: Programming Language :: Python
Classifier: Framework :: Odoo
Classifier: Framework :: Odoo :: 17.0
Classifier: License :: OSI Approved :: GNU Affero General Public License v3
Description-Content-Type: text/x-rst

.. image:: https://odoo-community.org/readme-banner-image
   :target: https://odoo-community.org/get-involved?utm_source=readme
   :alt: Odoo Community Association

=================
Base External API
=================

.. 
   !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
   !! This file is generated by oca-gen-addon-readme !!
   !! changes will be overwritten.                   !!
   !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
   !! source digest: sha256:1c608a86dbb80a9be0f7fa3c2904b4f0016e15fe4c10d4385f16d599fe55ea76
   !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
    :target: https://odoo-community.org/page/development-status
    :alt: Beta
.. |badge2| image:: https://img.shields.io/badge/license-AGPL--3-blue.png
    :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
    :alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-sygel--technology%2Fsy--server--backend-lightgray.png?logo=github
    :target: https://github.com/sygel-technology/sy-server-backend/tree/17.0/base_external_api
    :alt: sygel-technology/sy-server-backend

|badge1| |badge2| |badge3|

This module provides tools for other modules to use the requests library
for making external API calls.

With this module, you can:

- Create an external API record and configure its URL and
  authentication_method parameters
- Log every API call
- Make asynchronous calls

**Table of contents**

.. contents::
   :local:

Usage
=====

To use this module, you need to create a new module with:

1. A data file that creates an External API Config with an external ID.
2. A python file with code that gets the External API Config and uses it
   to make an external call with the call() or queued_call() methods.

Some use cases of this module would be sending every new res partner
record to, or sending every update in the price of the products, to a
remote API.

The code of the first example would look like this:

::

   <odoo noupdate="1">

       <record id="your_external_api_external_id" model="external.api.config">
           <field name="name">Your API Name</field>
           <field name="base_url">https://www.test.com</field>
       </record>

   </odoo>

::

   class ResPartner(models.Model):

       _inherit = "res.partner"

       def create(self, vals):
           recs = super().write(vals)
           if SYNCED_FIELDS.intersection(vals):
               for rec in recs:
                   partner_json = rec.json()  # Custom function to complete
                   self.env.ref(
                       'your_module.your_external_api_external_id'
                   ).queued_call(
                       method="post",
                       url="/partner/create",
                       data=partner_json
                   )
           return res

Known issues / Roadmap
======================

- This module could be extended to add the external_api_endpoint model,
  with the purpose to store in the database the diferent urls of the
  same API we can call, and some configuration data or extra
  information.

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/sygel-technology/sy-server-backend/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
`feedback <https://github.com/sygel-technology/sy-server-backend/issues/new?body=module:%20base_external_api%0Aversion:%2017.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Credits
=======

Authors
-------

* Sygel

Contributors
------------

- `Sygel <https://www.sygel.es>`__:

  - Alberto Martínez
  - Valentin Vinagre
  - Harald Panten

Maintainers
-----------

This module is part of the `sygel-technology/sy-server-backend <https://github.com/sygel-technology/sy-server-backend/tree/17.0/base_external_api>`_ project on GitHub.

You are welcome to contribute.
