flectra/addons/sms/models/sms_api.py

27 lines
825 B
Python
Raw Normal View History

# -*- coding: utf-8 -*-
2018-01-16 11:34:37 +01:00
# Part of Odoo, Flectra. See LICENSE file for full copyright and licensing details.
2018-01-16 11:34:37 +01:00
from flectra import api, fields, models
from flectra.exceptions import UserError
from flectra.addons.iap.models import iap
2018-01-16 11:34:37 +01:00
DEFAULT_ENDPOINT = 'https://iap-sms.flectra.com'
class SmsApi(models.AbstractModel):
_name = 'sms.api'
@api.model
def _send_sms(self, numbers, message):
""" Send sms
"""
account = self.env['iap.account'].get('sms')
params = {
'account_token': account.account_token,
'numbers': numbers,
'message': message,
}
endpoint = self.env['ir.config_parameter'].sudo().get_param('sms.endpoint', DEFAULT_ENDPOINT)
r = iap.jsonrpc(endpoint + '/iap/message_send', params=params)
return True