t2_airtime 0.1.9 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +50 -50
- data/lib/t2_airtime/util.rb +1 -1
- data/lib/t2_airtime/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ae197e105fc7596c31630070d8030e85757b0701
|
4
|
+
data.tar.gz: f73403091b4c8cd4b0d6977edf60e27f5cdbdc75
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c280efca6a355e39cf15fac08767ebdc9d371d15d5baa59d04d56031e0a765d82284d017a712227d22e2b0e41dc0610477f88834ab079e81f85967f0d1e16b6a
|
7
|
+
data.tar.gz: 0bcffd703b9791a30ecb138ff819ae5b4250c20f49dd867ecfc3b57457a78e686623030abaeda4146ea010dd071c729fb95c2727f3a4549c08edc13e7a99658e
|
data/README.md
CHANGED
@@ -1,69 +1,69 @@
|
|
1
1
|
# TransferTo Airtime API
|
2
2
|
|
3
|
-
TransferTo helps businesses offer airtime top-ups, goods and services, and mobile money around the world in real time.
|
4
|
-
|
5
|
-
application that leverages international recharge services, then this is the API for you.
|
3
|
+
[TransferTo](https://www.transfer-to.com/home) helps businesses offer airtime top-ups, goods and services, and mobile money around the world in real time.
|
4
|
+
TransferTo Airtime API enables developers to integrate TransferTo Top-up service into their system.
|
6
5
|
|
7
|
-
|
6
|
+
This gem is a convenience wrapper around the Airtime API. Requirements:
|
7
|
+
|
8
|
+
Two Factor Authentication (2FA) enabled in your [TransferTo Shop](https://shop.transferto.com) Security Center section.
|
9
|
+
|
10
|
+
|
11
|
+
## Usage
|
12
|
+
|
13
|
+
rails new $APPNAME \
|
14
|
+
--skip-active-record \
|
15
|
+
-d postgresql \
|
16
|
+
--skip-yarn \
|
17
|
+
--skip-action-cable \
|
18
|
+
--skip-sprockets \
|
19
|
+
--skip-spring \
|
20
|
+
--skip-coffee \
|
21
|
+
--skip-javascript \
|
22
|
+
--skip-turbolinks \
|
23
|
+
--api
|
8
24
|
|
9
25
|
Add this line to your application's Gemfile:
|
10
26
|
|
11
27
|
```ruby
|
12
28
|
gem 't2_airtime'
|
13
|
-
```
|
29
|
+
```
|
14
30
|
|
15
31
|
And then execute:
|
16
32
|
|
17
|
-
$ bundle
|
33
|
+
$ bundle
|
18
34
|
|
19
|
-
|
35
|
+
Create a `.env` file with the required information:
|
20
36
|
|
21
|
-
|
37
|
+
T2_SHOP_USER=
|
38
|
+
T2_AIRTIME_KEY=
|
39
|
+
T2_CURRENCY=
|
22
40
|
|
23
|
-
|
41
|
+
Start the server: `bundle exec puma -C config/puma.rb`
|
42
|
+
|
43
|
+
### Routes
|
44
|
+
|
45
|
+
The following routes are mada available to your application when you mount the API engine in `config/routes.rb`:
|
24
46
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
Execute:
|
36
|
-
|
37
|
-
$ rspec
|
38
|
-
|
39
|
-
T2Airtime
|
40
|
-
has a version number
|
41
|
-
has the correct API URL
|
42
|
-
has 7 test numbers
|
43
|
-
responds to ping
|
44
|
-
checks wallet
|
45
|
-
checks number information
|
46
|
-
reserves a transaction id
|
47
|
-
returns a countries list
|
48
|
-
returns a country operators
|
49
|
-
returns an operator products
|
50
|
-
returns error code 0 for PIN based Top-up (successful transaction)
|
51
|
-
returns error code 0 for PIN less Top-up (successful transaction)
|
52
|
-
returns error code 204 (destination number is not a valid prepaid phone number) (FAILED - 1)
|
53
|
-
returns error code 301 (input value out of range or invalid product) (FAILED - 2)
|
54
|
-
returns error code 214 (transaction refused by the operator) (FAILED - 3)
|
55
|
-
returns error code 998 (system not available, please retry later) (FAILED - 4)
|
56
|
-
returns error code 999 (unknown error, please contact support) (FAILED - 5)
|
57
|
-
returns a transaction list
|
58
|
-
|
59
|
-
Failed examples:
|
60
|
-
|
61
|
-
rspec ./spec/t2_airtime_spec.rb:99 # T2Airtime returns error code 204 (destination number is not a valid prepaid phone number)
|
62
|
-
rspec ./spec/t2_airtime_spec.rb:108 # T2Airtime returns error code 301 (input value out of range or invalid product)
|
63
|
-
rspec ./spec/t2_airtime_spec.rb:117 # T2Airtime returns error code 214 (transaction refused by the operator)
|
64
|
-
rspec ./spec/t2_airtime_spec.rb:126 # T2Airtime returns error code 998 (system not available, please retry later)
|
65
|
-
rspec ./spec/t2_airtime_spec.rb:135 # T2Airtime returns error code 999 (unknown error, please contact support)
|
47
|
+
```ruby
|
48
|
+
mount T2Airtime::Engine => '/airtime'
|
49
|
+
```
|
50
|
+
|
51
|
+
http://localhost:3000/airtime/transactions
|
52
|
+
http://localhost:3000/airtime/transactions/<id>
|
53
|
+
http://localhost:3000/airtime/countries
|
54
|
+
http://localhost:3000/airtime/<country_id>/operators
|
55
|
+
http://localhost:3000/airtime/<operator_id>/products
|
66
56
|
|
57
|
+
### Helpers
|
58
|
+
|
59
|
+
Main API helper:
|
60
|
+
|
61
|
+
```ruby
|
62
|
+
api = T2Airtime::API.api
|
63
|
+
```
|
64
|
+
|
65
|
+
[TBC]
|
66
|
+
|
67
67
|
## Development
|
68
68
|
|
69
69
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
data/lib/t2_airtime/util.rb
CHANGED
@@ -17,7 +17,7 @@ module T2Airtime
|
|
17
17
|
num > 0 && num < 8 ? numbers[num-1] : numbers
|
18
18
|
end
|
19
19
|
|
20
|
-
def self.format_price(price, currency=ENV['T2_CURRENCY'])
|
20
|
+
def self.format_price(price, currency=(ENV['T2_CURRENCY'] || "USD"))
|
21
21
|
Money.new(Float(price)*100, currency).format
|
22
22
|
end
|
23
23
|
|
data/lib/t2_airtime/version.rb
CHANGED