data_format = "url" if args.data_format: if (args.data_format == "json"): data_format = "json" port = 7090 if args.port: port = int(args.port) header = None if 'accept' in locals(): if args.accept: header = {"accept": args.accept} # example:initialize-sms-client sms_client = oneapi.SmsClient(args.username, args.password, args.server) # ---------------------------------------------------------------------------------------------------- # example:prepare-message-without-notify-url sms = models.SMSRequest() sms.sender_address = args.sender sms.notify_url = 'http://{}:{}'.format('localhost', port) sms.callback_data = 'Any string' sms.filter_criteria = "Urgent" # ---------------------------------------------------------------------------------------------------- # example:send-message result = sms_client.subscribe_delivery_status(sms, header, data_format) # store client correlator because we can later query for the delivery status with it: resource_url = result.resource_url # ----------------------------------------------------------------------------------------------------
# -*- coding: utf-8 -*- import sys as sys import logging as logging import oneapi as oneapi import oneapi.models as models import oneapi.dummyserver as dummyserver logging.basicConfig(level=logging.DEBUG, format='%(asctime)s %(name)-12s %(levelname)-8s %(message)s') username = sys.argv[1] password = sys.argv[2] sms_client = oneapi.SmsClient(username, password); data_connection_client = oneapi.DataConnectionProfileClient(username, 'wrongpassword'); #data_connection_client.client() print 'sms_client validity is ', sms_client.is_valid() print 'data_connection_client validity is ', data_connection_client.is_valid() assert sms_client.is_valid() assert not data_connection_client.is_valid()