oneapi 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (68) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +14 -0
  3. data/Gemfile +4 -0
  4. data/LICENSE.txt +22 -0
  5. data/README.md +37 -0
  6. data/Rakefile +2 -0
  7. data/lib/endpoints/ServiceEndpoints.rb +144 -0
  8. data/lib/foundation/FormParameter.rb +25 -0
  9. data/lib/foundation/FormParameters.rb +39 -0
  10. data/lib/foundation/JSONRequest.rb +109 -0
  11. data/lib/location/Locate.rb +100 -0
  12. data/lib/mms/MMSRetrieve.rb +198 -0
  13. data/lib/mms/MMSSend.rb +205 -0
  14. data/lib/oneapi.rb +6 -0
  15. data/lib/oneapi/version.rb +3 -0
  16. data/lib/payment/Charge.rb +166 -0
  17. data/lib/payment/Reservation.rb +295 -0
  18. data/lib/response/Attachment.rb +50 -0
  19. data/lib/response/HTTPResponse.rb +63 -0
  20. data/lib/response/PolicyException.rb +58 -0
  21. data/lib/response/RequestError.rb +41 -0
  22. data/lib/response/ResourceReference.rb +24 -0
  23. data/lib/response/ServiceException.rb +50 -0
  24. data/lib/response/location/CurrentLocation.rb +76 -0
  25. data/lib/response/location/ErrorInformation.rb +41 -0
  26. data/lib/response/location/LocationResponse.rb +49 -0
  27. data/lib/response/location/TerminalLocation.rb +67 -0
  28. data/lib/response/location/TerminalLocationList.rb +36 -0
  29. data/lib/response/mms/CallbackReference.rb +37 -0
  30. data/lib/response/mms/DeliveryInfo.rb +37 -0
  31. data/lib/response/mms/DeliveryInfoList.rb +49 -0
  32. data/lib/response/mms/DeliveryInfoNotification.rb +39 -0
  33. data/lib/response/mms/DeliveryReceiptSubscription.rb +39 -0
  34. data/lib/response/mms/HTTPResponse.rb +35 -0
  35. data/lib/response/mms/InboundMMSMessage.rb +37 -0
  36. data/lib/response/mms/InboundMessage.rb +91 -0
  37. data/lib/response/mms/InboundMessageList.rb +75 -0
  38. data/lib/response/mms/InboundMessageNotification.rb +39 -0
  39. data/lib/response/mms/MMSDeliveryReceiptSubscriptionResponse.rb +49 -0
  40. data/lib/response/mms/MMSMessageReceiptSubscriptionResponse.rb +49 -0
  41. data/lib/response/mms/MMSSendDeliveryStatusResponse.rb +49 -0
  42. data/lib/response/mms/RetrieveMMSMessageResponse.rb +57 -0
  43. data/lib/response/mms/RetrieveMMSResponse.rb +49 -0
  44. data/lib/response/mms/SendMMSResponse.rb +49 -0
  45. data/lib/response/payment/AmountReservationResponse.rb +49 -0
  46. data/lib/response/payment/AmountReservationTransaction.rb +116 -0
  47. data/lib/response/payment/AmountResponse.rb +49 -0
  48. data/lib/response/payment/AmountTransaction.rb +103 -0
  49. data/lib/response/payment/ChargingInformation.rb +50 -0
  50. data/lib/response/payment/PaymentAmount.rb +51 -0
  51. data/lib/response/sms/CallbackReference.rb +37 -0
  52. data/lib/response/sms/DeliveryInfo.rb +37 -0
  53. data/lib/response/sms/DeliveryInfoList.rb +49 -0
  54. data/lib/response/sms/DeliveryInfoNotification.rb +39 -0
  55. data/lib/response/sms/DeliveryReceiptSubscription.rb +39 -0
  56. data/lib/response/sms/HTTPResponse.rb +35 -0
  57. data/lib/response/sms/InboundSMSMessage.rb +89 -0
  58. data/lib/response/sms/InboundSMSMessageList.rb +75 -0
  59. data/lib/response/sms/InboundSMSMessageNotification.rb +39 -0
  60. data/lib/response/sms/RetrieveSMSResponse.rb +49 -0
  61. data/lib/response/sms/SMSDeliveryReceiptSubscriptionResponse.rb +49 -0
  62. data/lib/response/sms/SMSMessageReceiptSubscriptionResponse.rb +49 -0
  63. data/lib/response/sms/SMSSendDeliveryStatusResponse.rb +49 -0
  64. data/lib/response/sms/SendSMSResponse.rb +49 -0
  65. data/lib/sms/SMSRetrieve.rb +125 -0
  66. data/lib/sms/SMSSend.rb +168 -0
  67. data/oneapi.gemspec +23 -0
  68. metadata +138 -0
@@ -0,0 +1,198 @@
1
+ require "response/mms/InboundMMSMessage"
2
+ require "response/mms/InboundMessageList"
3
+ require "response/mms/RetrieveMMSResponse"
4
+ require "response/mms/InboundMessage"
5
+ require "response/mms/RetrieveMMSMessageResponse"
6
+ require "response/ResourceReference"
7
+ require "response/mms/MMSMessageReceiptSubscriptionResponse"
8
+ require "response/mms/HTTPResponse"
9
+ require 'json'
10
+ require 'uri'
11
+ require 'net/http'
12
+ require 'foundation/FormParameters'
13
+ require 'foundation/JSONRequest'
14
+ require 'Mail'
15
+ require 'response/Attachment'
16
+
17
+ class MMSRetrieve
18
+
19
+ def initialize(endpoints, username, password)
20
+ @endpoints=endpoints
21
+ @username=username
22
+ @password=password
23
+ end
24
+ def getEndpoints
25
+ @endpoints
26
+ end
27
+
28
+ def setEndpoints(endpoints)
29
+ @endpoints=endpoints
30
+ end
31
+
32
+ def getUsername
33
+ @username
34
+ end
35
+
36
+ def setUsername(username)
37
+ @username=username
38
+ end
39
+
40
+ def getPassword
41
+ @password
42
+ end
43
+
44
+ def setPassword(password)
45
+ @password=password
46
+ end
47
+
48
+
49
+ def retrieveMessages(registrationId,maxBatchSize)
50
+ baseurl=@endpoints.getRetrieveMMSEndpoint()
51
+ requestProcessor=JSONRequest.new()
52
+ if baseurl.index('{registrationId}')!=nil then
53
+ baseurl=baseurl.gsub('{registrationId}',CGI::escape(registrationId.to_s))
54
+ end
55
+ if baseurl.index('{maxBatchSize}')!=nil then
56
+ baseurl=baseurl.gsub('{maxBatchSize}',CGI::escape(maxBatchSize.to_s))
57
+ end
58
+ rawresponse=requestProcessor.get(baseurl,'application/json', @username, @password)
59
+ response=RetrieveMMSResponse.new()
60
+ if (rawresponse!=nil) && (rawresponse.getContent()!=nil)
61
+ jsondata=JSON.parse(rawresponse.getContent())
62
+ if (jsondata!=nil) && (jsondata['inboundMessageList']!=nil) then
63
+ response.setInboundMessageListJSON(jsondata['inboundMessageList'])
64
+ end
65
+ end
66
+ if rawresponse.getCode()!=nil then
67
+ response.setHTTPResponseCode(rawresponse.getCode())
68
+ end
69
+ if rawresponse.getLocation()!=nil then
70
+ response.setLocation(rawresponse.getLocation())
71
+ end
72
+ if rawresponse.getContentType()!=nil then
73
+ response.setContentType(rawresponse.getContentType())
74
+ end
75
+ return response
76
+ end
77
+
78
+ def retrieveMessageContent(registrationId,messageId,resFormat)
79
+ baseurl=@endpoints.getRetrieveMMSMessageEndpoint()
80
+ requestProcessor=JSONRequest.new()
81
+ if baseurl.index('{registrationId}')!=nil then
82
+ baseurl=baseurl.gsub('{registrationId}',CGI::escape(registrationId.to_s))
83
+ end
84
+ if baseurl.index('{messageId}')!=nil then
85
+ baseurl=baseurl.gsub('{messageId}',CGI::escape(messageId.to_s))
86
+ end
87
+ if baseurl.index('{resFormat}')!=nil then
88
+ baseurl=baseurl.gsub('{resFormat}',CGI::escape(resFormat.to_s))
89
+ end
90
+ rawresponse=requestProcessor.get(baseurl,'application/json', @username, @password)
91
+ response=RetrieveMMSMessageResponse.new()
92
+ if (rawresponse!=nil) && (rawresponse.getContent()!=nil) then
93
+ mimecontent="Content-Type: "+rawresponse.getContentType()+'\r\n\r\n'+rawresponse.getContent()
94
+ mimemsg=Mail.read_from_string(mimecontent.gsub("\\t","\t").gsub("\\n","\n").gsub("\\r","\r").gsub("\\\"","\""))
95
+ response=RetrieveMMSMessageResponse.new()
96
+ attachments=nil
97
+ for part in mimemsg.parts
98
+ contentType=part.content_type.strip
99
+ if (contentType.index(";")!=nil)
100
+ ct=contentType.split(";")
101
+ contentType=ct[0].strip
102
+ end
103
+ filename=nil
104
+ contentDisposition=part.content_disposition
105
+ if (contentDisposition!=nil)
106
+ cdp=contentDisposition.split(";")
107
+ for cvp in cdp
108
+ kv=cvp.split("=")
109
+ if kv[0].strip=="name"
110
+ filename=kv[1].gsub("\"","").strip
111
+ end
112
+ end
113
+ end
114
+ if contentType!='multipart/mixed'
115
+ payload=part.body.to_s
116
+ if (contentType!=nil) && (contentType=='application/json') && (filename!=nil) && (filename=="root-fields") && (payload!=nil)
117
+ jsondata=JSON.parse(payload)
118
+ if (jsondata!=nil) && (jsondata['inboundMessage']!=nil)
119
+ response.setInboundMessage(jsondata['inboundMessage'])
120
+ end
121
+ else
122
+ attachment=Attachment.new
123
+ attachment.setContentType(contentType)
124
+ attachment.setName(filename)
125
+ attachment.setData(payload)
126
+ if attachments==nil
127
+ attachments=Array.new
128
+ end
129
+ attachments[attachments.length]=attachment
130
+ end
131
+ end
132
+ end
133
+ response.setAttachment(attachments)
134
+ end
135
+ if rawresponse.getCode()!=nil then
136
+ response.setHTTPResponseCode(rawresponse.getCode())
137
+ end
138
+ if rawresponse.getLocation()!=nil then
139
+ response.setLocation(rawresponse.getLocation())
140
+ end
141
+ if rawresponse.getContentType()!=nil then
142
+ response.setContentType(rawresponse.getContentType())
143
+ end
144
+ return response
145
+ end
146
+
147
+ def subscribeToReceiptNotifications(destinationAddress,notifyURL,criteria,notificationFormat,clientCorrelator,callbackData)
148
+ baseurl=@endpoints.getMMSReceiptSubscriptionsEndpoint()
149
+ requestProcessor=JSONRequest.new()
150
+ formparameters=FormParameters.new()
151
+ formparameters.put('destinationAddress',destinationAddress)
152
+ formparameters.put('notifyURL',notifyURL)
153
+ formparameters.put('criteria',criteria)
154
+ formparameters.put('notificationFormat',notificationFormat)
155
+ formparameters.put('clientCorrelator',clientCorrelator)
156
+ formparameters.put('callbackData',callbackData)
157
+ postdata=formparameters.encodeParameters()
158
+ rawresponse=requestProcessor.post(baseurl,postdata,'application/json', @username, @password)
159
+ response=MMSMessageReceiptSubscriptionResponse.new()
160
+ if (rawresponse!=nil) && (rawresponse.getContent()!=nil)
161
+ jsondata=JSON.parse(rawresponse.getContent())
162
+ if (jsondata!=nil) && (jsondata['resourceReference']!=nil) then
163
+ response.setResourceReferenceJSON(jsondata['resourceReference'])
164
+ end
165
+ end
166
+ if rawresponse.getCode()!=nil then
167
+ response.setHTTPResponseCode(rawresponse.getCode())
168
+ end
169
+ if rawresponse.getLocation()!=nil then
170
+ response.setLocation(rawresponse.getLocation())
171
+ end
172
+ if rawresponse.getContentType()!=nil then
173
+ response.setContentType(rawresponse.getContentType())
174
+ end
175
+ return response
176
+ end
177
+
178
+ def cancelReceiptNotifications(subscriptionId)
179
+ baseurl=@endpoints.getCancelMMSReceiptSubscriptionEndpoint()
180
+ requestProcessor=JSONRequest.new()
181
+ if baseurl.index('{subscriptionId}')!=nil then
182
+ baseurl=baseurl.gsub('{subscriptionId}',CGI::escape(subscriptionId.to_s))
183
+ end
184
+ rawresponse=requestProcessor.delete(baseurl,@username,@password)
185
+ response=HTTPResponse.new()
186
+ if rawresponse.getCode()!=nil then
187
+ response.setHTTPResponseCode(rawresponse.getCode())
188
+ end
189
+ if rawresponse.getLocation()!=nil then
190
+ response.setLocation(rawresponse.getLocation())
191
+ end
192
+ if rawresponse.getContentType()!=nil then
193
+ response.setContentType(rawresponse.getContentType())
194
+ end
195
+ return response
196
+ end
197
+
198
+ end
@@ -0,0 +1,205 @@
1
+ require "response/ResourceReference"
2
+ require "response/mms/SendMMSResponse"
3
+ require "response/mms/DeliveryInfo"
4
+ require "response/mms/DeliveryInfoList"
5
+ require "response/mms/MMSSendDeliveryStatusResponse"
6
+ require "response/mms/CallbackReference"
7
+ require "response/mms/DeliveryReceiptSubscription"
8
+ require "response/mms/MMSDeliveryReceiptSubscriptionResponse"
9
+ require "response/mms/HTTPResponse"
10
+ require 'json'
11
+ require 'uri'
12
+ require 'net/http'
13
+ require 'foundation/FormParameters'
14
+ require 'foundation/JSONRequest'
15
+ require 'Base64'
16
+ require 'uuid'
17
+
18
+ class MMSSend
19
+
20
+ def initialize(endpoints, username, password)
21
+ @endpoints=endpoints
22
+ @username=username
23
+ @password=password
24
+ end
25
+ def getEndpoints
26
+ @endpoints
27
+ end
28
+
29
+ def setEndpoints(endpoints)
30
+ @endpoints=endpoints
31
+ end
32
+
33
+ def getUsername
34
+ @username
35
+ end
36
+
37
+ def setUsername(username)
38
+ @username=username
39
+ end
40
+
41
+ def getPassword
42
+ @password
43
+ end
44
+
45
+ def setPassword(password)
46
+ @password=password
47
+ end
48
+
49
+
50
+ def sendMMS(senderAddress,address,message,attachments,clientCorrelator,notifyURL,senderName,callbackData)
51
+ baseurl=@endpoints.getSendMMSEndpoint()
52
+ requestProcessor=JSONRequest.new()
53
+ formparameters=FormParameters.new()
54
+ formparameters.put('senderAddress',senderAddress)
55
+ if baseurl.index('{senderAddress}')!=nil then
56
+ baseurl=baseurl.gsub('{senderAddress}',CGI::escape(senderAddress.to_s))
57
+ end
58
+ if address!=nil
59
+ for item in address
60
+ formparameters.put('address',item)
61
+ end
62
+ end
63
+ formparameters.put('message',message)
64
+ formparameters.put('clientCorrelator',clientCorrelator)
65
+ formparameters.put('notifyURL',notifyURL)
66
+ formparameters.put('senderName',senderName)
67
+ formparameters.put('callbackData',callbackData)
68
+ postdata=formparameters.encodeParameters()
69
+ uuid=UUID.new
70
+ boundary=uuid.generate
71
+ msg = '\r\nMIME-Version: 1.0\r\n'
72
+ msg << '\r\n--'+boundary+'\r\n'
73
+ msg << 'Content-Disposition: form-data; name="root-fields"\r\n'
74
+ msg << 'Content-Type: application/x-www-form-urlencoded\r\n\r\n'
75
+ msg << postdata
76
+ msg << '\r\n'
77
+ if attachments!=nil then
78
+ for item in attachments
79
+ if (item!=nil) && (item.getData!=nil) then
80
+ msg << '\r\n--'+boundary+'\r\n'
81
+ attachmentName=item.getName()
82
+ if attachmentName!=nil then
83
+ msg << 'Content-Disposition: form-data; name="attachments"; filename="'+attachmentName+'"\r\n'
84
+ else
85
+ msg << 'Content-Disposition: form-data; name="attachments"\r\n'
86
+ end
87
+ msg << 'Content-Transfer-Encoding: base64\r\n'
88
+ attachmentContentType=item.getContentType()
89
+ attachmentData=item.getData()
90
+ if attachmentContentType!=nil then
91
+ msg << 'Content-Type:'+attachmentContentType+'\r\n'
92
+ else
93
+ msg << 'Content-Type: application/octet-stream\r\n'
94
+ end
95
+ msg << '\r\n'
96
+ msg << Base64.encode64(attachmentData).gsub('\n','\r\n')
97
+ msg << '\r\n'
98
+ end
99
+ end
100
+ end
101
+ msg << '\r\n--'+boundary+'--\r\n'
102
+ msg = msg.gsub("\\r", "\r")
103
+ msg = msg.gsub("\\n", "\n")
104
+ rawresponse=requestProcessor.postMultipart(baseurl,msg,'application/json', @username, @password, boundary)
105
+ response=SendMMSResponse.new()
106
+ if (rawresponse!=nil) && (rawresponse.getContent()!=nil)
107
+ jsondata=JSON.parse(rawresponse.getContent())
108
+ if (jsondata!=nil) && (jsondata['resourceReference']!=nil) then
109
+ response.setResourceReferenceJSON(jsondata['resourceReference'])
110
+ end
111
+ end
112
+ if rawresponse.getCode()!=nil then
113
+ response.setHTTPResponseCode(rawresponse.getCode())
114
+ end
115
+ if rawresponse.getLocation()!=nil then
116
+ response.setLocation(rawresponse.getLocation())
117
+ end
118
+ if rawresponse.getContentType()!=nil then
119
+ response.setContentType(rawresponse.getContentType())
120
+ end
121
+ return response
122
+ end
123
+
124
+ def queryDeliveryStatus(senderAddress,requestId)
125
+ baseurl=@endpoints.getQueryMMSDeliveryEndpoint()
126
+ requestProcessor=JSONRequest.new()
127
+ if baseurl.index('{senderAddress}')!=nil then
128
+ baseurl=baseurl.gsub('{senderAddress}',CGI::escape(senderAddress.to_s))
129
+ end
130
+ if baseurl.index('{requestId}')!=nil then
131
+ baseurl=baseurl.gsub('{requestId}',CGI::escape(requestId.to_s))
132
+ end
133
+ rawresponse=requestProcessor.get(baseurl,'application/json', @username, @password)
134
+ response=MMSSendDeliveryStatusResponse.new()
135
+ if (rawresponse!=nil) && (rawresponse.getContent()!=nil)
136
+ jsondata=JSON.parse(rawresponse.getContent())
137
+ if (jsondata!=nil) && (jsondata['deliveryInfoList']!=nil) then
138
+ response.setDeliveryInfoListJSON(jsondata['deliveryInfoList'])
139
+ end
140
+ end
141
+ if rawresponse.getCode()!=nil then
142
+ response.setHTTPResponseCode(rawresponse.getCode())
143
+ end
144
+ if rawresponse.getLocation()!=nil then
145
+ response.setLocation(rawresponse.getLocation())
146
+ end
147
+ if rawresponse.getContentType()!=nil then
148
+ response.setContentType(rawresponse.getContentType())
149
+ end
150
+ return response
151
+ end
152
+
153
+ def subscribeToDeliveryNotifications(senderAddress,clientCorrelator,notifyURL,callbackData)
154
+ baseurl=@endpoints.getMMSDeliverySubscriptionsEndpoint()
155
+ requestProcessor=JSONRequest.new()
156
+ formparameters=FormParameters.new()
157
+ formparameters.put('senderAddress',senderAddress)
158
+ if baseurl.index('{senderAddress}')!=nil then
159
+ baseurl=baseurl.gsub('{senderAddress}',CGI::escape(senderAddress.to_s))
160
+ end
161
+ formparameters.put('clientCorrelator',clientCorrelator)
162
+ formparameters.put('notifyURL',notifyURL)
163
+ formparameters.put('callbackData',callbackData)
164
+ postdata=formparameters.encodeParameters()
165
+ rawresponse=requestProcessor.post(baseurl,postdata,'application/json', @username, @password)
166
+ response=MMSDeliveryReceiptSubscriptionResponse.new()
167
+ if (rawresponse!=nil) && (rawresponse.getContent()!=nil)
168
+ jsondata=JSON.parse(rawresponse.getContent())
169
+ if (jsondata!=nil) && (jsondata['deliveryReceiptSubscription']!=nil) then
170
+ response.setDeliveryReceiptSubscriptionJSON(jsondata['deliveryReceiptSubscription'])
171
+ end
172
+ end
173
+ if rawresponse.getCode()!=nil then
174
+ response.setHTTPResponseCode(rawresponse.getCode())
175
+ end
176
+ if rawresponse.getLocation()!=nil then
177
+ response.setLocation(rawresponse.getLocation())
178
+ end
179
+ if rawresponse.getContentType()!=nil then
180
+ response.setContentType(rawresponse.getContentType())
181
+ end
182
+ return response
183
+ end
184
+
185
+ def cancelDeliveryNotifications(subscriptionId)
186
+ baseurl=@endpoints.getCancelMMSDeliverySubscriptionEndpoint()
187
+ requestProcessor=JSONRequest.new()
188
+ if baseurl.index('{subscriptionId}')!=nil then
189
+ baseurl=baseurl.gsub('{subscriptionId}',CGI::escape(subscriptionId.to_s))
190
+ end
191
+ rawresponse=requestProcessor.delete(baseurl,@username,@password)
192
+ response=HTTPResponse.new()
193
+ if rawresponse.getCode()!=nil then
194
+ response.setHTTPResponseCode(rawresponse.getCode())
195
+ end
196
+ if rawresponse.getLocation()!=nil then
197
+ response.setLocation(rawresponse.getLocation())
198
+ end
199
+ if rawresponse.getContentType()!=nil then
200
+ response.setContentType(rawresponse.getContentType())
201
+ end
202
+ return response
203
+ end
204
+
205
+ end
data/lib/oneapi.rb ADDED
@@ -0,0 +1,6 @@
1
+ require "oneapi/version"
2
+
3
+ module Oneapi
4
+ # Your code goes here...
5
+ #TODO: Move all configuration here
6
+ end
@@ -0,0 +1,3 @@
1
+ module Oneapi
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,166 @@
1
+ require "response/payment/AmountTransaction"
2
+ require "response/payment/AmountResponse"
3
+ require 'json'
4
+ require 'uri'
5
+ require 'net/http'
6
+ require 'foundation/FormParameters'
7
+ require 'foundation/JSONRequest'
8
+
9
+ class Charge
10
+
11
+ def initialize(endpoints, username, password)
12
+ @endpoints=endpoints
13
+ @username=username
14
+ @password=password
15
+ end
16
+ def getEndpoints
17
+ @endpoints
18
+ end
19
+
20
+ def setEndpoints(endpoints)
21
+ @endpoints=endpoints
22
+ end
23
+
24
+ def getUsername
25
+ @username
26
+ end
27
+
28
+ def setUsername(username)
29
+ @username=username
30
+ end
31
+
32
+ def getPassword
33
+ @password
34
+ end
35
+
36
+ def setPassword(password)
37
+ @password=password
38
+ end
39
+
40
+
41
+ def charge(endUserId,referenceCode,description,currency,amount,code,clientCorrelator,onBehalfOf,purchaseCategoryCode,channel,taxAmount,serviceId,productId)
42
+ baseurl=@endpoints.getAmountChargeEndpoint()
43
+ requestProcessor=JSONRequest.new()
44
+ formparameters=FormParameters.new()
45
+ formparameters.put('endUserId',endUserId)
46
+ if baseurl.index('{endUserId}')!=nil then
47
+ baseurl=baseurl.gsub('{endUserId}',CGI::escape(endUserId.to_s))
48
+ end
49
+ formparameters.put('referenceCode',referenceCode)
50
+ formparameters.put('description',description)
51
+ formparameters.put('currency',currency)
52
+ formparameters.put('amount',amount)
53
+ formparameters.put('code',code)
54
+ formparameters.put('clientCorrelator',clientCorrelator)
55
+ formparameters.put('onBehalfOf',onBehalfOf)
56
+ formparameters.put('purchaseCategoryCode',purchaseCategoryCode)
57
+ formparameters.put('channel',channel)
58
+ formparameters.put('taxAmount',taxAmount)
59
+ formparameters.put('serviceId',serviceId)
60
+ formparameters.put('productId',productId)
61
+ postdata=formparameters.encodeParameters()
62
+ rawresponse=requestProcessor.post(baseurl,postdata,'application/json', @username, @password)
63
+ response=AmountResponse.new()
64
+ if (rawresponse!=nil) && (rawresponse.getContent()!=nil)
65
+ jsondata=JSON.parse(rawresponse.getContent())
66
+ if (jsondata!=nil) && (jsondata['amountTransaction']!=nil) then
67
+ response.setAmountTransactionJSON(jsondata['amountTransaction'])
68
+ end
69
+ end
70
+ if rawresponse.getCode()!=nil then
71
+ response.setHTTPResponseCode(rawresponse.getCode())
72
+ end
73
+ if rawresponse.getLocation()!=nil then
74
+ response.setLocation(rawresponse.getLocation())
75
+ end
76
+ if rawresponse.getContentType()!=nil then
77
+ response.setContentType(rawresponse.getContentType())
78
+ end
79
+ return response
80
+ end
81
+
82
+ def chargeWithCallback(endUserId,referenceCode,description,currency,amount,code,callbackURL,clientCorrelator,onBehalfOf,purchaseCategoryCode,channel,taxAmount,serviceId,productId)
83
+ baseurl=@endpoints.getAmountChargeEndpoint()
84
+ requestProcessor=JSONRequest.new()
85
+ formparameters=FormParameters.new()
86
+ formparameters.put('endUserId',endUserId)
87
+ if baseurl.index('{endUserId}')!=nil then
88
+ baseurl=baseurl.gsub('{endUserId}',CGI::escape(endUserId.to_s))
89
+ end
90
+ formparameters.put('referenceCode',referenceCode)
91
+ formparameters.put('description',description)
92
+ formparameters.put('currency',currency)
93
+ formparameters.put('amount',amount)
94
+ formparameters.put('code',code)
95
+ formparameters.put('callbackURL',callbackURL)
96
+ formparameters.put('clientCorrelator',clientCorrelator)
97
+ formparameters.put('onBehalfOf',onBehalfOf)
98
+ formparameters.put('purchaseCategoryCode',purchaseCategoryCode)
99
+ formparameters.put('channel',channel)
100
+ formparameters.put('taxAmount',taxAmount)
101
+ formparameters.put('serviceId',serviceId)
102
+ formparameters.put('productId',productId)
103
+ postdata=formparameters.encodeParameters()
104
+ rawresponse=requestProcessor.post(baseurl,postdata,'application/json', @username, @password)
105
+ response=AmountResponse.new()
106
+ if (rawresponse!=nil) && (rawresponse.getContent()!=nil)
107
+ jsondata=JSON.parse(rawresponse.getContent())
108
+ if (jsondata!=nil) && (jsondata['amountTransaction']!=nil) then
109
+ response.setAmountTransactionJSON(jsondata['amountTransaction'])
110
+ end
111
+ end
112
+ if rawresponse.getCode()!=nil then
113
+ response.setHTTPResponseCode(rawresponse.getCode())
114
+ end
115
+ if rawresponse.getLocation()!=nil then
116
+ response.setLocation(rawresponse.getLocation())
117
+ end
118
+ if rawresponse.getContentType()!=nil then
119
+ response.setContentType(rawresponse.getContentType())
120
+ end
121
+ return response
122
+ end
123
+
124
+ def refund(endUserId,referenceCode,description,currency,amount,code,clientCorrelator,originalServerReferenceCode,onBehalfOf,purchaseCategoryCode,channel,taxAmount,serviceId,productId)
125
+ baseurl=@endpoints.getAmountRefundEndpoint()
126
+ requestProcessor=JSONRequest.new()
127
+ formparameters=FormParameters.new()
128
+ formparameters.put('endUserId',endUserId)
129
+ if baseurl.index('{endUserId}')!=nil then
130
+ baseurl=baseurl.gsub('{endUserId}',CGI::escape(endUserId.to_s))
131
+ end
132
+ formparameters.put('referenceCode',referenceCode)
133
+ formparameters.put('description',description)
134
+ formparameters.put('currency',currency)
135
+ formparameters.put('amount',amount)
136
+ formparameters.put('code',code)
137
+ formparameters.put('clientCorrelator',clientCorrelator)
138
+ formparameters.put('originalServerReferenceCode',originalServerReferenceCode)
139
+ formparameters.put('onBehalfOf',onBehalfOf)
140
+ formparameters.put('purchaseCategoryCode',purchaseCategoryCode)
141
+ formparameters.put('channel',channel)
142
+ formparameters.put('taxAmount',taxAmount)
143
+ formparameters.put('serviceId',serviceId)
144
+ formparameters.put('productId',productId)
145
+ postdata=formparameters.encodeParameters()
146
+ rawresponse=requestProcessor.post(baseurl,postdata,'application/json', @username, @password)
147
+ response=AmountResponse.new()
148
+ if (rawresponse!=nil) && (rawresponse.getContent()!=nil)
149
+ jsondata=JSON.parse(rawresponse.getContent())
150
+ if (jsondata!=nil) && (jsondata['amountTransaction']!=nil) then
151
+ response.setAmountTransactionJSON(jsondata['amountTransaction'])
152
+ end
153
+ end
154
+ if rawresponse.getCode()!=nil then
155
+ response.setHTTPResponseCode(rawresponse.getCode())
156
+ end
157
+ if rawresponse.getLocation()!=nil then
158
+ response.setLocation(rawresponse.getLocation())
159
+ end
160
+ if rawresponse.getContentType()!=nil then
161
+ response.setContentType(rawresponse.getContentType())
162
+ end
163
+ return response
164
+ end
165
+
166
+ end