diff --git a/erpnext/erpnext_integrations/doctype/exotel_settings/__init__.py b/erpnext/erpnext_integrations/doctype/exotel_settings/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/erpnext/erpnext_integrations/doctype/exotel_settings/exotel_settings.js b/erpnext/erpnext_integrations/doctype/exotel_settings/exotel_settings.js new file mode 100644 index 0000000000..bfed491d4b --- /dev/null +++ b/erpnext/erpnext_integrations/doctype/exotel_settings/exotel_settings.js @@ -0,0 +1,8 @@ +// Copyright (c) 2019, Frappe Technologies Pvt. Ltd. and contributors +// For license information, please see license.txt + +frappe.ui.form.on('Exotel Settings', { + // refresh: function(frm) { + + // } +}); diff --git a/erpnext/erpnext_integrations/doctype/exotel_settings/exotel_settings.json b/erpnext/erpnext_integrations/doctype/exotel_settings/exotel_settings.json new file mode 100644 index 0000000000..72f47b53ec --- /dev/null +++ b/erpnext/erpnext_integrations/doctype/exotel_settings/exotel_settings.json @@ -0,0 +1,61 @@ +{ + "creation": "2019-05-21 07:41:53.536536", + "doctype": "DocType", + "engine": "InnoDB", + "field_order": [ + "enabled", + "section_break_2", + "account_sid", + "api_key", + "api_token" + ], + "fields": [ + { + "fieldname": "enabled", + "fieldtype": "Check", + "label": "Enabled" + }, + { + "depends_on": "enabled", + "fieldname": "section_break_2", + "fieldtype": "Section Break" + }, + { + "fieldname": "account_sid", + "fieldtype": "Data", + "label": "Account SID" + }, + { + "fieldname": "api_token", + "fieldtype": "Data", + "label": "API Token" + }, + { + "fieldname": "api_key", + "fieldtype": "Data", + "label": "API Key" + } + ], + "issingle": 1, + "modified": "2019-05-22 06:25:18.026997", + "modified_by": "Administrator", + "module": "ERPNext Integrations", + "name": "Exotel Settings", + "owner": "Administrator", + "permissions": [ + { + "create": 1, + "delete": 1, + "email": 1, + "print": 1, + "read": 1, + "role": "System Manager", + "share": 1, + "write": 1 + } + ], + "quick_entry": 1, + "sort_field": "modified", + "sort_order": "ASC", + "track_changes": 1 +} \ No newline at end of file diff --git a/erpnext/erpnext_integrations/doctype/exotel_settings/exotel_settings.py b/erpnext/erpnext_integrations/doctype/exotel_settings/exotel_settings.py new file mode 100644 index 0000000000..763bea0e07 --- /dev/null +++ b/erpnext/erpnext_integrations/doctype/exotel_settings/exotel_settings.py @@ -0,0 +1,21 @@ +# -*- coding: utf-8 -*- +# Copyright (c) 2019, Frappe Technologies Pvt. Ltd. and contributors +# For license information, please see license.txt + +from __future__ import unicode_literals +# import frappe +from frappe.model.document import Document +import requests +import frappe +from frappe import _ + +class ExotelSettings(Document): + def validate(self): + self.verify_credentials() + + def verify_credentials(self): + if self.enabled: + response = requests.get('https://api.exotel.com/v1/Accounts/{sid}' + .format(sid = self.account_sid), auth=(self.account_sid, self.api_token)) + if response.status_code != 200: + frappe.throw(_("Invalid credentials")) \ No newline at end of file diff --git a/erpnext/erpnext_integrations/doctype/exotel_settings/test_exotel_settings.py b/erpnext/erpnext_integrations/doctype/exotel_settings/test_exotel_settings.py new file mode 100644 index 0000000000..5d85615c27 --- /dev/null +++ b/erpnext/erpnext_integrations/doctype/exotel_settings/test_exotel_settings.py @@ -0,0 +1,10 @@ +# -*- coding: utf-8 -*- +# Copyright (c) 2019, Frappe Technologies Pvt. Ltd. and Contributors +# See license.txt +from __future__ import unicode_literals + +# import frappe +import unittest + +class TestExotelSettings(unittest.TestCase): + pass