mirror of
https://github.com/bringout/oca-ocb-technical.git
synced 2026-04-19 17:11:59 +02:00
Initial commit: Technical packages
This commit is contained in:
commit
3473fa71a0
873 changed files with 297766 additions and 0 deletions
39
odoo-bringout-oca-ocb-iap/iap/models/iap_enrich_api.py
Normal file
39
odoo-bringout-oca-ocb-iap/iap/models/iap_enrich_api.py
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from odoo import models, api
|
||||
from odoo.addons.iap.tools import iap_tools
|
||||
|
||||
|
||||
class IapEnrichAPI(models.AbstractModel):
|
||||
_name = 'iap.enrich.api'
|
||||
_description = 'IAP Lead Enrichment API'
|
||||
_DEFAULT_ENDPOINT = 'https://iap-services.odoo.com'
|
||||
|
||||
@api.model
|
||||
def _contact_iap(self, local_endpoint, params):
|
||||
account = self.env['iap.account'].get('reveal')
|
||||
dbuuid = self.env['ir.config_parameter'].sudo().get_param('database.uuid')
|
||||
params['account_token'] = account.account_token
|
||||
params['dbuuid'] = dbuuid
|
||||
base_url = self.env['ir.config_parameter'].sudo().get_param('enrich.endpoint', self._DEFAULT_ENDPOINT)
|
||||
return iap_tools.iap_jsonrpc(base_url + local_endpoint, params=params, timeout=300)
|
||||
|
||||
@api.model
|
||||
def _request_enrich(self, lead_emails):
|
||||
""" Contact endpoint to get enrichment data.
|
||||
|
||||
:param lead_emails: dict{lead_id: email}
|
||||
:return: dict{lead_id: company data or False}
|
||||
:raise: several errors, notably
|
||||
* InsufficientCreditError: {
|
||||
"credit": 4.0,
|
||||
"service_name": "reveal",
|
||||
"base_url": "https://iap.odoo.com/iap/1/credit",
|
||||
"message": "You don't have enough credits on your account to use this service."
|
||||
}
|
||||
"""
|
||||
params = {
|
||||
'domains': lead_emails,
|
||||
}
|
||||
return self._contact_iap('/iap/clearbit/1/lead_enrichment_email', params=params)
|
||||
Loading…
Add table
Add a link
Reference in a new issue