t2_airtime 0.2.6 → 0.3.0
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/MIT-LICENSE +20 -0
- data/README.md +413 -31
- data/Rakefile +23 -3
- data/app/controllers/t2_airtime/airtime_controller.rb +102 -102
- data/config/routes.rb +8 -8
- data/lib/t2_airtime/engine.rb +6 -0
- data/lib/t2_airtime/version.rb +1 -1
- data/lib/t2_airtime.rb +1 -0
- data/spec/dummy/Rakefile +6 -0
- data/spec/dummy/app/assets/config/manifest.js +2 -0
- data/spec/dummy/app/assets/javascripts/application.js +13 -0
- data/spec/dummy/app/assets/stylesheets/application.css +15 -0
- data/spec/dummy/app/channels/application_cable/channel.rb +4 -0
- data/spec/dummy/app/channels/application_cable/connection.rb +4 -0
- data/spec/dummy/app/controllers/application_controller.rb +2 -0
- data/spec/dummy/app/jobs/application_job.rb +2 -0
- data/spec/dummy/app/mailers/application_mailer.rb +4 -0
- data/spec/dummy/app/views/layouts/mailer.html.erb +13 -0
- data/spec/dummy/app/views/layouts/mailer.text.erb +1 -0
- data/spec/dummy/bin/bundle +3 -0
- data/spec/dummy/bin/rails +4 -0
- data/spec/dummy/bin/rake +4 -0
- data/spec/dummy/bin/setup +27 -0
- data/spec/dummy/bin/update +26 -0
- data/spec/dummy/config/application.rb +31 -0
- data/spec/dummy/config/boot.rb +5 -0
- data/spec/dummy/config/cable.yml +10 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +44 -0
- data/spec/dummy/config/environments/production.rb +80 -0
- data/spec/dummy/config/environments/test.rb +42 -0
- data/spec/dummy/config/initializers/application_controller_renderer.rb +6 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/cors.rb +16 -0
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/spec/dummy/config/initializers/inflections.rb +16 -0
- data/spec/dummy/config/initializers/mime_types.rb +4 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +9 -0
- data/spec/dummy/config/locales/en.yml +33 -0
- data/spec/dummy/config/puma.rb +56 -0
- data/spec/dummy/config/routes.rb +3 -0
- data/spec/dummy/config/secrets.yml +32 -0
- data/spec/dummy/config/spring.rb +6 -0
- data/spec/dummy/config.ru +5 -0
- data/spec/dummy/log/development.log +118 -0
- data/spec/dummy/log/test.log +0 -0
- data/spec/dummy/tmp/restart.txt +0 -0
- data/spec/rails_helper.rb +60 -0
- data/spec/spec_helper.rb +96 -0
- data/spec/t2_airtime_spec.rb +181 -0
- metadata +92 -73
- data/.gitignore +0 -14
- data/.rspec +0 -2
- data/.travis.yml +0 -5
- data/CODE_OF_CONDUCT.md +0 -74
- data/Gemfile +0 -6
- data/LICENSE.txt +0 -21
- data/doc/T2Airtime/API.html +0 -1152
- data/doc/T2Airtime/Account.html +0 -260
- data/doc/T2Airtime/AirtimeController.html +0 -491
- data/doc/T2Airtime/Base.html +0 -346
- data/doc/T2Airtime/ConfigurationError.html +0 -124
- data/doc/T2Airtime/Country.html +0 -448
- data/doc/T2Airtime/Engine.html +0 -124
- data/doc/T2Airtime/Error.html +0 -290
- data/doc/T2Airtime/Operator.html +0 -272
- data/doc/T2Airtime/Product.html +0 -294
- data/doc/T2Airtime/Reply.html +0 -775
- data/doc/T2Airtime/Request.html +0 -664
- data/doc/T2Airtime/Test.html +0 -221
- data/doc/T2Airtime/Transaction.html +0 -426
- data/doc/T2Airtime/Util.html +0 -338
- data/doc/T2Airtime.html +0 -147
- data/doc/_index.html +0 -265
- data/doc/class_list.html +0 -51
- data/doc/css/common.css +0 -1
- data/doc/css/full_list.css +0 -58
- data/doc/css/style.css +0 -492
- data/doc/file.README.html +0 -172
- data/doc/file_list.html +0 -56
- data/doc/frames.html +0 -17
- data/doc/index.html +0 -172
- data/doc/js/app.js +0 -248
- data/doc/js/full_list.js +0 -216
- data/doc/js/jquery.js +0 -4
- data/doc/method_list.html +0 -491
- data/doc/top-level-namespace.html +0 -110
- data/release +0 -7
- data/t2_airtime.gemspec +0 -33
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d5be1d81ae20b8777de2203112eb858f005a2d5c
|
4
|
+
data.tar.gz: 2cddc813b0f043c501119d1f654e921248a2daf9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a0a908f95d48701e5c4df6784c0158c5bf3d71fb06b4d771f2d0948e0eda622f6aeacb8dac184a0cb501e15738efe23ffee0dc7c92f143faa0a3db78eac3c110
|
7
|
+
data.tar.gz: 724d54f3f1b4469f4e40942a102df63636a9e095bfc3f5bb4c4120ead886d48cc1e7ee5150b0ac79c87dacbd24a5be58f0346bde26486d4989d0948cfb93ec33
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2017 matteolc
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
CHANGED
@@ -8,18 +8,9 @@ This gem is a convenience wrapper around the Airtime API. Requirement is that Tw
|
|
8
8
|
|
9
9
|
## Usage
|
10
10
|
|
11
|
-
Create a new rails application
|
12
|
-
|
13
|
-
rails new
|
14
|
-
--skip-active-record \
|
15
|
-
--skip-yarn \
|
16
|
-
--skip-action-cable \
|
17
|
-
--skip-sprockets \
|
18
|
-
--skip-spring \
|
19
|
-
--skip-coffee \
|
20
|
-
--skip-javascript \
|
21
|
-
--skip-turbolinks \
|
22
|
-
--api
|
11
|
+
Create a new rails application:
|
12
|
+
|
13
|
+
rails new t2_airtime
|
23
14
|
|
24
15
|
Add this line to your application's Gemfile:
|
25
16
|
|
@@ -35,7 +26,6 @@ Create a `.env` file with the required information:
|
|
35
26
|
|
36
27
|
T2_SHOP_USER=
|
37
28
|
T2_AIRTIME_KEY=
|
38
|
-
T2_CURRENCY=
|
39
29
|
|
40
30
|
Start the server: `bundle exec puma -C config/puma.rb`
|
41
31
|
|
@@ -44,39 +34,431 @@ Start the server: `bundle exec puma -C config/puma.rb`
|
|
44
34
|
The following routes are mada available to your application when you mount the API engine in `config/routes.rb`:
|
45
35
|
|
46
36
|
```ruby
|
47
|
-
mount T2Airtime::Engine => '/
|
37
|
+
mount T2Airtime::Engine => '/t2_airtime'
|
48
38
|
```
|
49
39
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
40
|
+
* `/t2_airtime/account` [Account information](#account_info)
|
41
|
+
* `/t2_airtime/countries` [List of all countries offered](#country_list)
|
42
|
+
* `/t2_airtime/countries/<country_id>/operators` [List of all operators available for a certain country](#operator_list)
|
43
|
+
* `/t2_airtime/countries/<country_id>/operators/<operator_id>/products` [List of all products available for a certain operator](#product_list)
|
44
|
+
* `/t2_airtime/transactions` [List all transactions](#transaction_list)
|
45
|
+
* `/t2_airtime/transactions/<id>` [Show a transaction](#transaction_show)
|
55
46
|
|
56
|
-
###
|
47
|
+
### API Object
|
57
48
|
|
58
|
-
|
49
|
+
You can access the Airtime API in Ruby as:
|
59
50
|
|
60
51
|
```ruby
|
61
52
|
api = T2Airtime::API.api
|
62
53
|
```
|
63
54
|
|
64
|
-
|
55
|
+
The following methods are available to the `api` object:
|
65
56
|
|
66
|
-
|
57
|
+
* `ping` [Test the connection to the Airtime API](#ping)
|
58
|
+
* `account_info` [Information regarding your TransferTo account](#account_info)
|
59
|
+
* `country_list` [Retrieve available countries](#country_list)
|
60
|
+
* `operator_list` [Retrieve all operators available for a certain country](#operator_list)
|
61
|
+
* `product_list` [Retrieve all products available for a certain operator](#product_list)
|
62
|
+
* `transaction_list` [Retrieve the list of transactions performed within a date range](#transaction_list)
|
63
|
+
* `transaction_info` [Retrieve available information on a specific transaction](#transaction_info)
|
64
|
+
* `topup` Recharge a destination number with a specified product.
|
65
|
+
* `msisdn_info` Retrieve various information of a specific MSISDN as well as the list of all products configured for your specific account and the destination operator of the MSISDN.
|
66
|
+
* `reserve_id` Reserve a transaction ID in the system. Maybe used in a topup operation.
|
67
|
+
* `get_id_from_key` Retrieve the ID of a transaction previously performed based on the key used in the request at that time.
|
67
68
|
|
68
|
-
|
69
|
+
Each method returns an object with the following properties:
|
69
70
|
|
70
|
-
|
71
|
+
* `success?` `true` if the request was successful.
|
72
|
+
* `status` The HTTP status of the reply. `200` indicates a successful request.
|
73
|
+
* `error_code` The error code of the request. `0` indicates a successful request.
|
74
|
+
* `error_message` The error message of the request. `Transaction successful` indicates a successful request.
|
75
|
+
* `url` The full URL of the request.
|
76
|
+
* `information` The response body as a hash.
|
77
|
+
* `auth_key` The authorization key used in the request.
|
78
|
+
* `headers` The HTTP Headers of the reply.
|
79
|
+
* `raw` The raw body of the reply.
|
71
80
|
|
72
|
-
|
81
|
+
<a name="ping"></a>
|
82
|
+
#### Ping
|
73
83
|
|
74
|
-
|
84
|
+
This method can be used for keep-alive. To test the connection with the API:
|
75
85
|
|
76
|
-
|
86
|
+
```ruby
|
87
|
+
irb(main)> response= T2Airtime::API.api.ping
|
88
|
+
irb(main)> response.success?
|
89
|
+
=> true
|
90
|
+
```
|
91
|
+
|
92
|
+
<a name="account_info"></a>
|
93
|
+
#### Account Information
|
94
|
+
|
95
|
+
The `account_info` method retrieves the various information regarding your TransferTo account.
|
96
|
+
To format the response as JSON-API you can call `T2Airtime::Account.serialize(data)`.
|
97
|
+
|
98
|
+
From a Rails console (or Ruby file):
|
99
|
+
|
100
|
+
```ruby
|
101
|
+
irb(main)> response= T2Airtime::API.api.account_info
|
102
|
+
irb(main)> account= T2Airtime::Account.serialize(response.data)
|
103
|
+
```
|
104
|
+
|
105
|
+
The serializer returns the following JSON representation of your account:
|
106
|
+
|
107
|
+
```ruby
|
108
|
+
{
|
109
|
+
"type": "accounts",
|
110
|
+
# Account login name
|
111
|
+
"id": ACCOUNT_ID,
|
112
|
+
"attributes": {
|
113
|
+
# Account type: "Master" (main account) or "Retailer" (subaccount)
|
114
|
+
"type": ACCOUNT_TYPE
|
115
|
+
# Account login name
|
116
|
+
"name": ACCOUNT_NAME,
|
117
|
+
# Account currency (USD, GBP, EUR, etc…)
|
118
|
+
"currency": ACCOUNT_CURRENCY,
|
119
|
+
# For main account: returns the account’s remaining balance.
|
120
|
+
# For sub-account: returns the account’s remaining limit balance
|
121
|
+
# of the day if a daily limit is fixed. Else, returns the account
|
122
|
+
# remaining balance
|
123
|
+
"balance": ACCOUNT_BALANCE,
|
124
|
+
# For main account: returns the total remaining balance (sum
|
125
|
+
# of all sub-accounts and current master).
|
126
|
+
# For sub-account:
|
127
|
+
# 1. If balance is shared and daily limit is fixed: returns the fixed daily limit amount
|
128
|
+
# 2. If balance is shared but daily limit is not fixed: returns "No Limit"
|
129
|
+
# 3. Else if balance is not shared: returns the remaining balance
|
130
|
+
"wallet": ACCOUNT_WALLET,
|
131
|
+
# The time at which the information was fetched.
|
132
|
+
# Can be used for caching purposes.
|
133
|
+
"fetched-at": TIMESTAMP
|
134
|
+
}
|
135
|
+
}
|
136
|
+
{{</ highlight >}}
|
137
|
+
|
138
|
+
From a browser:
|
139
|
+
[http://localhost:3000/account](/)
|
140
|
+
|
141
|
+

|
142
|
+
|
143
|
+
<a name="country_list"></a>
|
144
|
+
#### Country List
|
145
|
+
|
146
|
+
The `country_list` method retrieves the countries offered in your TransferTo price list.
|
147
|
+
To format the response as JSON-API you can call `T2Airtime::Country.serialize(data)`.
|
148
|
+
|
149
|
+
From a Rails console (or Ruby file):
|
150
|
+
|
151
|
+
```ruby
|
152
|
+
irb(main)> response= T2Airtime::API.api.country_list
|
153
|
+
irb(main)> countries= T2Airtime::Country.serialize(response.data)
|
154
|
+
```
|
155
|
+
|
156
|
+
The serializer returns the following JSON representation of a country:
|
157
|
+
|
158
|
+
```ruby
|
159
|
+
{
|
160
|
+
"type": "countries",
|
161
|
+
# Unique Airtime ID for the country
|
162
|
+
"id": COUNTRY_ID,
|
163
|
+
"attributes": {
|
164
|
+
# The country name
|
165
|
+
"name": COUNTRY_NAME,
|
166
|
+
# The ISO 3166-1 country alpha-3, https://it.wikipedia.org/wiki/ISO_3166-1_alpha-3
|
167
|
+
# Can be used for unique country identification.
|
168
|
+
"alpha3": COUNTRY_ALPHA3,
|
169
|
+
# The time at which the country was fetched.
|
170
|
+
# Can be used for caching purposes.
|
171
|
+
"fetched-at": TIMESTAMP
|
172
|
+
},
|
173
|
+
"relationships": {
|
174
|
+
"operators": { "links": { "related": "/countries/COUNTRY_ID/operators" } }
|
175
|
+
}
|
176
|
+
}
|
177
|
+
```
|
178
|
+
|
179
|
+
The `relationships` section of the response provides a link you can use to navigate the country operators.
|
180
|
+
|
181
|
+
From a browser:
|
182
|
+
[http://localhost:3000/countries](/)
|
183
|
+
|
184
|
+

|
185
|
+
|
186
|
+
<a name="operator_list"></a>
|
187
|
+
#### Operator List
|
188
|
+
|
189
|
+
The `operator_list` method retrieves the operators available for a certain country.
|
190
|
+
To format the response as JSON-API you can call `T2Airtime::Operator.serialize(data)`.
|
191
|
+
|
192
|
+
From a Rails console (or Ruby file):
|
193
|
+
|
194
|
+
```ruby
|
195
|
+
irb(main)> response= T2Airtime::API.api.operator_list countries.shuffle.first["id"]
|
196
|
+
irb(main)> operators= T2Airtime::Operator.serialize(response.data)
|
197
|
+
```
|
198
|
+
|
199
|
+
The serializer returns the following JSON representation of an operator:
|
200
|
+
|
201
|
+
```ruby
|
202
|
+
{
|
203
|
+
"type": "operators",
|
204
|
+
# Unique Airtime ID for the operator
|
205
|
+
"id": OPERATOR_ID,
|
206
|
+
"attributes": {
|
207
|
+
# The operator name
|
208
|
+
"name": OPERATOR_NAME,
|
209
|
+
# The time at which the operator was fetched.
|
210
|
+
# Can be used for caching purposes.
|
211
|
+
"fetched-at": TIMESTAMP
|
212
|
+
},
|
213
|
+
"links": {
|
214
|
+
# The URL at which you can retrieve the operator's logo
|
215
|
+
logo: OPERATOR_LOGO_URL
|
216
|
+
},
|
217
|
+
"relationships": {
|
218
|
+
"country": { "data": { "type": "countries", "id": COUNTRY_ID } },
|
219
|
+
"products": { "links": { "related": "/countries/COUNTRY_ID/operators/OPERATOR_ID/products" } }
|
220
|
+
},
|
221
|
+
"included": [
|
222
|
+
{
|
223
|
+
"type": "countries",
|
224
|
+
"id": COUNTRY_ID,
|
225
|
+
"attributes": {
|
226
|
+
"name": COUNTRY_NAME,
|
227
|
+
"alpha3": COUNTRY_ALPHA3
|
228
|
+
}
|
229
|
+
}
|
230
|
+
]
|
231
|
+
}
|
232
|
+
```
|
233
|
+
|
234
|
+
* The `relationships` section of the response provides a link you can use to navigate the operator products.
|
235
|
+
* The `included` section of the response provides all the information regarding the operator's country.
|
236
|
+
|
237
|
+
From a browser:
|
238
|
+
[http://localhost:3000/countries/COUNTRY_ID/operators](/)
|
239
|
+
|
240
|
+

|
241
|
+
|
242
|
+
<a name="product_list"></a>
|
243
|
+
#### Product List
|
77
244
|
|
78
|
-
The
|
245
|
+
The `product_list` method retrieves the products available for a certain operator.
|
246
|
+
To format the response as JSON-API you can call `T2Airtime::Product.serialize(data)`.
|
79
247
|
|
80
|
-
|
248
|
+
From a Rails console (or Ruby file):
|
249
|
+
|
250
|
+
```ruby
|
251
|
+
irb(main)> response= T2Airtime::API.api.product_list operators.shuffle.first["id"]
|
252
|
+
irb(main)> products= T2Airtime::Product.serialize(response.data)
|
253
|
+
```
|
254
|
+
|
255
|
+
The serializer returns the following JSON representation of a product:
|
256
|
+
|
257
|
+
```ruby
|
258
|
+
{
|
259
|
+
"type": "products",
|
260
|
+
# Airtime ID for the product. Attention! It is only unique within
|
261
|
+
# the scope of the operator
|
262
|
+
"id": PRODUCT_ID,
|
263
|
+
"attributes": {
|
264
|
+
# The product name, or face value for display, es. 5EUR
|
265
|
+
"name": PRODUCT_NAME,
|
266
|
+
# Currency of the destination country
|
267
|
+
"currency": PRODUCT_CURRENCY,
|
268
|
+
# The face value of the product (same as id)
|
269
|
+
"local-price": PRODUCT_LOCAL_PRICE,
|
270
|
+
# The retail price of the product
|
271
|
+
"retail-price": PRODUCT_RETAIL_PRICE,
|
272
|
+
# The wholesale price (also known as your cost) of the product
|
273
|
+
"wholesale-price": PRODUCT_WHOLESALE_PRICE,
|
274
|
+
# The time at which the operator was fetched.
|
275
|
+
# Can be used for caching purposes.
|
276
|
+
"fetched-at": TIMESTAMP
|
277
|
+
},
|
278
|
+
"relationships": {
|
279
|
+
"country": { "data": { "type": "countries", "id": COUNTRY_ID } },
|
280
|
+
"operator": { "data": { "type": "operators", "id": OPERATOR_ID } }
|
281
|
+
},
|
282
|
+
"included": [
|
283
|
+
{
|
284
|
+
"type": "countries",
|
285
|
+
"id": COUNTRY_ID,
|
286
|
+
"attributes": {
|
287
|
+
"name": COUNTRY_NAME,
|
288
|
+
"alpha3": COUNTRY_ALPHA3
|
289
|
+
}
|
290
|
+
},
|
291
|
+
{
|
292
|
+
"type": "operators",
|
293
|
+
"id": OPERATOR_ID,
|
294
|
+
"attributes": { "name": OPERATOR_NAME },
|
295
|
+
"links": { "logo": OPERATOR_LOGO_URL }
|
296
|
+
}
|
297
|
+
]
|
298
|
+
}
|
299
|
+
}
|
300
|
+
```
|
301
|
+
|
302
|
+
* The `relationships` section of the response provides a link you can use to navigate the product `included` relationships.
|
303
|
+
* The `included` section of the response provides all the information regarding the product's country and operator.
|
304
|
+
|
305
|
+
From a browser:
|
306
|
+
[http://localhost:3000/countries/COUNTRY_ID/operators/OPERATOR_ID/products](/)
|
307
|
+
|
308
|
+

|
309
|
+
|
310
|
+
<a name="transaction_list"></a>
|
311
|
+
#### Transaction List
|
312
|
+
|
313
|
+
The `transaction_list` method retrieves all transaction within the specified time-range.
|
314
|
+
To format the response as JSON-API you can call `T2Airtime::Transaction.serialize(data)`.
|
315
|
+
|
316
|
+
From a Rails console (or Ruby file):
|
317
|
+
|
318
|
+
```ruby
|
319
|
+
irb(main)> response= T2Airtime::API.api.transaction_list
|
320
|
+
irb(main)> transactions= T2Airtime::Transaction.serialize(response.data)
|
321
|
+
```
|
322
|
+
|
323
|
+
From a browser:
|
324
|
+
[http://localhost:3000/transactions](/)
|
325
|
+
|
326
|
+

|
327
|
+
|
328
|
+
|
329
|
+
<a name="transaction_info"></a>
|
330
|
+
#### Transaction Information
|
331
|
+
|
332
|
+
The `transaction_info` method retrieves information regarding a certain transaction.
|
333
|
+
To format the response as JSON-API you can call `T2Airtime::Transaction.serialize_one(data)`.
|
334
|
+
|
335
|
+
From a Rails console (or Ruby file):
|
336
|
+
|
337
|
+
```ruby
|
338
|
+
irb(main)> response= T2Airtime::API.api.transaction_info
|
339
|
+
irb(main)> transactions= T2Airtime::Transaction.serialize_one(response.data)
|
340
|
+
{{</ highlight >}}
|
341
|
+
|
342
|
+
The serializer returns the following JSON representation of a transaction:
|
343
|
+
|
344
|
+
```ruby
|
345
|
+
{
|
346
|
+
type: "transactions",
|
347
|
+
# Unique Airtime ID for the transaction
|
348
|
+
id: TRANSACTION_ID,
|
349
|
+
attributes: {
|
350
|
+
# The international phone number or name of
|
351
|
+
# the user (sender) requesting to credit a phone
|
352
|
+
# number
|
353
|
+
"msisdn": TRANSACTION_MSISDN,
|
354
|
+
# Destination MSISDN (usually recipient phone number)
|
355
|
+
"destination-msisdn": TRANSACTION_DESTINATION_MSISDN,
|
356
|
+
# Authentication key used during the transaction
|
357
|
+
"transaction-authentication-key": TRANSACTION_AUTHENTICATION_KEY,
|
358
|
+
# Error code for the transaction
|
359
|
+
"transaction-error-code": TRANSACTION_ERROR_CODE,
|
360
|
+
# Description of the error code for the transaction
|
361
|
+
"transaction-error-txt": TRANSACTION_ERROR_TEXT,
|
362
|
+
# Reference of the operator (returned only if available)
|
363
|
+
"reference-operator": TRANSACTION_REFERENCE_OPERATOR,
|
364
|
+
# Returns the value requested to the operator
|
365
|
+
# (equals to product_requested in case of successful
|
366
|
+
# transaction). It equals to 0 when Top-up
|
367
|
+
# failed.
|
368
|
+
"actual-product-sent": TRANSACTION_PRODUCT_SENT,
|
369
|
+
# Recipient SMS
|
370
|
+
# Returns the custom message appended to the
|
371
|
+
# default notification SMS sent to the recipient
|
372
|
+
"sms": TRANSACTION_SMS,
|
373
|
+
# Value of the customized field cid1 sent in the Top-up request
|
374
|
+
"cid1": TRANSACTION_CID1,
|
375
|
+
# Value of the customized field cid2 sent in the Top-up request
|
376
|
+
"cid2": TRANSACTION_CID2,
|
377
|
+
# Value of the customized field cid3 sent in the Top-up request
|
378
|
+
"cid3": TRANSACTION_CID3,
|
379
|
+
# Date of the transaction (GMT)
|
380
|
+
"date": TRANSACTION_DATE,
|
381
|
+
# Currency of the account from which the transaction is requested
|
382
|
+
"originating-currency": TRANSACTION_ORIGINATING_CURRENCY,
|
383
|
+
# Currency of the destination country
|
384
|
+
"destination-currency": TRANSACTION_DESTINATION_CURRENCY,
|
385
|
+
# Type of product returned ("Yes", default "No" if not set)
|
386
|
+
"pin-based": TRANSACTION_PIN_BASED,
|
387
|
+
# Final amount received by recipient. Indicative value only
|
388
|
+
"local-info-amount": TRANSACTION_LOCAL_INFO_AMOUNT,
|
389
|
+
# Local currency in destination
|
390
|
+
"local-info-currency": TRANSACTION_LOCAL_INFO_CURRENCY,
|
391
|
+
# Value of the transaction before tax and service
|
392
|
+
# fee in local currency.
|
393
|
+
"local-info-amount": TRANSACTION_LOCAL_INFO_AMOUNT,
|
394
|
+
# The time at which the transaction was fetched.
|
395
|
+
# Can be used for caching purposes.
|
396
|
+
"fetched-at": TIMESTAMP
|
397
|
+
},
|
398
|
+
relationships: {
|
399
|
+
country: { data: { type: "countries", id: COUNTRY_ID } },
|
400
|
+
operator: { data: { type: "operators", id: OPERATOR_ID } },
|
401
|
+
product: { data: { type: "products", id: PRODUCT_ID } }
|
402
|
+
},
|
403
|
+
included: [
|
404
|
+
{
|
405
|
+
type: "countries",
|
406
|
+
id: COUNTRY_ID,
|
407
|
+
attributes: {
|
408
|
+
"name": COUNTRY_NAME,
|
409
|
+
"alpha3": COUNTRY_ALPHA3
|
410
|
+
}
|
411
|
+
},
|
412
|
+
{
|
413
|
+
type: "operators",
|
414
|
+
id: OPERATOR_ID,
|
415
|
+
attributes: { "name": OPERATOR_NAME },
|
416
|
+
links: { logo: OPERATOR_LOGO_URL }
|
417
|
+
},
|
418
|
+
{
|
419
|
+
type: "products",
|
420
|
+
id: PRODUCT_ID,
|
421
|
+
attributes: {
|
422
|
+
"name": PRODUCT_NAME,
|
423
|
+
"currency": PRODUCT_CURRENCY,
|
424
|
+
"wholesale-price": PRODUCT_WHOLESALE_PRICE,
|
425
|
+
"retail-price": PRODUCT_RETAIL_PRICE,
|
426
|
+
"local-price": PRODUCT_LOCAL_PRICE
|
427
|
+
}
|
428
|
+
}
|
429
|
+
]
|
430
|
+
}
|
431
|
+
```
|
432
|
+
|
433
|
+
* The `relationships` section of the response provides a link you can use to navigate the product `included` relationships.
|
434
|
+
* The `included` section of the response provides all the information regarding the product's country and operator.
|
435
|
+
|
436
|
+
From a browser:
|
437
|
+
[http://localhost:3000/transactions/TRANSACTION_ID](/)
|
438
|
+
|
439
|
+

|
440
|
+
|
441
|
+
## Testing
|
442
|
+
|
443
|
+
Clone this repository and export your secrets:
|
444
|
+
|
445
|
+
$> export T2_SHOP_USER=
|
446
|
+
$> export T2_AIRTIME_KEY=
|
447
|
+
|
448
|
+
Execute:
|
449
|
+
|
450
|
+
rake
|
451
|
+
|
452
|
+
To execute the test application:
|
453
|
+
|
454
|
+
cd spec/dummy
|
455
|
+
|
456
|
+
Start the server: `puma -C config/puma.rb`
|
457
|
+
|
458
|
+
## Contributing
|
459
|
+
|
460
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/matteolc/t2_airtime.
|
461
|
+
|
462
|
+
## License
|
81
463
|
|
82
|
-
|
464
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/Rakefile
CHANGED
@@ -1,6 +1,26 @@
|
|
1
|
-
|
2
|
-
require
|
1
|
+
begin
|
2
|
+
require 'bundler/setup'
|
3
|
+
rescue LoadError
|
4
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
5
|
+
end
|
3
6
|
|
7
|
+
require 'rdoc/task'
|
8
|
+
|
9
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
10
|
+
rdoc.rdoc_dir = 'rdoc'
|
11
|
+
rdoc.title = 'T2Airtime'
|
12
|
+
rdoc.options << '--line-numbers'
|
13
|
+
rdoc.rdoc_files.include('README.md')
|
14
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
15
|
+
end
|
16
|
+
|
17
|
+
load 'rails/tasks/statistics.rake'
|
18
|
+
|
19
|
+
require 'bundler/gem_tasks'
|
20
|
+
|
21
|
+
require 'rspec/core/rake_task'
|
4
22
|
RSpec::Core::RakeTask.new(:spec)
|
5
23
|
|
6
|
-
task :
|
24
|
+
task default: :spec
|
25
|
+
|
26
|
+
|