Package: beeline-portal
Beeline cloudpbx portal api wrapperInstallInstall usingpip...pip install beeline-portalUsagefrombeeline_portalimportBeelinePBXclient=BeelinePBX('<access_token>')get abonentsabonents=client.get_abonents()# return map[Abonent]find abonentabonent=client.find_abonent('<pattern>')# raise BeelinePBXException or return Abonentget abonent agent statusresult=client.get_abonent_agent_status('<pattern>')# raise BeelinePBXException or return {'status': status}set abonent agent status_=client.set_abonent_agent_status('<pattern>','status')# raise BeelinePBXException or return {}get abonent recording statusresult=client.get_abonent_recording_status('<pattern>')# raise BeelinePBXException or return {'status': status}enable abonent recording_=client.enable_abonent_recording('<pattern>')# raise BeelinePBXException or return {}stop abonent recording_=client.stop_abonent_recording('<pattern>')# raise BeelinePBXException or return {}call from abonentresult=client.call_from_abonent('<pattern>','phone number')# raise BeelinePBXException or return {'response': response}v2 call from abonentresult=client.call_from_abonent_v2('<pattern>','phone number')# raise BeelinePBXException or return {'response': response}transfer call from abonentresult=client.transfer_call_from_abonent('<pattern>','call_id','phone number')# raise BeelinePBXException or return {}transfer call from abonentresult=client.transfer_call_with_consult('<pattern>','call_id','call_id_consult')# raise BeelinePBXException or return {}add extension numberresult=client.transfer_call_with_consult('<pattern>','phone number','schedule')# raise BeelinePBXException or return {}delete extension numberresult=client.delete_extension_number('<pattern>')# raise BeelinePBXException or return {}get cfbcfb_response=client.get_cfb('<pattern>')# raise BeelinePBXException or return CfbResponseenable cfbfrombeeline_protal.modelsimportCfbcfb=Cfb('+7397999992','+7397999993')cfb_response=client.get_cfb('<pattern>',cfb)# raise BeelinePBXException or return CfbResponsestop cfbresult=client.stop_cfb('<pattern>')# raise BeelinePBXException or return {}get cfs rule listresult=client.get_cfs_rules('<pattern>')# raise BeelinePBXException or return CfsStatusResponseadd cfs rulefrombeeline_portal.modelsimportCfsRulecfs_rule=CfsRule('my rule','+7937999992','WORKING_TIME',['+7937999993'])result=client.add_cfs_rule('<pattern>',cfs_rule)# raise BeelinePBXException or return {'number': response}enable cfsresult=client.enable_cfs('<pattern>')# raise BeelinePBXException or return {}update cfs rulefrombeeline_portal.modelsimportCfsRulecfs_rule=CfsRule('my rule','+7937999992','WORKING_TIME',['+7937999993'])result=client.update_cfs_rule('<pattern>','cfs_id',cfs_rule)# raise BeelinePBXException or return {}stop cfsresult=client.stop_cfs('<pattern>')# raise BeelinePBXException or return {}delete cfs ruleresult=client.delete_cfs_rule('<pattern>','<cfs_id>')# raise BeelinePBXException or return {}get bwl listresult=client.get_bwl_list('<pattern>')# raise BeelinePBXException or return BwlStatusResponseadd bwl rulefrombeeline_portal.modelsimportBwlRulebwl_rule=BwlRule('BWL_RULE','WORKING_TIME',['+7939797772'])result=client.add_bwl_rule('<pattern>','WHITE_LIST',bwl_rule)# raise BeelinePBXException or return {'number': response}update bwl rulefrombeeline_portal.modelsimportBwlRulebwl_rule=BwlRule('BWL_RULE','WORKING_TIME',['+7939797772'])result=client.update_bwl_rule('<pattern>','<bwl_id>',bwl_rule)# raise BeelinePBXException or return {}enable bwlresult=client.enable_bwl('<pattern>','<rule_type>')# raise BeelinePBXException or return {}stop bwlresult=client.stop_bwl('<pattern>')# raise BeelinePBXException or return {}delete bwl ruleresult=client.delete_bwl_rule('<pattern>','<bwl_id>')# raise BeelinePBXException or return {}get call recordscall_records=client.get_records()#raise BeelinePBXException or return map[CallRecord]delete call recordresult=client.delete_record('<record_id>')#raise BeelinePBXException or return {}get call recordcall_record=client.get_record('<record_id>')#raise BeelinePBXException or return CallRecordget call record by extratracking idcall_record=client.get_record_by_extratracking_id('<extratracking_id>','<user_id>')#raise BeelinePBXException or return CallRecorddownload call recordbytes_record_data=client.download_record('<record_id>')#raise BeelinePBXException or return record data in bytesdownload call record by extracking idbytes_record_data=client.download_record_by_extracking_id('<extratracking_id>','<user_id>')#raise BeelinePBXException or return record data in bytesget call record linkrecord_link=client.get_record_link('<record_id>')#raise BeelinePBXException or return stringget call record link by extracking idrecord_link=client.get_record_link_by_extracking_id('<extratracking_id>','<user_id>')#raise BeelinePBXException or return stringget incoming numbersincoming_numbers=client.get_incoming_numbers()#raise BeelinePBXException or return map[Number]find incoming numberinc_number=client.find_incoming_number('<pattern>')#raise BeelinePBXException or return Numbercreate subscriptionfrombeeline_portal.modelsimportSubscriptionRequestsr=SubscriptionRequest('<pattern>',23,'BASIC_CALL','<url>')result=client.create_subscription(sr)#raise BeelinePBXException or return dictget subscriptionsubs=client.get_subscription('<subscription_id>')#raise BeelinePBXException or return Subscriptionstop subscriptionsubs=client.stop_subscrption('<subscription_id>')#raise BeelinePBXException or return {}get icr numbersicr_numbers=client.get_icr_numbers()#raise BeelinePBXException or return map[Number]enable icr for numbersresult=client.enable_icr_for_number(['+79238458793'])#raise BeelinePBXException or return map[IcrNumbersResult]stop icr for numbersresult=client.stop_icr_for_number(['+79238458793'])#raise BeelinePBXException or return map[IcrNumbersResult]get icr route rulesicr_route_rules=client.get_icr_route_rules()#raise BeelinePBXException or return map[IcrRouteRule]delete icr route rulesfrombeeline_portal.modelsimportIcrRouteRulerule=IcrRouteRule('+7923424535','201')icr_route_rules=client.delete_list_of_icr_rules([rule])#raise BeelinePBXException or return map[IcrRouteResult]add icr route rulesfrombeeline_portal.modelsimportIcrRouteRulerule=IcrRouteRule('+7923424535','201')icr_route_rules=client.add_list_of_icr_rules([rule])#raise BeelinePBXException or return map[IcrRouteResult]update icr route rulesfrombeeline_portal.modelsimportIcrRouteRulerule=IcrRouteRule('+7923424535','201')icr_route_rules=client.update_list_of_icr_rules([rule])#raise BeelinePBXException or return map[IcrRouteResult]get voice campaignscampaigns=client.get_voice_campaigns()#raise BeelinePBXException or return map[VoiceCampaign]upload voice file to campaignresult=client.upload_file_to_voice_campaign('<path to file>')# raise BeelinePBXException or return {"id": "<id>"}add question voice campaignfrombeeline_portal.modelsimportVoiceCampaignQuestion,Answer,DateAndTimeanswers=[Answer('Q1','gadget')]schedule=VoiceCampaignSchedule('Q1','H1','H4','BUSINESS_DAY')from_=DateAndTime(parse_datetime('2021-11-11'),'00:00')to_=DateAndTime(parse_datetime('2021-11-21'),'00:00')campaign=VoiceCampaignQuestion('q_campaign',answers,"<file>",['+793799992'],'+7123212432',schedule,from_,to_,)result=client.add_question_type_voice_campaign(campaign)# raise BeelinePBXException or return string numberadd message voice campaignfrombeeline_portal.modelsimportVoiceCampaignMessagecampaign=VoiceCampaignMessage.from_beeline_struct({"name":"Message campaign","audioFile":"file_id","phones":["200"],"phoneNumber":"+79379999992","schedule":{"tryQuantity":"Q1","fromHour":"H1","toHour":"H4","schedule":"BUSINESS_DAY"},"from":{"date":"2021-01-01","time":"00:00:23"},"to":{"date":"2021-01-01","time":"00:00:23"}})result=client.add_message_type_voice_campaign(campaign)# raise BeelinePBXException or return string numberupdate voice campaignfrombeeline_portal.modelsimportVoiceCampaignvc=VoiceCampaign.from_beeline_struct({"name":"MyVoiceCampaign","status":"SUSPENDED","recordId":"hhyth1231432","type":"QUESTION","answers":[{"choice":"B1","answer":"test"}],"audioFile":"<link>","phones":["93799992"],"phoneNumber":"+799999999","schedule":{"tryQuantity":"Q1","fromHour":"H0","toHour":"H4","schedule":"ALL_WEEK",},"from":{"date":"2021-01-01","time":"00:00:00"},"to":{"date":"2021-12-01","time":"23:59:59"},"abonent":{"userId":"9379992@beeline.ru","phone":"9379992","firstName":"Ivan","lastName":"Moody",},})result=client.update_voice_campaign('<campaign_id>',vc)delete voice campaignresult=client.delete_voice_campaign('<campaign_id>')# raise BeelinePBXException or return {}stop voice campaignresult=client.stop_voice_campaign('<campaign_id>')# raise BeelinePBXException or return {}start voice campaignresult=client.start_voice_campaign('<campaign_id>')# raise BeelinePBXException or return {}get voice campaign infovc_info_report=client.get_voice_campaign_info('<campaign_id>')# raise BeelinePBXException or return VoiceCampaignInfoReportget statisticfromdatetimeimportdatetime,timedeltadate_to=datetime.now()date_from=date_to-timedelta(days=2)statistic=client.get_statistic('<user_id>',date_from,date_to,0,10)# raise BeelinePBXException or return map[StatRecord]get v2 statisticfromdatetimeimportdatetime,timedeltadate_to=datetime.now()date_from=date_to-timedelta(days=2)statistic=client.get_statistic_v2('<user_id>',date_from,date_to,0,10)# raise BeelinePBXException or return map[StatRecordV2]