africastalking-ruby 2.1.1 → 2.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9a164a8ff23b2df6262e1618fb0410f0865fb5968371a8e84744355972c15392
4
- data.tar.gz: f8f349b0b93e28799b008acb508f6c71e21e4611aadb08586a23a36f0585ce86
3
+ metadata.gz: b413fad16821dec1a3413944c05ad5f7994f2c4ca015f74b18207cf62e43c55b
4
+ data.tar.gz: 25eb01c03084f5476ec527d98eae7997c0a5f545ed65ca8b349646816a6c6a4e
5
5
  SHA512:
6
- metadata.gz: 630d8aab1c9bf72628efacc46a51a1b40dbabe6000523c79fbbc1583859d9ccf7b3c490f31f0ba81a3a30c6b154ed1e2dd2184d9614dcf04a30a0271edf0635b
7
- data.tar.gz: 134cea25df4acaa735d827dad03f6cc256ab67009b42b4d3b59e066a3918a1ae76285fd741145e178484e0a104d30ffaec122b90f7e3c4957d4bf4583fc115c1
6
+ metadata.gz: efb81de911194f28574316cd5814055532e8219385491e4acde20a521b87e589c389ba71cdcd1a5567482824c939ae2969fecd4d3c401991cce1322fb04f6e7e
7
+ data.tar.gz: f6eab4f33c23c6b3234122689742791d8ea982f7e91d885ec55c483119396af32a992bf99a64164667d86f4edb2828afcb2985936fb5de93c8447f4434bc84af
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- africastalking-ruby (2.1.1)
4
+ africastalking-ruby (2.1.1.beta.1)
5
5
  httparty (= 0.16.1)
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -281,6 +281,7 @@ payments.mobileCheckout options
281
281
  - `currencyCode`: 3-digit ISO format currency code (e.g `KES`, `USD`, `UGX` etc.) `REQUIRED`
282
282
  - `amount`: This is the amount. `REQUIRED`
283
283
  - `metadata`: Some optional data to associate with transaction.`OPTIONAL`
284
+ - `providerChannel`: This represents the payment channel the payment will be made from. eg paybill number. The payment channel must be mapped to you. The AfricasTalking default provider channel is used if not specified.`OPTIONAL`
284
285
 
285
286
  #### Mobile B2C
286
287
  ```ruby
@@ -332,6 +333,20 @@ payments.mobileB2B options
332
333
  - `amount`: Payment amount. `REQUIRED`
333
334
  - `metadata`: Some optional data to associate with transaction.`REQUIRED`
334
335
 
336
+ #### Mobile Data
337
+ ```ruby
338
+ payments.mobileData options
339
+ ```
340
+ - `options`
341
+ - `productName`: Your Payment Product. `REQUIRED`
342
+ - `recipients`: A list of recipients. Each recipient has:
343
+
344
+ - `phoneNumber`: Customer phone number (in international format). `REQUIRED`
345
+ - `quantity`: Mobile data amount. `REQUIRED`
346
+ - `unit`: Mobile data unit. Can either be `MB` or `GB`. `REQUIRED`
347
+ - `validity`: How long the mobile data is valid for. Must be one of `Daily`, `Weekly` and `Monthly`. `REQUIRED`
348
+ - `metadata`: Additional data to associate with the transaction. `REQUIRED`
349
+
335
350
  #### Wallet Transfer
336
351
  ```ruby
337
352
  payments.walletTransfer options
@@ -111,6 +111,33 @@ class Payments
111
111
  raise AfricasTalkingException, response
112
112
  end
113
113
 
114
+ def mobileData options
115
+ validateParamsPresence? options, %w(productName)
116
+ recipients = options['recipients'].each{|item|
117
+ validateParamsPresence? item, %w(phoneNumber quantity unit validity metadata)
118
+ }
119
+ parameters = {
120
+ 'username' => @username,
121
+ 'productName' => options['productName'],
122
+ 'recipients' => recipients,
123
+ }
124
+ url = getMobileDataUrl()
125
+ response = sendJSONRequest(url, parameters)
126
+ if (@response_code == HTTP_CREATED)
127
+ resultObj = JSON.parse(response, :quirky_mode =>true)
128
+ if (resultObj['entries'].length > 0)
129
+ results = resultObj['entries'].collect{ |data|
130
+ MobileDataResponse.new data['phoneNumber'], data['provider'], data['status'], data['transactionId'], data['value'], data['errorMessage']
131
+ }
132
+ #
133
+ return results
134
+ end
135
+
136
+ raise AfricasTalkingException, resultObj['errorMessage']
137
+ end
138
+ raise AfricasTalkingException, response
139
+ end
140
+
114
141
  def bankCheckoutCharge options
115
142
  validateParamsPresence? options, %w(bankAccount productName currencyCode amount narration metadata)
116
143
  parameters = {
@@ -381,6 +408,10 @@ class Payments
381
408
  return getPaymentHost() + "/mobile/b2c/request"
382
409
  end
383
410
 
411
+ def getMobileDataUrl()
412
+ return getPaymentHost() + "/mobile/data/request"
413
+ end
414
+
384
415
  def getMobilePaymentB2BUrl()
385
416
  return getPaymentHost() + "/mobile/b2b/request"
386
417
  end
@@ -453,7 +484,20 @@ class MobileB2CResponse
453
484
  @transactionId = transactionId_
454
485
  @errorMessage = errorMessage_
455
486
  end
456
- end
487
+ end
488
+
489
+ class MobileDataResponse
490
+ attr_reader :phoneNumber, :provider, :status, :transactionId, :value, :errorMessage
491
+
492
+ def initialize phoneNumber_, provider_, status_, transactionId_, value_, errorMessage_
493
+ @phoneNumber = phoneNumber_
494
+ @provider = provider_
495
+ @status = status_
496
+ @transactionId = transactionId_
497
+ @value = value_
498
+ @errorMessage = errorMessage_
499
+ end
500
+ end
457
501
 
458
502
  class MobileB2BResponse
459
503
  attr_reader :status, :transactionId, :transactionFee, :providerChannel, :errorMessage
@@ -638,4 +682,4 @@ class TransactionData
638
682
  @transactionId = transactionId_
639
683
  @creationTime = creationTime_
640
684
  end
641
- end
685
+ end
@@ -1,3 +1,3 @@
1
1
  module AfricasTalking
2
- VERSION = "2.1.1"
2
+ VERSION = "2.1.2"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: africastalking-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.1
4
+ version: 2.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Mwirigi
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-10-29 00:00:00.000000000 Z
11
+ date: 2019-09-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler