Example #1
0
	def releaseReservation(self,endUserId,transactionId,referenceCode,referenceSequence):
		"""
		releaseReservation : release the reservation
		Parameters:
		endUserId : is end user ID; either MSISDN including the 'tel:' protocol identifier. OneAPI also supports the Anonymous Customer Reference (ACR) if provided by the operator.
		transactionId : uniquely identifies the reservation transaction - used in maintaining the sequence of transactions
		referenceCode : (string, unique per charge event) is your reference for reconciliation purposes. The operator should include it in reports so that you can match their view of what has been sold with yours by matching the referenceCodes.
		referenceSequence : (integer) - this allows the server to distinguish easily between new and repeated requests in the case of a communication failure. For each transaction within a reservation sequence, iterate the referenceSequence by 1
		"""
		baseurl=self.endpoints.getAmountReservationReleaseEndpoint()
		requestProcessor=JSONRequest()
		formparameters=FormParameters()
		formparameters.put('endUserId',endUserId)
		if '{endUserId}' in baseurl: baseurl=baseurl.replace('{endUserId}',str(endUserId))
		formparameters.put('transactionId',transactionId)
		if '{transactionId}' in baseurl: baseurl=baseurl.replace('{transactionId}',str(transactionId))
		formparameters.put('referenceCode',referenceCode)
		formparameters.put('referenceSequence',referenceSequence)
		postdata=formparameters.encodeParameters()
		rawresponse=requestProcessor.post(baseurl,postdata,'application/json', self.username, self.password)
		response=AmountReservationResponse()
		if rawresponse is not None and rawresponse.getContent() is not None:
			jsondata=json.loads(rawresponse.getContent())
			if jsondata is not None and jsondata['amountReservationTransaction'] is not None:
				response.setAmountReservationTransactionJSON(jsondata['amountReservationTransaction'])
		if rawresponse.getCode() is not None: response.setHTTPResponseCode(rawresponse.getCode())
		if rawresponse.getLocation() is not None: response.setLocation(rawresponse.getLocation())
		if rawresponse.getContentType() is not None: response.setContentType(rawresponse.getContentType())
		return response
Example #2
0
	def subscribeToDeliveryNotifications(self,senderAddress,clientCorrelator,notifyURL,callbackData):
		"""
		subscribeToDeliveryNotifications : subscribe to SMS delivery notifications
		Parameters:
		senderAddress : MSISDN or allocated code of the sender
		clientCorrelator : string) uniquely identifies this create subscription request. If there is a communication failure during the request, using the same clientCorrelator when retrying the request allows the operator to avoid creating a duplicate subscription.
		notifyURL : (URL) This will be used by the server to POST the notifications to you, so include the URL of your own listener application.
		callbackData : (string) is a function name or other data that you would like included when the POST is received.
		"""
		baseurl=self.endpoints.getSMSDeliverySubscriptionsEndpoint()
		requestProcessor=JSONRequest()
		formparameters=FormParameters()
		formparameters.put('senderAddress',senderAddress)
		if '{senderAddress}' in baseurl: baseurl=baseurl.replace('{senderAddress}',str(senderAddress))
		formparameters.put('clientCorrelator',clientCorrelator)
		formparameters.put('notifyURL',notifyURL)
		formparameters.put('callbackData',callbackData)
		postdata=formparameters.encodeParameters()
		rawresponse=requestProcessor.post(baseurl,postdata,'application/json', self.username, self.password)
		response=SMSDeliveryReceiptSubscriptionResponse()
		if rawresponse is not None and rawresponse.getContent() is not None:
			jsondata=json.loads(rawresponse.getContent())
			if jsondata is not None and jsondata['deliveryReceiptSubscription'] is not None:
				response.setDeliveryReceiptSubscriptionJSON(jsondata['deliveryReceiptSubscription'])
		if rawresponse.getCode() is not None: response.setHTTPResponseCode(rawresponse.getCode())
		if rawresponse.getLocation() is not None: response.setLocation(rawresponse.getLocation())
		if rawresponse.getContentType() is not None: response.setContentType(rawresponse.getContentType())
		return response
Example #3
0
    def subscribeToReceiptNotifications(self, destinationAddress, notifyURL,
                                        criteria, notificationFormat,
                                        clientCorrelator, callbackData):
        """
		subscribeToReceiptNotifications : subscribe to notifications of MMS messages sent to your application
		Parameters:
		destinationAddress : the MSISDN, or code agreed with the operator, to which people may send an MMS to your application
		notifyURL : (URL) is your address to which notifications will be sent
		criteria : (string) is case-insensitve text to match against the first word of the message, ignoring any leading whitespace. This allows you to reuse a short code among various applications, each of which can register their own subscription with different criteria.
		notificationFormat : is the content type that notifications will be sent in - for OneAPI v1.0 only JSON is supported.
		clientCorrelator : (string) uniquely identifies this create subscription request. If there is a communication failure during the request, using the same clientCorrelator when retrying the request allows the operator to avoid creating a duplicate subscription.
		callbackData : (string) is a function name or other data that you would like included when the POST is received.
		"""
        baseurl = self.endpoints.getMMSReceiptSubscriptionsEndpoint()
        requestProcessor = JSONRequest()
        formparameters = FormParameters()
        formparameters.put('destinationAddress', destinationAddress)
        formparameters.put('notifyURL', notifyURL)
        formparameters.put('criteria', criteria)
        formparameters.put('notificationFormat', notificationFormat)
        formparameters.put('clientCorrelator', clientCorrelator)
        formparameters.put('callbackData', callbackData)
        postdata = formparameters.encodeParameters()
        rawresponse = requestProcessor.post(baseurl, postdata,
                                            'application/json', self.username,
                                            self.password)
        response = MMSMessageReceiptSubscriptionResponse()
        if rawresponse is not None and rawresponse.getContent() is not None:
            jsondata = json.loads(rawresponse.getContent())
            if jsondata is not None and jsondata[
                    'resourceReference'] is not None:
                response.setResourceReferenceJSON(
                    jsondata['resourceReference'])
        if rawresponse.getCode() is not None:
            response.setHTTPResponseCode(rawresponse.getCode())
        if rawresponse.getLocation() is not None:
            response.setLocation(rawresponse.getLocation())
        if rawresponse.getContentType() is not None:
            response.setContentType(rawresponse.getContentType())
        return response
Example #4
0
	def subscribeToReceiptNotifications(self,destinationAddress,notifyURL,criteria,notificationFormat,clientCorrelator,callbackData):
		"""
		subscribeToReceiptNotifications : subscribe to notifications of MMS messages sent to your application
		Parameters:
		destinationAddress : the MSISDN, or code agreed with the operator, to which people may send an MMS to your application
		notifyURL : (URL) is your address to which notifications will be sent
		criteria : (string) is case-insensitve text to match against the first word of the message, ignoring any leading whitespace. This allows you to reuse a short code among various applications, each of which can register their own subscription with different criteria.
		notificationFormat : is the content type that notifications will be sent in - for OneAPI v1.0 only JSON is supported.
		clientCorrelator : (string) uniquely identifies this create subscription request. If there is a communication failure during the request, using the same clientCorrelator when retrying the request allows the operator to avoid creating a duplicate subscription.
		callbackData : (string) is a function name or other data that you would like included when the POST is received.
		"""
		baseurl=self.endpoints.getMMSReceiptSubscriptionsEndpoint()
		requestProcessor=JSONRequest()
		formparameters=FormParameters()
		formparameters.put('destinationAddress',destinationAddress)
		formparameters.put('notifyURL',notifyURL)
		formparameters.put('criteria',criteria)
		formparameters.put('notificationFormat',notificationFormat)
		formparameters.put('clientCorrelator',clientCorrelator)
		formparameters.put('callbackData',callbackData)
		postdata=formparameters.encodeParameters()
		rawresponse=requestProcessor.post(baseurl,postdata,'application/json', self.username, self.password)
		response=MMSMessageReceiptSubscriptionResponse()
		if rawresponse is not None and rawresponse.getContent() is not None:
			jsondata=json.loads(rawresponse.getContent())
			if jsondata is not None and jsondata['resourceReference'] is not None:
				response.setResourceReferenceJSON(jsondata['resourceReference'])
		if rawresponse.getCode() is not None: response.setHTTPResponseCode(rawresponse.getCode())
		if rawresponse.getLocation() is not None: response.setLocation(rawresponse.getLocation())
		if rawresponse.getContentType() is not None: response.setContentType(rawresponse.getContentType())
		return response
Example #5
0
	def sendSMS(self,senderAddress,address,message,clientCorrelator,notifyURL,senderName,callbackData):
		"""
		sendSMS : Send an SMS from your Web application
		Parameters:
		senderAddress : MSISDN or allocated code of the sender
		address : MSISDN or ACR of the mobile terminal to send to
		message : text part of the message to send to the recipient(s) - long messages may be split by the OneAPI server
		clientCorrelator : (string) uniquely identifies this create SMS request. If there is a communication failure during the request, using the same clientCorrelator when retrying the request allows the operator to avoid sending the same SMS twice.
		notifyURL : (anyURI) is the URL-escaped URL to which you would like a notification of delivery sent.
		senderName : (string) is the URL-escaped name of the sender to appear on the terminal is the address to  whom a responding SMS may be sent
		callbackData : (string) will be passed back in this notification, so you can use it to identify the message the receipt relates to (or any other useful data, such as a function name)
		"""
		baseurl=self.endpoints.getSendSMSEndpoint()
		requestProcessor=JSONRequest()
		formparameters=FormParameters()
		formparameters.put('senderAddress',senderAddress)
		if '{senderAddress}' in baseurl: baseurl=baseurl.replace('{senderAddress}',str(senderAddress))
		if address is not None:
			for item in address:
				formparameters.put('address',item)
		formparameters.put('message',message)
		formparameters.put('clientCorrelator',clientCorrelator)
		formparameters.put('notifyURL',notifyURL)
		formparameters.put('senderName',senderName)
		formparameters.put('callbackData',callbackData)
		postdata=formparameters.encodeParameters()
		rawresponse=requestProcessor.post(baseurl,postdata,'application/json', self.username, self.password)
		response=SendSMSResponse()
		if rawresponse is not None and rawresponse.getContent() is not None:
			jsondata=json.loads(rawresponse.getContent())
			if jsondata is not None and jsondata['resourceReference'] is not None:
				response.setResourceReferenceJSON(jsondata['resourceReference'])
		if rawresponse.getCode() is not None: response.setHTTPResponseCode(rawresponse.getCode())
		if rawresponse.getLocation() is not None: response.setLocation(rawresponse.getLocation())
		if rawresponse.getContentType() is not None: response.setContentType(rawresponse.getContentType())
		return response
Example #6
0
    def chargeWithCallback(self, endUserId, referenceCode, description,
                           currency, amount, code, callbackURL,
                           clientCorrelator, onBehalfOf, purchaseCategoryCode,
                           channel, taxAmount, serviceId, productId):
        """
		chargeWithCallback : charge an amount to the end user's bill. Note all parameters are URL encoded by the API functions so this is not needed by the application
		Parameters:
		endUserId : is end user ID; either MSISDN including the 'tel:' protocol identifier. OneAPI also supports the Anonymous Customer Reference (ACR) if provided by the operator.
		referenceCode : (string, unique per charge event) is your reference for reconciliation purposes. The operator should include it in reports so that you can match their view of what has been sold with yours by matching the referenceCodes.
		description : is the human-readable text to appear on the bill, so the user can easily see what they bought
		currency : is the 3-figure code as per ISO 4217
		amount : (decimal) can be a whole number or decimal
		code : (string) a code provided by the OneAPI implementation that is used to reference an operator price point.
		callbackURL : specifies a URL which will receive a notification when the charge request has completed (as part of an Oauth based flow)
		clientCorrelator : (string) uniquely identifies this create charge request. If there is a communication failure during the charge request, using the same clientCorrelator when retrying the request allows the operator to avoid applying the same charge twice.
		onBehalfOf : (string) allows aggregators/partners to specify the actual payee.
		purchaseCategoryCode : (string) an indication of the content type. Values meaningful to the billing system would be published by a OneAPI implementation.
		channel : (string) can be 'Wap', 'Web', 'SMS', depending on the source of user interaction
		taxAmount : decimal) tax already charged by the merchant.
		serviceId : (string) The ID of the partner/merchant service
		productId : (string) combines with the serviceID to uniquely identify the product being purchased.
		"""
        baseurl = self.endpoints.getAmountChargeEndpoint()
        requestProcessor = JSONRequest()
        formparameters = FormParameters()
        formparameters.put('endUserId', endUserId)
        if '{endUserId}' in baseurl:
            baseurl = baseurl.replace('{endUserId}', str(endUserId))
        formparameters.put('referenceCode', referenceCode)
        formparameters.put('description', description)
        formparameters.put('currency', currency)
        formparameters.put('amount', amount)
        formparameters.put('code', code)
        formparameters.put('callbackURL', callbackURL)
        formparameters.put('clientCorrelator', clientCorrelator)
        formparameters.put('onBehalfOf', onBehalfOf)
        formparameters.put('purchaseCategoryCode', purchaseCategoryCode)
        formparameters.put('channel', channel)
        formparameters.put('taxAmount', taxAmount)
        formparameters.put('serviceId', serviceId)
        formparameters.put('productId', productId)
        postdata = formparameters.encodeParameters()
        rawresponse = requestProcessor.post(baseurl, postdata,
                                            'application/json', self.username,
                                            self.password)
        response = AmountResponse()
        if rawresponse is not None and rawresponse.getContent() is not None:
            jsondata = json.loads(rawresponse.getContent())
            if jsondata is not None and jsondata[
                    'amountTransaction'] is not None:
                response.setAmountTransactionJSON(
                    jsondata['amountTransaction'])
        if rawresponse.getCode() is not None:
            response.setHTTPResponseCode(rawresponse.getCode())
        if rawresponse.getLocation() is not None:
            response.setLocation(rawresponse.getLocation())
        if rawresponse.getContentType() is not None:
            response.setContentType(rawresponse.getContentType())
        return response
Example #7
0
    def releaseReservation(self, endUserId, transactionId, referenceCode,
                           referenceSequence):
        """
		releaseReservation : release the reservation
		Parameters:
		endUserId : is end user ID; either MSISDN including the 'tel:' protocol identifier. OneAPI also supports the Anonymous Customer Reference (ACR) if provided by the operator.
		transactionId : uniquely identifies the reservation transaction - used in maintaining the sequence of transactions
		referenceCode : (string, unique per charge event) is your reference for reconciliation purposes. The operator should include it in reports so that you can match their view of what has been sold with yours by matching the referenceCodes.
		referenceSequence : (integer) - this allows the server to distinguish easily between new and repeated requests in the case of a communication failure. For each transaction within a reservation sequence, iterate the referenceSequence by 1
		"""
        baseurl = self.endpoints.getAmountReservationReleaseEndpoint()
        requestProcessor = JSONRequest()
        formparameters = FormParameters()
        formparameters.put('endUserId', endUserId)
        if '{endUserId}' in baseurl:
            baseurl = baseurl.replace('{endUserId}', str(endUserId))
        formparameters.put('transactionId', transactionId)
        if '{transactionId}' in baseurl:
            baseurl = baseurl.replace('{transactionId}', str(transactionId))
        formparameters.put('referenceCode', referenceCode)
        formparameters.put('referenceSequence', referenceSequence)
        postdata = formparameters.encodeParameters()
        rawresponse = requestProcessor.post(baseurl, postdata,
                                            'application/json', self.username,
                                            self.password)
        response = AmountReservationResponse()
        if rawresponse is not None and rawresponse.getContent() is not None:
            jsondata = json.loads(rawresponse.getContent())
            if jsondata is not None and jsondata[
                    'amountReservationTransaction'] is not None:
                response.setAmountReservationTransactionJSON(
                    jsondata['amountReservationTransaction'])
        if rawresponse.getCode() is not None:
            response.setHTTPResponseCode(rawresponse.getCode())
        if rawresponse.getLocation() is not None:
            response.setLocation(rawresponse.getLocation())
        if rawresponse.getContentType() is not None:
            response.setContentType(rawresponse.getContentType())
        return response
Example #8
0
    def reserveAdditionalAmountSimple(self, endUserId, transactionId,
                                      referenceCode, description, currency,
                                      amount, referenceSequence, code):
        """
		reserveAdditionalAmountSimple : reserve an additional amount
		Parameters:
		endUserId : is end user ID; either MSISDN including the 'tel:' protocol identifier. OneAPI also supports the Anonymous Customer Reference (ACR) if provided by the operator.
		transactionId : uniquely identifies the reservation transaction - used in maintaining the sequence of transactions
		referenceCode : (string, unique per charge event) is your reference for reconciliation purposes. The operator should include it in reports so that you can match their view of what has been sold with yours by matching the referenceCodes.
		description : is the human-readable text to appear on the bill, so the user can easily see what they bought
		currency : is the 3-figure code as per ISO 4217
		amount : (decimal) can be a whole number or decimal
		referenceSequence : (integer) - this allows the server to distinguish easily between new and repeated requests in the case of a communication failure. For each transaction within a reservation sequence, iterate the referenceSequence by 1
		code : (string) a code provided by the OneAPI implementation that is used to reference an operator price point.
		"""
        baseurl = self.endpoints.getAmountReserveAdditionalEndpoint()
        requestProcessor = JSONRequest()
        formparameters = FormParameters()
        formparameters.put('endUserId', endUserId)
        if '{endUserId}' in baseurl:
            baseurl = baseurl.replace('{endUserId}', str(endUserId))
        formparameters.put('transactionId', transactionId)
        if '{transactionId}' in baseurl:
            baseurl = baseurl.replace('{transactionId}', str(transactionId))
        formparameters.put('referenceCode', referenceCode)
        formparameters.put('description', description)
        formparameters.put('currency', currency)
        formparameters.put('amount', amount)
        formparameters.put('referenceSequence', referenceSequence)
        formparameters.put('code', code)
        postdata = formparameters.encodeParameters()
        rawresponse = requestProcessor.post(baseurl, postdata,
                                            'application/json', self.username,
                                            self.password)
        response = AmountReservationResponse()
        if rawresponse is not None and rawresponse.getContent() is not None:
            jsondata = json.loads(rawresponse.getContent())
            if jsondata is not None and jsondata[
                    'amountReservationTransaction'] is not None:
                response.setAmountReservationTransactionJSON(
                    jsondata['amountReservationTransaction'])
        if rawresponse.getCode() is not None:
            response.setHTTPResponseCode(rawresponse.getCode())
        if rawresponse.getLocation() is not None:
            response.setLocation(rawresponse.getLocation())
        if rawresponse.getContentType() is not None:
            response.setContentType(rawresponse.getContentType())
        return response
Example #9
0
	def chargeWithCallback(self,endUserId,referenceCode,description,currency,amount,code,callbackURL,clientCorrelator,onBehalfOf,purchaseCategoryCode,channel,taxAmount,serviceId,productId):
		"""
		chargeWithCallback : charge an amount to the end user's bill. Note all parameters are URL encoded by the API functions so this is not needed by the application
		Parameters:
		endUserId : is end user ID; either MSISDN including the 'tel:' protocol identifier. OneAPI also supports the Anonymous Customer Reference (ACR) if provided by the operator.
		referenceCode : (string, unique per charge event) is your reference for reconciliation purposes. The operator should include it in reports so that you can match their view of what has been sold with yours by matching the referenceCodes.
		description : is the human-readable text to appear on the bill, so the user can easily see what they bought
		currency : is the 3-figure code as per ISO 4217
		amount : (decimal) can be a whole number or decimal
		code : (string) a code provided by the OneAPI implementation that is used to reference an operator price point.
		callbackURL : specifies a URL which will receive a notification when the charge request has completed (as part of an Oauth based flow)
		clientCorrelator : (string) uniquely identifies this create charge request. If there is a communication failure during the charge request, using the same clientCorrelator when retrying the request allows the operator to avoid applying the same charge twice.
		onBehalfOf : (string) allows aggregators/partners to specify the actual payee.
		purchaseCategoryCode : (string) an indication of the content type. Values meaningful to the billing system would be published by a OneAPI implementation.
		channel : (string) can be 'Wap', 'Web', 'SMS', depending on the source of user interaction
		taxAmount : decimal) tax already charged by the merchant.
		serviceId : (string) The ID of the partner/merchant service
		productId : (string) combines with the serviceID to uniquely identify the product being purchased.
		"""
		baseurl=self.endpoints.getAmountChargeEndpoint()
		requestProcessor=JSONRequest()
		formparameters=FormParameters()
		formparameters.put('endUserId',endUserId)
		if '{endUserId}' in baseurl: baseurl=baseurl.replace('{endUserId}',str(endUserId))
		formparameters.put('referenceCode',referenceCode)
		formparameters.put('description',description)
		formparameters.put('currency',currency)
		formparameters.put('amount',amount)
		formparameters.put('code',code)
		formparameters.put('callbackURL',callbackURL)
		formparameters.put('clientCorrelator',clientCorrelator)
		formparameters.put('onBehalfOf',onBehalfOf)
		formparameters.put('purchaseCategoryCode',purchaseCategoryCode)
		formparameters.put('channel',channel)
		formparameters.put('taxAmount',taxAmount)
		formparameters.put('serviceId',serviceId)
		formparameters.put('productId',productId)
		postdata=formparameters.encodeParameters()
		rawresponse=requestProcessor.post(baseurl,postdata,'application/json', self.username, self.password)
		response=AmountResponse()
		if rawresponse is not None and rawresponse.getContent() is not None:
			jsondata=json.loads(rawresponse.getContent())
			if jsondata is not None and jsondata['amountTransaction'] is not None:
				response.setAmountTransactionJSON(jsondata['amountTransaction'])
		if rawresponse.getCode() is not None: response.setHTTPResponseCode(rawresponse.getCode())
		if rawresponse.getLocation() is not None: response.setLocation(rawresponse.getLocation())
		if rawresponse.getContentType() is not None: response.setContentType(rawresponse.getContentType())
		return response
Example #10
0
	def sendMMS(self,senderAddress,address,message,attachments,clientCorrelator,notifyURL,senderName,callbackData):
		"""
		sendMMS : Send an SMS from your Web application
		Parameters:
		senderAddress : MSISDN or allocated code of the sender
		address : MSISDN or ACR of the mobile terminal to send to
		message : text part of the message to send to the recipient(s)
		attachments : file attachments (see the Attachments class) to send as part of the MMS
		clientCorrelator : (string) uniquely identifies this create MMS request. If there is a communication failure during the request, using the same clientCorrelator when retrying the request allows the operator to avoid sending the same MMS twice.
		notifyURL : (anyURI) is the URL-escaped URL to which you would like a notification of delivery sent. The format of this notification is shown below.
		senderName : (string) is the name to appear on the user's terminal as the sender of the message.
		callbackData : (string) is any meaningful data you woul like send back in the notification, for example to identify the message or pass a function name, etc.
		"""
		baseurl=self.endpoints.getSendMMSEndpoint()
		requestProcessor=JSONRequest()
		formparameters=FormParameters()
		formparameters.put('senderAddress',senderAddress)
		if '{senderAddress}' in baseurl: baseurl=baseurl.replace('{senderAddress}',str(senderAddress))
		if address is not None:
			for item in address:
				formparameters.put('address',item)
		formparameters.put('message',message)
		formparameters.put('clientCorrelator',clientCorrelator)
		formparameters.put('notifyURL',notifyURL)
		formparameters.put('senderName',senderName)
		formparameters.put('callbackData',callbackData)
		postdata=formparameters.encodeParameters()
		outer=MIMEMultipart()
		jsonpart=MIMEBase('application', 'x-www-form-urlencoded')
		jsonpart.set_payload(postdata)
		jsonpart.add_header('Content-Disposition', 'form-data; name="root-fields"')
		outer.attach(jsonpart)
		if attachments is not None:
			for item in attachments:
				if item is not None:
					attachmentName=item.getName()
					attachmentContentType=item.getContentType()
					attachmentData=item.getData()
					if attachmentData is not None:
						if attachmentContentType is not None:
							maintype, subtype = attachmentContentType.split('/', 1)
							msga = MIMEBase(maintype, subtype)
						else:
							msga = MIMEBase('application','octet-stream')
						msga.set_payload(base64.b64encode(attachmentData))
						msga.add_header('Content-Disposition', 'form-data', name='attachments', filename=attachmentName)
						msga.add_header('Content-Transfer-Encoding', 'base64')
						outer.attach(msga)
		payload=outer.as_string(False)
		boundary=outer.get_boundary()
		trimmed=re.sub('Content-Type: multipart/mixed\\; [A-Za-z0-9\\=\\"]*','',payload)
		reformatted=trimmed.replace('\r\n','\n').replace('\n','\r\n')
		rawresponse=requestProcessor.postMultipart(baseurl,reformatted,'application/json', self.username, self.password, boundary)
		response=SendMMSResponse()
		if rawresponse is not None and rawresponse.getContent() is not None:
			jsondata=json.loads(rawresponse.getContent())
			if jsondata is not None and jsondata['resourceReference'] is not None:
				response.setResourceReferenceJSON(jsondata['resourceReference'])
		if rawresponse.getCode() is not None: response.setHTTPResponseCode(rawresponse.getCode())
		if rawresponse.getLocation() is not None: response.setLocation(rawresponse.getLocation())
		if rawresponse.getContentType() is not None: response.setContentType(rawresponse.getContentType())
		return response
Example #11
0
	def subscribeToDeliveryNotifications(self,senderAddress,clientCorrelator,notifyURL,callbackData):
		"""
		subscribeToDeliveryNotifications : subscribe to MMS delivery notifications
		Parameters:
		senderAddress : MSISDN or allocated code of the sender
		clientCorrelator : (string) uniquely identifies this create subscription request. If there is a communication failure during the request, using the same clientCorrelator when retrying the request allows the operator to avoid creating a duplicate subscription.
		notifyURL : (URL) This will be used by the server to POST the notifications to you, so include the URL of your own listener application.
		callbackData : (string) is a function name or other data that you would like included when the POST is received.
		"""
		baseurl=self.endpoints.getMMSDeliverySubscriptionsEndpoint()
		requestProcessor=JSONRequest()
		formparameters=FormParameters()
		formparameters.put('senderAddress',senderAddress)
		if '{senderAddress}' in baseurl: baseurl=baseurl.replace('{senderAddress}',str(senderAddress))
		formparameters.put('clientCorrelator',clientCorrelator)
		formparameters.put('notifyURL',notifyURL)
		formparameters.put('callbackData',callbackData)
		postdata=formparameters.encodeParameters()
		rawresponse=requestProcessor.post(baseurl,postdata,'application/json', self.username, self.password)
		response=MMSDeliveryReceiptSubscriptionResponse()
		if rawresponse is not None and rawresponse.getContent() is not None:
			jsondata=json.loads(rawresponse.getContent())
			if jsondata is not None and jsondata['deliveryReceiptSubscription'] is not None:
				response.setDeliveryReceiptSubscriptionJSON(jsondata['deliveryReceiptSubscription'])
		if rawresponse.getCode() is not None: response.setHTTPResponseCode(rawresponse.getCode())
		if rawresponse.getLocation() is not None: response.setLocation(rawresponse.getLocation())
		if rawresponse.getContentType() is not None: response.setContentType(rawresponse.getContentType())
		return response
Example #12
0
	def reserveAdditionalAmountSimple(self,endUserId,transactionId,referenceCode,description,currency,amount,referenceSequence,code):
		"""
		reserveAdditionalAmountSimple : reserve an additional amount
		Parameters:
		endUserId : is end user ID; either MSISDN including the 'tel:' protocol identifier. OneAPI also supports the Anonymous Customer Reference (ACR) if provided by the operator.
		transactionId : uniquely identifies the reservation transaction - used in maintaining the sequence of transactions
		referenceCode : (string, unique per charge event) is your reference for reconciliation purposes. The operator should include it in reports so that you can match their view of what has been sold with yours by matching the referenceCodes.
		description : is the human-readable text to appear on the bill, so the user can easily see what they bought
		currency : is the 3-figure code as per ISO 4217
		amount : (decimal) can be a whole number or decimal
		referenceSequence : (integer) - this allows the server to distinguish easily between new and repeated requests in the case of a communication failure. For each transaction within a reservation sequence, iterate the referenceSequence by 1
		code : (string) a code provided by the OneAPI implementation that is used to reference an operator price point.
		"""
		baseurl=self.endpoints.getAmountReserveAdditionalEndpoint()
		requestProcessor=JSONRequest()
		formparameters=FormParameters()
		formparameters.put('endUserId',endUserId)
		if '{endUserId}' in baseurl: baseurl=baseurl.replace('{endUserId}',str(endUserId))
		formparameters.put('transactionId',transactionId)
		if '{transactionId}' in baseurl: baseurl=baseurl.replace('{transactionId}',str(transactionId))
		formparameters.put('referenceCode',referenceCode)
		formparameters.put('description',description)
		formparameters.put('currency',currency)
		formparameters.put('amount',amount)
		formparameters.put('referenceSequence',referenceSequence)
		formparameters.put('code',code)
		postdata=formparameters.encodeParameters()
		rawresponse=requestProcessor.post(baseurl,postdata,'application/json', self.username, self.password)
		response=AmountReservationResponse()
		if rawresponse is not None and rawresponse.getContent() is not None:
			jsondata=json.loads(rawresponse.getContent())
			if jsondata is not None and jsondata['amountReservationTransaction'] is not None:
				response.setAmountReservationTransactionJSON(jsondata['amountReservationTransaction'])
		if rawresponse.getCode() is not None: response.setHTTPResponseCode(rawresponse.getCode())
		if rawresponse.getLocation() is not None: response.setLocation(rawresponse.getLocation())
		if rawresponse.getContentType() is not None: response.setContentType(rawresponse.getContentType())
		return response