import json import requests class Majortel: def post_call(self): if self.debug: print("[debug] Sono entrato in Majortel.post_call") api_url = '{0}/majortel/call/'.format(self.api_url_base) token = self.token_data['access_token'] response = requests.post(api_url, headers=self.headers, params={"callerNumber": self.callerNumber, "calledNumber": self.calledNumber}) print(response) if response.status_code == 200: return True else: return None def post_ring(self): if self.debug: print("[debug] Sono entrato in Majortel.post_ring") if self.debug: print(self.calledNumbers) api_url = '{0}/majortel/ring/'.format(self.api_url_base) token = self.token_data['access_token'] for calledNumber in self.calledNumbers: response = requests.post(api_url, headers=self.headers, params={"calledNumber": calledNumber, "calledId": self.calledId, "ringTime": self.ringTime}) print(response.text) if response.status_code == 200: return True else: return None def get_contacts(self): """ url pattern: /majortel/contacts/username/{username}/password/{password}/addressbookName/{addressbookName}/ """ if self.debug: print("[debug] Sono entrato in Majortel.get_contacts" ) api_url = '{0}/majortel/contacts/'.format(self.api_url_base) api_url += 'username/'+self.username+'/' api_url += 'password/'+self.password+'/' api_url += 'addressbook/'+self.addressbookName+'/' token = self.token_data['access_token'] response = requests.get(api_url, headers=self.headers) print(response.text) def get_contacts_microsip(self): """ url pattern: /majortel/contacts/username/{username}/password/{password}/addressbookName/{addressbookName}/microsip/ """ if self.debug: print("[debug] Sono entrato in Majortel.get_contacts" ) api_url = '{0}/majortel/contacts/'.format(self.api_url_base) api_url += 'username/'+self.username+'/' api_url += 'password/'+self.password+'/' api_url += 'addressbook/'+self.addressbookName+'/' api_url += 'microsip/' token = self.token_data['access_token'] response = requests.get(api_url, headers=self.headers) print(response.text)