t2_airtime 0.4.0 → 0.4.1
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/README.md +462 -408
- data/lib/t2_airtime/serializer.rb +1 -0
- data/lib/t2_airtime/version.rb +1 -1
- data/spec/dummy/tmp/cache/361/BB0/accounts +0 -0
- data/spec/dummy/tmp/cache/3DD/470/countries +0 -0
- data/spec/dummy/tmp/cache/4DE/4A0/products%2F2361 +0 -0
- data/spec/dummy/tmp/cache/51F/AC0/operators%2F666 +0 -0
- data/spec/dummy/tmp/cache/632/7D0/msisdn%2F%2B628123456710 +0 -0
- data/spec/dummy/tmp/cache/8B4/E50/countries%2Fserializer +165 -165
- data/spec/dummy/tmp/cache/9B5/F50/products%2F2361%2Fserializer +25 -0
- data/spec/dummy/tmp/cache/9F6/A40/operators%2F666%2Fserializer +2 -0
- metadata +11 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0a465a10576955be1e193df5070890b80d6884d4
|
4
|
+
data.tar.gz: 1182a3ea5ee57f02f690ac599ce286fc2bc5af53
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b77299b057c64afb6e9a4591d89cb308b027bc89d08c79c98c24eeab8ade528cc39e37160c7efce85a5abb4ed9f6f61dd86a8a53e21a8e57c85b430a5936290d
|
7
|
+
data.tar.gz: 5d13a4d7bb0f2bfa5ee5daf76eed8e3f67f897b5b667d464a8c72189bd2c316377ff34913a022e7e3a8b8fc5a03ee2371eb9c3df81bac68665d7a08d303edac5
|
data/README.md
CHANGED
@@ -1,464 +1,518 @@
|
|
1
|
-
|
1
|
+
FORMAT: 1A
|
2
|
+
HOST: http://polls.apiblueprint.org/
|
2
3
|
|
3
|
-
|
4
|
-
TransferTo Airtime API enables developers to integrate TransferTo Top-up service into their system.
|
4
|
+
# t2-airtime
|
5
5
|
|
6
|
-
|
6
|
+
T2-Airtime is a Ruby gem providing a proxy cache and a REST API to [TransferTo](https://www.transfer-to.com/home) Airtime service.
|
7
7
|
|
8
|
+
## Authorization
|
8
9
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
Add this line to your application's Gemfile:
|
16
|
-
|
17
|
-
```ruby
|
18
|
-
gem 't2_airtime'
|
19
|
-
```
|
20
|
-
|
21
|
-
And then execute:
|
22
|
-
|
23
|
-
$ bundle
|
24
|
-
|
25
|
-
Create a `.env` file with the required information:
|
26
|
-
|
27
|
-
T2_SHOP_USER=
|
28
|
-
T2_AIRTIME_KEY=
|
29
|
-
|
30
|
-
Start the server: `bundle exec puma -C config/puma.rb`
|
31
|
-
|
32
|
-
### Routes
|
33
|
-
|
34
|
-
The following routes are mada available to your application when you mount the API engine in `config/routes.rb`:
|
10
|
+
+ Two Factor Authentication (2FA) is enabled in your [TransferTo Shop](https://shop.transferto.com) Security Center section
|
11
|
+
+ You have your Transfer-To Shop username and Airtime secret key generated by 2FA
|
12
|
+
+ Export the secrets as environment variables `T2_SHOP_USER`, `T2_AIRTIME_KEY`
|
13
|
+
|
14
|
+
# Account
|
35
15
|
|
36
16
|
```ruby
|
37
|
-
|
17
|
+
irb(main)> account= T2Airtime::Account.get
|
18
|
+
irb(main)> T2Airtime::Account.serialize(account.data)
|
38
19
|
```
|
39
20
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
21
|
+
## Account Attributes
|
22
|
+
- `id` (string) - Transfer-To TShop login name
|
23
|
+
- `type` (string) - `Master` (main account) or `Retailer` (subaccount)
|
24
|
+
- `name` (string) - Transfer-To TShop account name
|
25
|
+
- `currency` (string) - Account currency (USD, GBP, EUR, etc...)
|
26
|
+
- `balance` (float) - For `Master` account returns the account’s remaining balance.
|
27
|
+
For `Retailer` returns the account’s remaining limit balance of the day
|
28
|
+
if a daily limit is fixed. Else, returns the account remaining balance
|
29
|
+
- `wallet` (float) - For `Master` returns the total remaining balance (sum
|
30
|
+
of all sub-accounts and current master). For `Retailer`:
|
31
|
+
1. If balance is shared and daily limit is fixed: returns the fixed daily limit amount
|
32
|
+
2. If balance is shared but daily limit is not fixed: returns "No Limit"
|
33
|
+
3. Else if balance is not shared: returns the remaining balance
|
34
|
+
- `fetchedAt` (string) - The date and time at which the information was fetched
|
35
|
+
|
36
|
+
# Country
|
50
37
|
|
51
38
|
```ruby
|
52
|
-
|
39
|
+
irb(main)> countries= T2Airtime::Country.all
|
40
|
+
irb(main)> T2Airtime::Country.serialize(countries.data)
|
53
41
|
```
|
54
42
|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
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.
|
68
|
-
|
69
|
-
Each method returns an object with the following properties:
|
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.
|
80
|
-
|
81
|
-
<a name="ping"></a>
|
82
|
-
#### Ping
|
83
|
-
|
84
|
-
This method can be used for keep-alive. To test the connection with the API:
|
43
|
+
## Country Attributes
|
44
|
+
- `id` (integer) - Country Airtime ID
|
45
|
+
- `name` (string) - The country name
|
46
|
+
- `alpha3` (string) - The alpha3 code of the country
|
47
|
+
- `callingCode` (float) - The international dialing code of the country
|
48
|
+
- `fetchedAt` (string) - The date and time at which the information was fetched
|
49
|
+
|
50
|
+
# Operator
|
85
51
|
|
86
52
|
```ruby
|
87
|
-
irb(main)>
|
88
|
-
irb(main)>
|
89
|
-
=> true
|
53
|
+
irb(main)> operators= T2Airtime::Operator.all(666)
|
54
|
+
irb(main)> T2Airtime::Operator.serialize(operators.data)
|
90
55
|
```
|
91
56
|
|
92
|
-
|
93
|
-
|
57
|
+
## Operator Attributes
|
58
|
+
- `id` (integer) - Operator Airtime ID
|
59
|
+
- `name` (string) - The operator name
|
60
|
+
- `logo` (string) - The URL to the operator logo
|
61
|
+
- `countryId` (float) - The country Airtime ID of the operator
|
62
|
+
- `countryName` (float) - The country name
|
63
|
+
- `countryAlpha3` (float) - The country alpha3
|
64
|
+
- `fetchedAt` (string) - The date and time at which the information was fetched
|
94
65
|
|
95
|
-
|
96
|
-
|
66
|
+
## Operator Relationships
|
67
|
+
- `country.id` (integer) - Country Airtime ID
|
97
68
|
|
98
|
-
|
69
|
+
# Product
|
99
70
|
|
100
71
|
```ruby
|
101
|
-
irb(main)>
|
102
|
-
irb(main)>
|
72
|
+
irb(main)> products= T2Airtime::Product.all(2361)
|
73
|
+
irb(main)> T2Airtime::Product.serialize(products.data)
|
103
74
|
```
|
104
75
|
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
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):
|
76
|
+
## Product Attributes
|
77
|
+
- `id` (integer) - Product Airtime ID
|
78
|
+
- `name` (string) - The product name
|
79
|
+
- `localCurrency` (string) - The currency code of the product
|
80
|
+
- `localCurrencySymbol` (string) - The currency symbol of the product
|
81
|
+
- `currency` (string) - The curreny of your account
|
82
|
+
- `currencySymbol` (string) - The currency symbol of your account
|
83
|
+
- `localPrice` (float) - The face-value of the topup
|
84
|
+
- `retailPrice` (float) - The retail price of the product
|
85
|
+
- `wholesalePrice` (float) - The wholesale price of the product
|
86
|
+
- `countryId` (float) - The country Airtime ID of the product
|
87
|
+
- `countryName` (float) - The country name
|
88
|
+
- `countryAlpha3` (float) - The country alpha3
|
89
|
+
- `operatorId` (string) - The operator Airtime ID of the product
|
90
|
+
- `operatorName` (string) - The operator name
|
91
|
+
- `operatorLogo` (string) - The URL to the operator logo
|
92
|
+
- `fetchedAt` (string) - The date and time at which the information was fetched
|
93
|
+
|
94
|
+
## Product Relationships
|
95
|
+
- `country.id` (integer) - Country Airtime ID
|
96
|
+
- `operator.id` (integer) - Operator Airtime ID
|
97
|
+
|
98
|
+
# Transaction
|
150
99
|
|
151
100
|
```ruby
|
152
|
-
irb(main)>
|
153
|
-
irb(main)>
|
101
|
+
irb(main)> transactions= T2Airtime::API.api.transaction_list
|
102
|
+
irb(main)> T2Airtime::Transaction.serialize(transactions.data)
|
154
103
|
```
|
155
104
|
|
156
|
-
The serializer returns the following JSON representation of a country:
|
157
|
-
|
158
105
|
```ruby
|
159
|
-
|
160
|
-
|
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
|
-
}
|
106
|
+
irb(main)> transaction= T2Airtime::Transaction.get("584171224")
|
107
|
+
irb(main)> T2Airtime::Transaction.serialize_one(transaction.data)
|
177
108
|
```
|
178
109
|
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
110
|
+
## Transaction Attributes
|
111
|
+
- `id` (integer) - Transaction Airtime ID
|
112
|
+
- `msisdn` (string) - The international phone number or name of
|
113
|
+
the user (sender) requesting to credit a phone number
|
114
|
+
- `destinationMsisdn` (string) - Destination MSISDN (usually recipient phone number)
|
115
|
+
- `transactionAuthenticationKey` (string) - Authentication key used during the transaction
|
116
|
+
- `transactionErrorCode` (string) - Error code for the transaction
|
117
|
+
- `transactionErrorTxt` (string) - Description of the error code for the transaction
|
118
|
+
- `referenceOperator` (string) - Reference of the operator (returned only if available)
|
119
|
+
- `actualProductSent` (string) - Returns the value requested to the operator
|
120
|
+
(equals to product_requested in case of successful transaction). It equals to 0 when Top-up
|
121
|
+
failed or in a simulation.
|
122
|
+
- `sms` (string) - The custom message appended to the default notification SMS sent
|
123
|
+
to the recipient
|
124
|
+
- `cid1` (string) - Value of the customized field cid1 sent in the Top-up request
|
125
|
+
- `cid2` (string) - Value of the customized field cid2 sent in the Top-up request
|
126
|
+
- `cid3` (string) - Value of the customized field cid3 sent in the Top-up request
|
127
|
+
- `date` (string) - Date of the transaction (GMT)
|
128
|
+
- `currency` (string) - Currency of the account from which the transaction is requested
|
129
|
+
- `localCurrency` (string) - Currency of the destination country
|
130
|
+
- `pinBased` (string) - Type of product returned ("Yes", default "No" if not set)
|
131
|
+
- `localInfoAmount` (string) - Final amount received by recipient. Indicative value only
|
132
|
+
- `localInfoCurrency` (string) - Local currency in destination
|
133
|
+
- `localInfoValue` (string) - Value of the transaction before tax and service fee in local currency
|
134
|
+
- `errorCode` (string) - Error code for the transaction
|
135
|
+
- `errorTxt` (string) - Description of the error code for the transaction
|
136
|
+
- `productName` (string) - The product name
|
137
|
+
- `productLocalCurrency` (string) - The currency code of the product
|
138
|
+
- `productLocalCurrencySymbol` (string) - The currency symbol of the product
|
139
|
+
- `productCurrency` (string) - The curreny of your account
|
140
|
+
- `productCurrencySymbol` (string) - The currency symbol of your account
|
141
|
+
- `productLocalPrice` (float) - The face-value of the topup
|
142
|
+
- `productRetailPrice` (float) - The retail price of the product
|
143
|
+
- `productWholesalePrice` (float) - The wholesale price of the product
|
144
|
+
- `countryId` (float) - The country Airtime ID of the product
|
145
|
+
- `countryName` (float) - The country name
|
146
|
+
- `countryAlpha3` (float) - The country alpha3
|
147
|
+
- `operatorId` (string) - The operator Airtime ID of the product
|
148
|
+
- `operatorName` (string) - The operator name
|
149
|
+
- `operatorLogo` (string) - The URL to the operator logo
|
150
|
+
- `fetchedAt` (string) - The date and time at which the information was fetched
|
151
|
+
|
152
|
+
## Transaction Relationships
|
153
|
+
- `country.id` (integer) - Country Airtime ID
|
154
|
+
- `operator.id` (integer) - Operator Airtime ID
|
155
|
+
- `product.id` (integer) - Product Airtime ID
|
156
|
+
|
157
|
+
# Topup
|
193
158
|
|
194
159
|
```ruby
|
195
|
-
irb(main)>
|
196
|
-
irb(main)>
|
160
|
+
irb(main)> topup= T2Airtime::API.api.topup params
|
161
|
+
irb(main)> T2Airtime::Topup.serialize(topup.data)
|
197
162
|
```
|
198
163
|
|
199
|
-
|
164
|
+
## Topup Attributes
|
165
|
+
- `balance` (string) - For main account: returns the account’s remaining
|
166
|
+
balance. For sub-account: returns the account’s remaining
|
167
|
+
limit balance of the day if a daily limit is fixed. Else,
|
168
|
+
returns the account remaining balance.
|
169
|
+
- `balanceDisplay` (string) - The `balance` value formatted in the currency of your account
|
170
|
+
- `transactionId` (integer) - Airtime ID of the transaction.
|
171
|
+
- `msisdn` (string) - The international phone number or name of
|
172
|
+
the user (sender) requesting to credit a phone number
|
173
|
+
- `destinationMsisdn` (string) - Destination MSISDN (usually recipient phone number)
|
174
|
+
- `transactionAuthenticationKey` (string) - Authentication key used during the transaction
|
175
|
+
- `transactionErrorCode` (string) - Error code for the transaction
|
176
|
+
- `transactionErrorTxt` (string) - Description of the error code for the transaction
|
177
|
+
- `referenceOperator` (string) - Reference of the operator (returned only if available)
|
178
|
+
- `actualProductSent` (string) - Returns the value requested to the operator
|
179
|
+
(equals to product_requested in case of successful transaction). It equals to 0 when Top-up
|
180
|
+
failed or in a simulation.
|
181
|
+
- `sms` (string) - The custom message appended to the default notification SMS sent
|
182
|
+
to the recipient
|
183
|
+
- `smsSent` (string) - Defines the status of the notification SMS sent to the
|
184
|
+
recipient. Returns `yes` only if the SMS has been successfully sent.
|
185
|
+
- `smsText` (string) - The custom message appended to the default
|
186
|
+
notification SMS sent to the sender.
|
187
|
+
- `cid1` (string) - Value of the customized field cid1 sent in the Top-up request
|
188
|
+
- `cid2` (string) - Value of the customized field cid2 sent in the Top-up request
|
189
|
+
- `cid3` (string) - Value of the customized field cid3 sent in the Top-up request
|
190
|
+
- `currency` (string) - Currency of the account from which the transaction is requested
|
191
|
+
- `localCurrency` (string) - Currency of the destination country
|
192
|
+
- `productName` (string) - The product name
|
193
|
+
- `productLocalCurrency` (string) - The currency code of the product
|
194
|
+
- `productLocalCurrencySymbol` (string) - The currency symbol of the product
|
195
|
+
- `productCurrency` (string) - The curreny of your account
|
196
|
+
- `productCurrencySymbol` (string) - The currency symbol of your account
|
197
|
+
- `productLocalPrice` (float) - The face-value of the topup
|
198
|
+
- `productRetailPrice` (float) - The retail price of the product
|
199
|
+
- `productWholesalePrice` (float) - The wholesale price of the product
|
200
|
+
- `countryId` (float) - The country Airtime ID of the product
|
201
|
+
- `countryName` (float) - The country name
|
202
|
+
- `countryAlpha3` (float) - The country alpha3
|
203
|
+
- `operatorId` (string) - The operator Airtime ID of the product
|
204
|
+
- `operatorName` (string) - The operator name
|
205
|
+
- `operatorLogo` (string) - The URL to the operator logo
|
206
|
+
- `executedAt` (string) - The date and time at which the information was fetched
|
207
|
+
|
208
|
+
# Msisdn
|
200
209
|
|
201
210
|
```ruby
|
202
|
-
|
203
|
-
|
204
|
-
|
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
|
244
|
-
|
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)`.
|
211
|
+
irb(main)> msisdn= T2Airtime::Msisdn.info("+628123456710")
|
212
|
+
irb(main)> T2Airtime::Msisdn.serialize(msisdn.data)
|
213
|
+
```
|
247
214
|
|
248
|
-
|
215
|
+
## Msisdn Attributes
|
216
|
+
- `msisdn` (string) - The international mobile number
|
217
|
+
- `country` (string) - The country of the number
|
218
|
+
- `countryId` (string) - Country Airtime ID
|
219
|
+
- `operator` (string) - The operator of the number
|
220
|
+
- `operatorId` (string) - Operator Airtime ID
|
221
|
+
- `fetchedAt` (string) - The date and time at which the information was fetched
|
249
222
|
|
250
|
-
|
251
|
-
|
252
|
-
irb(main)> products= T2Airtime::Product.serialize(response.data)
|
253
|
-
```
|
223
|
+
## Accounts [/accounts]
|
224
|
+
Cached for 1 hour.
|
254
225
|
|
255
|
-
|
226
|
+
### Show Account [GET]
|
227
|
+
+ Response 200 (application/json)
|
256
228
|
|
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
229
|
{
|
284
|
-
"type": "
|
285
|
-
"id":
|
230
|
+
"type": "accounts",
|
231
|
+
"id": "my-t2-shop-account",
|
286
232
|
"attributes": {
|
287
|
-
"
|
288
|
-
"
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
"attributes": { "name": OPERATOR_NAME },
|
295
|
-
"links": { "logo": OPERATOR_LOGO_URL }
|
233
|
+
"type": "Master",
|
234
|
+
"name": "my-t2-shop-account-name",
|
235
|
+
"currency": "USD",
|
236
|
+
"balance": 16.2,
|
237
|
+
"wallet": 16.2,
|
238
|
+
"fetchedAt": "2017-09-17T13:48:34Z"
|
239
|
+
}
|
296
240
|
}
|
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
241
|
|
242
|
+
## Countries [/countries]
|
243
|
+
Cached for 1 hour.
|
328
244
|
|
329
|
-
|
330
|
-
#### Transaction Information
|
245
|
+
### List all Countries [GET]
|
331
246
|
|
332
|
-
|
333
|
-
To format the response as JSON-API you can call `T2Airtime::Transaction.serialize_one(data)`.
|
247
|
+
+ Response 200 (application/json)
|
334
248
|
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
249
|
+
[
|
250
|
+
{
|
251
|
+
"type": "countries"
|
252
|
+
"id": 661
|
253
|
+
"attributes": {
|
254
|
+
"name": "Afghanistan"
|
255
|
+
"alpha3": "AFG"
|
256
|
+
"callingCode": "93"
|
257
|
+
"fetchedAt": "2017-09-17T13:58:46Z"
|
258
|
+
}
|
259
|
+
}
|
260
|
+
...
|
261
|
+
]
|
262
|
+
|
263
|
+
## Operators [/operators]
|
264
|
+
|
265
|
+
### List all Operators [GET]
|
266
|
+
Cached for 1 hour.
|
267
|
+
|
268
|
+
+ Response 200 (application/json)
|
269
|
+
|
270
|
+
[
|
271
|
+
{
|
272
|
+
"type": "operators"
|
273
|
+
"id": 2361
|
274
|
+
"attributes": {
|
275
|
+
"name": "Movicel Angola USD"
|
276
|
+
"logo": "https://operator-logo.transferto.com/logo-2361-1.png"
|
277
|
+
"countryId": 666
|
278
|
+
"countryName": "Angola"
|
279
|
+
"countryAlpha3": "AGO"
|
280
|
+
"fetchedAt": "2017-09-17T16:44:08Z"
|
281
|
+
},
|
282
|
+
"relationships": {
|
283
|
+
"country": {
|
284
|
+
"data":{
|
285
|
+
"type": "countries"
|
286
|
+
"id": 666
|
287
|
+
}
|
288
|
+
}
|
289
|
+
}
|
290
|
+
},
|
291
|
+
...
|
292
|
+
]
|
293
|
+
|
294
|
+
## Products [/products]
|
295
|
+
Cached for 1 hour.
|
296
|
+
|
297
|
+
### List all Products [GET]
|
298
|
+
|
299
|
+
+ Response 200 (application/json)
|
300
|
+
|
301
|
+
[
|
302
|
+
{
|
303
|
+
"type": "products"
|
304
|
+
"id": 1
|
305
|
+
"attributes": {
|
306
|
+
"name": "$1.00"
|
307
|
+
"localCurrency": "USD"
|
308
|
+
"localCurrencySymbol": "$"
|
309
|
+
"currency": "USD"
|
310
|
+
"currencySymbol": "$"
|
311
|
+
"localPrice": 1.0
|
312
|
+
"retailPrice": 1.1
|
313
|
+
"wholesalePrice": 1.03
|
314
|
+
"countryId": 666
|
315
|
+
"countryName": "Angola"
|
316
|
+
"countryAlpha3": "AGO"
|
317
|
+
"operatorId": 2361
|
318
|
+
"operatorName": "Movicel Angola USD"
|
319
|
+
"operatorLogo": "https://operator-logo.transferto.com/logo-2361-1.png"
|
320
|
+
"fetchedAt": "2017-09-17T16:48:20Z"
|
321
|
+
},
|
322
|
+
"relationships": {
|
323
|
+
"country": {
|
324
|
+
"data": {
|
325
|
+
"type": "countries"
|
326
|
+
"id": 666
|
327
|
+
}
|
328
|
+
},
|
329
|
+
"operator": {
|
330
|
+
"data": {
|
331
|
+
"type": "operators"
|
332
|
+
"id": 2361
|
333
|
+
}
|
334
|
+
}
|
335
|
+
},
|
336
|
+
...
|
337
|
+
]
|
338
|
+
|
339
|
+
## Transactions [/transactions]
|
340
|
+
|
341
|
+
### List all Transactions [GET]
|
342
|
+
|
343
|
+
+ Response 200 (application/json)
|
344
|
+
|
345
|
+
[
|
346
|
+
{
|
347
|
+
"type": "transactions"
|
348
|
+
"id": 584176053
|
349
|
+
"attributes": {
|
350
|
+
"msisdn": "+393800000000"
|
351
|
+
"destinationMsisdn": "393800000001"
|
352
|
+
"transactionAuthenticationKey": "1505553036"
|
353
|
+
"transactionErrorCode": 0
|
354
|
+
"transactionErrorTxt": "Transaction successful"
|
355
|
+
"referenceOperator": nil
|
356
|
+
"actualProductSent": "5"
|
357
|
+
"sms": nil
|
358
|
+
"smsText": "Test"
|
359
|
+
"cid1": "Cid1"
|
360
|
+
"cid2": "Cid2"
|
361
|
+
"cid3": "Cid3"
|
362
|
+
"date": "2017-09-16 09:10:39"
|
363
|
+
"currency": "USD"
|
364
|
+
"localCurrency": "EUR"
|
365
|
+
"pinBased": "no"
|
366
|
+
"localInfoAmount": "5.00"
|
367
|
+
"localInfoCurrency": "EUR"
|
368
|
+
"localInfoValue": "5.00"
|
369
|
+
"errorCode": 0
|
370
|
+
"errorTxt": "Transaction successful"
|
371
|
+
"countryId": 772
|
372
|
+
"countryName": "Italy"
|
373
|
+
"countryAlpha3": "ITA"
|
374
|
+
"operatorId": 734
|
375
|
+
"operatorName": "Wind Italy"
|
376
|
+
"operatorLogo": "https://operator-logo.transferto.com/logo-734-1.png"
|
377
|
+
"productName": "€5.00"
|
378
|
+
"productLocalCurrency": "EUR"
|
379
|
+
"productLocalCurrencySymbol": "€"
|
380
|
+
"productCurrency": "USD"
|
381
|
+
"productCurrencySymbol": "$"
|
382
|
+
"productLocalPrice": 5.0
|
383
|
+
"productRetailPrice": 7.5
|
384
|
+
"productWholesalePrice": 6.9
|
385
|
+
"fetchedAt": "2017-09-17T16:56:29Z"
|
386
|
+
},
|
387
|
+
"relationships": {
|
388
|
+
"country": {
|
389
|
+
"data": {
|
390
|
+
"type": "countries"
|
391
|
+
"id": 772
|
392
|
+
}
|
393
|
+
},
|
394
|
+
"operator": {
|
395
|
+
"data": {
|
396
|
+
"type": "operators"
|
397
|
+
"id": 734
|
398
|
+
}
|
399
|
+
},
|
400
|
+
"product": {
|
401
|
+
"data": {
|
402
|
+
"type": "products"
|
403
|
+
"id": 5
|
404
|
+
}
|
405
|
+
}
|
406
|
+
}
|
407
|
+
},
|
408
|
+
...
|
409
|
+
]
|
410
|
+
|
411
|
+
### Show Transactions [GET]
|
412
|
+
|
413
|
+
+ Response 200 (application/json)
|
414
|
+
|
415
|
+
{
|
416
|
+
"type": "transactions"
|
417
|
+
"id": 584176053
|
418
|
+
"attributes": {
|
419
|
+
"msisdn": "+393800000000"
|
420
|
+
"destinationMsisdn": "393800000001"
|
421
|
+
"transactionAuthenticationKey": "1505553036"
|
422
|
+
"transactionErrorCode": 0
|
423
|
+
"transactionErrorTxt": "Transaction successful"
|
424
|
+
"referenceOperator": nil
|
425
|
+
"actualProductSent": "5"
|
426
|
+
"sms": nil
|
427
|
+
"smsText": "Test"
|
428
|
+
"cid1": "Cid1"
|
429
|
+
"cid2": "Cid2"
|
430
|
+
"cid3": "Cid3"
|
431
|
+
"date": "2017-09-16 09:10:39"
|
432
|
+
"currency": "USD"
|
433
|
+
"localCurrency": "EUR"
|
434
|
+
"pinBased": "no"
|
435
|
+
"localInfoAmount": "5.00"
|
436
|
+
"localInfoCurrency": "EUR"
|
437
|
+
"localInfoValue": "5.00"
|
438
|
+
"errorCode": 0
|
439
|
+
"errorTxt": "Transaction successful"
|
440
|
+
"countryId": 772
|
441
|
+
"countryName": "Italy"
|
442
|
+
"countryAlpha3": "ITA"
|
443
|
+
"operatorId": 734
|
444
|
+
"operatorName": "Wind Italy"
|
445
|
+
"operatorLogo": "https://operator-logo.transferto.com/logo-734-1.png"
|
446
|
+
"productName": "€5.00"
|
447
|
+
"productLocalCurrency": "EUR"
|
448
|
+
"productLocalCurrencySymbol": "€"
|
449
|
+
"productCurrency": "USD"
|
450
|
+
"productCurrencySymbol": "$"
|
451
|
+
"productLocalPrice": 5.0
|
452
|
+
"productRetailPrice": 7.5
|
453
|
+
"productWholesalePrice": 6.9
|
454
|
+
"fetchedAt": "2017-09-17T16:56:29Z"
|
455
|
+
},
|
456
|
+
"relationships": {
|
457
|
+
"country": {
|
458
|
+
"data": {
|
459
|
+
"type": "countries"
|
460
|
+
"id": 772
|
461
|
+
}
|
462
|
+
},
|
463
|
+
"operator": {
|
464
|
+
"data": {
|
465
|
+
"type": "operators"
|
466
|
+
"id": 734
|
467
|
+
}
|
468
|
+
},
|
469
|
+
"product": {
|
470
|
+
"data": {
|
471
|
+
"type": "products"
|
472
|
+
"id": 5
|
473
|
+
}
|
474
|
+
}
|
475
|
+
}
|
476
|
+
}
|
477
|
+
|
478
|
+
### Create (Reserve) Transaction [POST]
|
479
|
+
|
480
|
+
+ Response 200 (application/json)
|
343
481
|
|
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
482
|
{
|
413
|
-
type: "
|
414
|
-
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
|
-
}
|
483
|
+
"type": "transactions"
|
484
|
+
"id": 584176053
|
428
485
|
}
|
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
|
486
|
+
|
487
|
+
## Number Information [/msisdn_info]
|
488
|
+
Cached for 24 hours.
|
451
489
|
|
452
|
-
|
490
|
+
### Show Number Information [GET]
|
453
491
|
|
454
|
-
|
492
|
+
+ Response 200 (application/json)
|
455
493
|
|
456
|
-
|
494
|
+
{
|
495
|
+
"type": "msisdn"
|
496
|
+
"msisdn": "628123456710"
|
497
|
+
"country": "Indonesia"
|
498
|
+
"countryId": "767"
|
499
|
+
"operator": "AAA-TESTING Indonesia USD"
|
500
|
+
"operatorId": "1562"
|
501
|
+
"fetchedAt": "2017-09-17T17:05:08Z"
|
502
|
+
}
|
457
503
|
|
458
|
-
##
|
504
|
+
## Topup [/topup]
|
459
505
|
|
460
|
-
|
506
|
+
### Create Topup [POST]
|
461
507
|
|
462
|
-
|
508
|
+
+ Response 200 (application/json)
|
463
509
|
|
464
|
-
|
510
|
+
{
|
511
|
+
"type": "msisdn"
|
512
|
+
"msisdn": "628123456710"
|
513
|
+
"country": "Indonesia"
|
514
|
+
"countryId": "767"
|
515
|
+
"operator": "AAA-TESTING Indonesia USD"
|
516
|
+
"operatorId": "1562"
|
517
|
+
"fetchedAt": "2017-09-17T17:05:08Z"
|
518
|
+
}
|