Class: Reservation

Inherits:
Object
  • Object
show all
Defined in:
lib/payment/Reservation.rb

Instance Method Summary collapse

Constructor Details

#initialize(endpoints, username, password) ⇒ Reservation

Returns a new instance of Reservation.



11
12
13
14
15
# File 'lib/payment/Reservation.rb', line 11

def initialize(endpoints, username, password)
  @endpoints=endpoints
  @username=username
  @password=password
end

Instance Method Details

#chargeAmount(endUserId, transactionId, referenceCode, description, currency, amount, referenceSequence, code, clientCorrelator, onBehalfOf, purchaseCategoryCode, channel, taxAmount, serviceId, productId) ⇒ Object



167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
# File 'lib/payment/Reservation.rb', line 167

def chargeAmount(endUserId,transactionId,referenceCode,description,currency,amount,referenceSequence,code,clientCorrelator,onBehalfOf,purchaseCategoryCode,channel,taxAmount,serviceId,productId)
  baseurl=@endpoints.getAmountReservationChargeEndpoint()
  requestProcessor=JSONRequest.new()
  formparameters=FormParameters.new()
  formparameters.put('endUserId',endUserId)
  if baseurl.index('{endUserId}')!=nil then
    baseurl=baseurl.gsub('{endUserId}',CGI::escape(endUserId.to_s))
  end
  formparameters.put('transactionId',transactionId)
  if baseurl.index('{transactionId}')!=nil then
    baseurl=baseurl.gsub('{transactionId}',CGI::escape(transactionId.to_s))
  end
  formparameters.put('referenceCode',referenceCode)
  formparameters.put('description',description)
  formparameters.put('currency',currency)
  formparameters.put('amount',amount)
  formparameters.put('referenceSequence',referenceSequence)
  formparameters.put('code',code)
  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', @username, @password)
  response=AmountReservationResponse.new()
  if (rawresponse!=nil) && (rawresponse.getContent()!=nil)
    jsondata=JSON.parse(rawresponse.getContent())
    if (jsondata!=nil) && (jsondata['amountReservationTransaction']!=nil) then
      response.setAmountReservationTransactionJSON(jsondata['amountReservationTransaction'])
    end
  end
  if rawresponse.getCode()!=nil then
    response.setHTTPResponseCode(rawresponse.getCode())
  end
  if rawresponse.getLocation()!=nil then
    response.setLocation(rawresponse.getLocation())
  end
  if rawresponse.getContentType()!=nil then
    response.setContentType(rawresponse.getContentType())
  end
  return response
end

#chargeAmountWithCallback(endUserId, transactionId, referenceCode, description, currency, amount, referenceSequence, code, callbackURL, clientCorrelator, onBehalfOf, purchaseCategoryCode, channel, taxAmount, serviceId, productId) ⇒ Object



213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
# File 'lib/payment/Reservation.rb', line 213

def chargeAmountWithCallback(endUserId,transactionId,referenceCode,description,currency,amount,referenceSequence,code,callbackURL,clientCorrelator,onBehalfOf,purchaseCategoryCode,channel,taxAmount,serviceId,productId)
  baseurl=@endpoints.getAmountReservationChargeEndpoint()
  requestProcessor=JSONRequest.new()
  formparameters=FormParameters.new()
  formparameters.put('endUserId',endUserId)
  if baseurl.index('{endUserId}')!=nil then
    baseurl=baseurl.gsub('{endUserId}',CGI::escape(endUserId.to_s))
  end
  formparameters.put('transactionId',transactionId)
  if baseurl.index('{transactionId}')!=nil then
    baseurl=baseurl.gsub('{transactionId}',CGI::escape(transactionId.to_s))
  end
  formparameters.put('referenceCode',referenceCode)
  formparameters.put('description',description)
  formparameters.put('currency',currency)
  formparameters.put('amount',amount)
  formparameters.put('referenceSequence',referenceSequence)
  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', @username, @password)
  response=AmountReservationResponse.new()
  if (rawresponse!=nil) && (rawresponse.getContent()!=nil)
    jsondata=JSON.parse(rawresponse.getContent())
    if (jsondata!=nil) && (jsondata['amountReservationTransaction']!=nil) then
      response.setAmountReservationTransactionJSON(jsondata['amountReservationTransaction'])
    end
  end
  if rawresponse.getCode()!=nil then
    response.setHTTPResponseCode(rawresponse.getCode())
  end
  if rawresponse.getLocation()!=nil then
    response.setLocation(rawresponse.getLocation())
  end
  if rawresponse.getContentType()!=nil then
    response.setContentType(rawresponse.getContentType())
  end
  return response
end

#getEndpointsObject



16
17
18
# File 'lib/payment/Reservation.rb', line 16

def getEndpoints
  @endpoints
end

#getPasswordObject



32
33
34
# File 'lib/payment/Reservation.rb', line 32

def getPassword
  @password
end

#getUsernameObject



24
25
26
# File 'lib/payment/Reservation.rb', line 24

def getUsername
  @username
end

#releaseReservation(endUserId, transactionId, referenceCode, referenceSequence) ⇒ Object



260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
# File 'lib/payment/Reservation.rb', line 260

def releaseReservation(endUserId,transactionId,referenceCode,referenceSequence)
  baseurl=@endpoints.getAmountReservationReleaseEndpoint()
  requestProcessor=JSONRequest.new()
  formparameters=FormParameters.new()
  formparameters.put('endUserId',endUserId)
  if baseurl.index('{endUserId}')!=nil then
    baseurl=baseurl.gsub('{endUserId}',CGI::escape(endUserId.to_s))
  end
  formparameters.put('transactionId',transactionId)
  if baseurl.index('{transactionId}')!=nil then
    baseurl=baseurl.gsub('{transactionId}',CGI::escape(transactionId.to_s))
  end
  formparameters.put('referenceCode',referenceCode)
  formparameters.put('referenceSequence',referenceSequence)
  postdata=formparameters.encodeParameters()
  rawresponse=requestProcessor.post(baseurl,postdata,'application/json', @username, @password)
  response=AmountReservationResponse.new()
  if (rawresponse!=nil) && (rawresponse.getContent()!=nil)
    jsondata=JSON.parse(rawresponse.getContent())
    if (jsondata!=nil) && (jsondata['amountReservationTransaction']!=nil) then
      response.setAmountReservationTransactionJSON(jsondata['amountReservationTransaction'])
    end
  end
  if rawresponse.getCode()!=nil then
    response.setHTTPResponseCode(rawresponse.getCode())
  end
  if rawresponse.getLocation()!=nil then
    response.setLocation(rawresponse.getLocation())
  end
  if rawresponse.getContentType()!=nil then
    response.setContentType(rawresponse.getContentType())
  end
  return response
end

#reserveAdditionalAmount(endUserId, transactionId, referenceCode, description, currency, amount, referenceSequence, code, clientCorrelator, onBehalfOf, purchaseCategoryCode, channel, taxAmount, serviceId, productId) ⇒ Object



82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
# File 'lib/payment/Reservation.rb', line 82

def reserveAdditionalAmount(endUserId,transactionId,referenceCode,description,currency,amount,referenceSequence,code,clientCorrelator,onBehalfOf,purchaseCategoryCode,channel,taxAmount,serviceId,productId)
  baseurl=@endpoints.getAmountReserveAdditionalEndpoint()
  requestProcessor=JSONRequest.new()
  formparameters=FormParameters.new()
  formparameters.put('endUserId',endUserId)
  if baseurl.index('{endUserId}')!=nil then
    baseurl=baseurl.gsub('{endUserId}',CGI::escape(endUserId.to_s))
  end
  formparameters.put('transactionId',transactionId)
  if baseurl.index('{transactionId}')!=nil then
    baseurl=baseurl.gsub('{transactionId}',CGI::escape(transactionId.to_s))
  end
  formparameters.put('referenceCode',referenceCode)
  formparameters.put('description',description)
  formparameters.put('currency',currency)
  formparameters.put('amount',amount)
  formparameters.put('referenceSequence',referenceSequence)
  formparameters.put('code',code)
  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', @username, @password)
  response=AmountReservationResponse.new()
  if (rawresponse!=nil) && (rawresponse.getContent()!=nil)
    jsondata=JSON.parse(rawresponse.getContent())
    if (jsondata!=nil) && (jsondata['amountReservationTransaction']!=nil) then
      response.setAmountReservationTransactionJSON(jsondata['amountReservationTransaction'])
    end
  end
  if rawresponse.getCode()!=nil then
    response.setHTTPResponseCode(rawresponse.getCode())
  end
  if rawresponse.getLocation()!=nil then
    response.setLocation(rawresponse.getLocation())
  end
  if rawresponse.getContentType()!=nil then
    response.setContentType(rawresponse.getContentType())
  end
  return response
end

#reserveAdditionalAmountSimple(endUserId, transactionId, referenceCode, description, currency, amount, referenceSequence, code) ⇒ Object



128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
# File 'lib/payment/Reservation.rb', line 128

def reserveAdditionalAmountSimple(endUserId,transactionId,referenceCode,description,currency,amount,referenceSequence,code)
  baseurl=@endpoints.getAmountReserveAdditionalEndpoint()
  requestProcessor=JSONRequest.new()
  formparameters=FormParameters.new()
  formparameters.put('endUserId',endUserId)
  if baseurl.index('{endUserId}')!=nil then
    baseurl=baseurl.gsub('{endUserId}',CGI::escape(endUserId.to_s))
  end
  formparameters.put('transactionId',transactionId)
  if baseurl.index('{transactionId}')!=nil then
    baseurl=baseurl.gsub('{transactionId}',CGI::escape(transactionId.to_s))
  end
  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', @username, @password)
  response=AmountReservationResponse.new()
  if (rawresponse!=nil) && (rawresponse.getContent()!=nil)
    jsondata=JSON.parse(rawresponse.getContent())
    if (jsondata!=nil) && (jsondata['amountReservationTransaction']!=nil) then
      response.setAmountReservationTransactionJSON(jsondata['amountReservationTransaction'])
    end
  end
  if rawresponse.getCode()!=nil then
    response.setHTTPResponseCode(rawresponse.getCode())
  end
  if rawresponse.getLocation()!=nil then
    response.setLocation(rawresponse.getLocation())
  end
  if rawresponse.getContentType()!=nil then
    response.setContentType(rawresponse.getContentType())
  end
  return response
end

#reserveInitialAmount(endUserId, referenceCode, description, currency, amount, code, clientCorrelator, onBehalfOf, purchaseCategoryCode, channel, taxAmount, serviceId, productId) ⇒ Object



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/payment/Reservation.rb', line 41

def reserveInitialAmount(endUserId,referenceCode,description,currency,amount,code,clientCorrelator,onBehalfOf,purchaseCategoryCode,channel,taxAmount,serviceId,productId)
  baseurl=@endpoints.getAmountReserveEndpoint()
  requestProcessor=JSONRequest.new()
  formparameters=FormParameters.new()
  formparameters.put('endUserId',endUserId)
  if baseurl.index('{endUserId}')!=nil then
    baseurl=baseurl.gsub('{endUserId}',CGI::escape(endUserId.to_s))
  end
  formparameters.put('referenceCode',referenceCode)
  formparameters.put('description',description)
  formparameters.put('currency',currency)
  formparameters.put('amount',amount)
  formparameters.put('code',code)
  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', @username, @password)
  response=AmountReservationResponse.new()
  if (rawresponse!=nil) && (rawresponse.getContent()!=nil)
    jsondata=JSON.parse(rawresponse.getContent())
    if (jsondata!=nil) && (jsondata['amountReservationTransaction']!=nil) then
      response.setAmountReservationTransactionJSON(jsondata['amountReservationTransaction'])
    end
  end
  if rawresponse.getCode()!=nil then
    response.setHTTPResponseCode(rawresponse.getCode())
  end
  if rawresponse.getLocation()!=nil then
    response.setLocation(rawresponse.getLocation())
  end
  if rawresponse.getContentType()!=nil then
    response.setContentType(rawresponse.getContentType())
  end
  return response
end

#setEndpoints(endpoints) ⇒ Object



20
21
22
# File 'lib/payment/Reservation.rb', line 20

def setEndpoints(endpoints)
  @endpoints=endpoints
end

#setPassword(password) ⇒ Object



36
37
38
# File 'lib/payment/Reservation.rb', line 36

def setPassword(password)
  @password=password
end

#setUsername(username) ⇒ Object



28
29
30
# File 'lib/payment/Reservation.rb', line 28

def setUsername(username)
  @username=username
end