africastalking-ruby 2.1.6 → 2.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/Gemfile.lock +2 -2
- data/README.md +2 -8
- data/lib/AfricasTalking/Airtime.rb +12 -4
- data/lib/AfricasTalking/Sms.rb +0 -3
- data/lib/AfricasTalking/Token.rb +0 -22
- data/lib/AfricasTalking/version.rb +1 -1
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bc0b95d13726d3cd8857b22f6747a4daba8891932a55432b50fb01e2aad8a6dd
|
4
|
+
data.tar.gz: 4256f674404dd05b4879019e7d4439b819cb87c1a040a50b387a871269d16b79
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 33363d9665e5d79586c31ec649f40913babbc549541a775f2c68bf55ce5d7bcbc2df2e4857ad39489eb2adc6740826cc197d785f3d909598d04c9264b6e2d0a8
|
7
|
+
data.tar.gz: da4e794f0b904002fefecc3983d8334c314058c869c7bb7888961d702e14e4bf011780acd5f8a1fc306f278f66d6a24c06aa27f9519771cd5d97ebd70c0409b3
|
data/.gitignore
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
africastalking-ruby (2.1.
|
4
|
+
africastalking-ruby (2.1.8)
|
5
5
|
httparty (= 0.16.1)
|
6
6
|
|
7
7
|
GEM
|
@@ -114,7 +114,7 @@ DEPENDENCIES
|
|
114
114
|
pry (~> 0)
|
115
115
|
rake (~> 10.0)
|
116
116
|
rspec (~> 3.0)
|
117
|
-
rspec-rails (~> 3.7.2)
|
117
|
+
rspec-rails (~> 3.7, >= 3.7.2)
|
118
118
|
rubocop (~> 0.54.0)
|
119
119
|
|
120
120
|
BUNDLED WITH
|
data/README.md
CHANGED
@@ -48,14 +48,6 @@ token = @AT.token
|
|
48
48
|
|
49
49
|
#### Create authentication Token
|
50
50
|
|
51
|
-
```ruby
|
52
|
-
token.createCheckoutToken options
|
53
|
-
```
|
54
|
-
- `options`
|
55
|
-
- `phoneNumber`: The phone number you want to create a subscription for
|
56
|
-
|
57
|
-
#### Create Checkout Token
|
58
|
-
|
59
51
|
```ruby
|
60
52
|
token.generateAuthToken phoneNumber
|
61
53
|
```
|
@@ -76,6 +68,8 @@ airtime.send options
|
|
76
68
|
- `currency`:3-digit ISO format currency code . `REQUIRED`
|
77
69
|
- `amount`: Amount sent `>= 10 && <= 10K` with currency e.g `KES 100` `REQUIRED`
|
78
70
|
|
71
|
+
- `maxNumRetry`: This allows you to specify the maximum number of retries in case of failed airtime deliveries due to various reasons such as telco unavailability. The default retry period is 8 hours and retries occur every 60seconds. For example, setting `maxNumRetry=4` means the transaction will be retried every 60seconds for the next 4 hours.`OPTIONAL`.
|
72
|
+
|
79
73
|
### Sms
|
80
74
|
|
81
75
|
```ruby
|
@@ -12,15 +12,23 @@ class Airtime
|
|
12
12
|
def send options
|
13
13
|
url = getAirtimeUrl() + "/send"
|
14
14
|
|
15
|
-
recipients = options.each{|item|
|
15
|
+
recipients = options['recipients'].each{|item|
|
16
16
|
validateParamsPresence? item, %w(phoneNumber currencyCode amount)
|
17
17
|
item['amount'].to_s.prepend(item['currencyCode'].to_s + " ")
|
18
18
|
item.delete('currencyCode')
|
19
19
|
}
|
20
20
|
post_body = {
|
21
|
-
|
22
|
-
|
23
|
-
|
21
|
+
'username' => @username,
|
22
|
+
'recipients' => recipients.to_json,
|
23
|
+
}
|
24
|
+
|
25
|
+
if options['maxNumRetry'] && options['maxNumRetry'] > 0
|
26
|
+
post_body['maxNumRetry'] = options['maxNumRetry'].to_i
|
27
|
+
|
28
|
+
else
|
29
|
+
puts "Please make sure #{options['maxNumRetry']} is a number and greater than zero!"
|
30
|
+
end
|
31
|
+
|
24
32
|
response = sendNormalRequest(url, post_body)
|
25
33
|
if (@response_code == HTTP_CREATED)
|
26
34
|
responses = JSON.parse(response, :quirky_mode =>true)
|
data/lib/AfricasTalking/Sms.rb
CHANGED
@@ -145,9 +145,6 @@ class Sms
|
|
145
145
|
'shortCode' => options['shortCode'],
|
146
146
|
'keyword' => options['keyword']
|
147
147
|
}
|
148
|
-
if options['checkoutToken'] != nil
|
149
|
-
post_body['checkoutToken'] = options['checkoutToken']
|
150
|
-
end
|
151
148
|
url = getSmsSubscriptionUrl() + "/create"
|
152
149
|
if validateParamsPresence?(options, ['shortCode', 'keyword', 'phoneNumber'])
|
153
150
|
response = sendNormalRequest(url, post_body)
|
data/lib/AfricasTalking/Token.rb
CHANGED
@@ -24,21 +24,6 @@ class Token
|
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
27
|
-
def createCheckoutToken options
|
28
|
-
post_body = {
|
29
|
-
'phoneNumber' => options['phoneNumber']
|
30
|
-
}
|
31
|
-
url = getApiHost() + "/checkout/token/create"
|
32
|
-
response = sendNormalRequest(url, post_body)
|
33
|
-
#
|
34
|
-
if(@response_code == HTTP_CREATED)
|
35
|
-
r= JSON.parse(response, :quirky_mode => true)
|
36
|
-
return CheckoutTokenResponse.new r['token'], r['description']
|
37
|
-
else
|
38
|
-
raise AfricasTalkingException, response
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
27
|
private
|
43
28
|
|
44
29
|
def getApiHost()
|
@@ -57,10 +42,3 @@ class AuthTokenResponse
|
|
57
42
|
@lifetimeInSeconds = lifetimeInSeconds_
|
58
43
|
end
|
59
44
|
end
|
60
|
-
class CheckoutTokenResponse
|
61
|
-
attr_accessor :token, :description
|
62
|
-
def initialize token_, description_
|
63
|
-
@token = token_
|
64
|
-
@description = description_
|
65
|
-
end
|
66
|
-
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.
|
4
|
+
version: 2.1.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Mwirigi
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-03-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -159,8 +159,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
159
159
|
- !ruby/object:Gem::Version
|
160
160
|
version: '0'
|
161
161
|
requirements: []
|
162
|
-
|
163
|
-
rubygems_version: 2.7.7
|
162
|
+
rubygems_version: 3.4.8
|
164
163
|
signing_key:
|
165
164
|
specification_version: 4
|
166
165
|
summary: Simple gem that helps you build integrations with AfricasTalking
|