t2_airtime 0.2.3 → 0.2.4
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/lib/t2_airtime/serializer.rb +12 -23
- data/lib/t2_airtime/util.rb +0 -4
- data/lib/t2_airtime/version.rb +1 -1
- data/release +1 -1
- data/t2_airtime.gemspec +0 -1
- metadata +1 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cf789e78f7d18fcb79de60b5966cd044402ed179
|
4
|
+
data.tar.gz: b016dec47ef1358e355c4a206e279087cdf7152b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c8b121f72cf0e91d277b95c14b884b08054d1c5c0f25833aa6277c928637dde4a4ee35d49dc363145ece16dc2b0462d5b92051c5e60812b46d28387319c1c13e
|
7
|
+
data.tar.gz: 7ad7d4d131a4c70aa0b081cf6e9cfe345e514fee312b9939504330a8c1e20135cf4f3fbfed03389fd176df25be16cf3b2774164a387c41f2989c3044f7d93a34
|
@@ -12,13 +12,11 @@ module T2Airtime
|
|
12
12
|
type: "accounts",
|
13
13
|
id: T2Airtime::API.api.user,
|
14
14
|
attributes: {
|
15
|
-
type: data[:type],
|
16
|
-
name: data[:name],
|
17
|
-
currency: data[:currency],
|
18
|
-
balance: Float(data[:balance]),
|
19
|
-
wallet: Float(data[:wallet]),
|
20
|
-
"balance-display": T2Airtime::Util.format_price(data[:balance], data[:currency]),
|
21
|
-
"wallet-display": T2Airtime::Util.format_price(data[:wallet], data[:currency]),
|
15
|
+
"type": data[:type],
|
16
|
+
"name": data[:name],
|
17
|
+
"currency": data[:currency],
|
18
|
+
"balance": Float(data[:balance]),
|
19
|
+
"wallet": Float(data[:wallet]),
|
22
20
|
"fetched-at": T2Airtime::Util.format_time(ts)
|
23
21
|
}
|
24
22
|
}.as_json
|
@@ -154,23 +152,19 @@ module T2Airtime
|
|
154
152
|
end
|
155
153
|
|
156
154
|
def self.serialize(data, ts="#{Time.zone.now}", qty=nil)
|
157
|
-
return [] if data[:product_list].nil?
|
158
|
-
currency = data[:destination_currency]
|
159
|
-
retail_prices = data[:retail_price_list].split(",")
|
160
|
-
wholesale_prices = data[:wholesale_price_list].split(",")
|
155
|
+
return [] if data[:product_list].nil?
|
161
156
|
ids = data[:product_list].split(",")
|
157
|
+
retail_prices = data[:retail_price_list].split(",")
|
158
|
+
wholesale_prices = data[:wholesale_price_list].split(",")
|
162
159
|
ids.take(qty.nil? ? ids.count : qty).each_with_index.map{|id, n| {
|
163
160
|
type: "products",
|
164
161
|
id: Integer(id),
|
165
162
|
attributes: {
|
166
|
-
"name": "#{id}#{
|
167
|
-
"currency":
|
163
|
+
"name": "#{id}#{data[:destination_currency]}",
|
164
|
+
"currency": data[:destination_currency],
|
168
165
|
"local-price": Float(id),
|
169
166
|
"retail-price": Float(retail_prices[n]),
|
170
167
|
"wholesale-price": Float(wholesale_prices[n]),
|
171
|
-
"local-price-display": T2Airtime::Util.format_price(id, currency),
|
172
|
-
"retail-price-display": T2Airtime::Util.format_price(retail_prices[n]),
|
173
|
-
"wholesale-price-display": T2Airtime::Util.format_price(wholesale_prices[n]),
|
174
168
|
"fetched-at": T2Airtime::Util.format_time(ts)
|
175
169
|
},
|
176
170
|
relationships: {
|
@@ -242,9 +236,7 @@ module T2Airtime
|
|
242
236
|
"transaction-error-code": Integer(data[:transaction_error_code]),
|
243
237
|
"transaction-error-txt": data[:transaction_error_txt],
|
244
238
|
"reference-operator": data[:reference_operator],
|
245
|
-
"product-requested-display": T2Airtime::Util.format_price(data[:product_requested], data[:destination_currency]),
|
246
239
|
"actual-product-sent": data[:actual_product_sent],
|
247
|
-
"actual-product-sent-display": T2Airtime::Util.format_price(data[:actual_product_sent], data[:destination_currency]),
|
248
240
|
"sms": data[:sms],
|
249
241
|
"cid1": data[:cid1],
|
250
242
|
"cid2": data[:cid2],
|
@@ -254,8 +246,8 @@ module T2Airtime
|
|
254
246
|
"destination-currency": data[:destination_currency],
|
255
247
|
"pin-based": data[:pin_based],
|
256
248
|
"local-info-amount": data[:local_info_amount],
|
257
|
-
"local-info-amount-display": T2Airtime::Util.format_price(data[:local_info_amount], data[:local_info_currency]),
|
258
249
|
"local-info-currency": data[:local_info_currency],
|
250
|
+
"local-info-value": data[:local_info_value],
|
259
251
|
"error-code": data[:error_code],
|
260
252
|
"error-txt": data[:error_txt],
|
261
253
|
"fetched-at": T2Airtime::Util.format_time(ts)
|
@@ -306,11 +298,8 @@ module T2Airtime
|
|
306
298
|
"name": "#{data[:product_requested]}#{data[:destination_currency]}",
|
307
299
|
"currency": data[:destination_currency],
|
308
300
|
"wholesale-price": data[:wholesale_price],
|
309
|
-
"wholesale-price-display": T2Airtime::Util.format_price(data[:wholesale_price], data[:originating_currency]),
|
310
301
|
"retail-price": data[:retail_price],
|
311
|
-
"
|
312
|
-
"local-price": data[:local_info_value],
|
313
|
-
"local-price-display": T2Airtime::Util.format_price(data[:local_info_value], data[:local_info_currency])
|
302
|
+
"local-price": Float(data[:product_requested])
|
314
303
|
}
|
315
304
|
}
|
316
305
|
]
|
data/lib/t2_airtime/util.rb
CHANGED
@@ -17,10 +17,6 @@ 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'] || "USD"))
|
21
|
-
Money.new(Float(price)*100, currency).format
|
22
|
-
end
|
23
|
-
|
24
20
|
def self.format_time(timestr)
|
25
21
|
Time.zone.parse(timestr).to_datetime.in_time_zone('UTC').iso8601
|
26
22
|
end
|
data/lib/t2_airtime/version.rb
CHANGED
data/release
CHANGED
data/t2_airtime.gemspec
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: t2_airtime
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- matteolc
|
@@ -114,20 +114,6 @@ dependencies:
|
|
114
114
|
- - '='
|
115
115
|
- !ruby/object:Gem::Version
|
116
116
|
version: 2.1.2
|
117
|
-
- !ruby/object:Gem::Dependency
|
118
|
-
name: money
|
119
|
-
requirement: !ruby/object:Gem::Requirement
|
120
|
-
requirements:
|
121
|
-
- - '='
|
122
|
-
- !ruby/object:Gem::Version
|
123
|
-
version: 6.9.0
|
124
|
-
type: :runtime
|
125
|
-
prerelease: false
|
126
|
-
version_requirements: !ruby/object:Gem::Requirement
|
127
|
-
requirements:
|
128
|
-
- - '='
|
129
|
-
- !ruby/object:Gem::Version
|
130
|
-
version: 6.9.0
|
131
117
|
description: Wrapper methods to interface with [TransferTo](https://www.transfer-to.com/home)
|
132
118
|
Airtime API
|
133
119
|
email:
|