t2_airtime 0.2.3 → 0.2.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bc3d42284a0dc27d0322214bcde7d80ccb02e20d
4
- data.tar.gz: a15023d4e9449635920baa19c4a4405d9984483b
3
+ metadata.gz: cf789e78f7d18fcb79de60b5966cd044402ed179
4
+ data.tar.gz: b016dec47ef1358e355c4a206e279087cdf7152b
5
5
  SHA512:
6
- metadata.gz: 1c78fbe2336823e689ef5492e9db4babbb550639957692ff5a38fa751a3fd924441bf20031b493fea81baea6ea8bad1df371a0de6279efda29c7076f3f13b885
7
- data.tar.gz: 7148dfa87929738484e798dcca447ccd0c8f68dca894226dc7d2aaa84714060c139c330499ed24992e3c2cde3c169703ca81474ad44db2f2eff5574b88392e4f
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}#{currency}",
167
- "currency": 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
- "retail-price-display": T2Airtime::Util.format_price(data[:retail_price], data[:originating_currency]),
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
  ]
@@ -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
@@ -1,3 +1,3 @@
1
1
  module T2Airtime
2
- VERSION = "0.2.3"
2
+ VERSION = "0.2.4"
3
3
  end
data/release CHANGED
@@ -2,6 +2,6 @@
2
2
  set -e
3
3
 
4
4
  git add .
5
- git commit -am "Bump to v${0}"
5
+ git commit -am "Bump to v${1}"
6
6
  git push origin master
7
7
  gem release
data/t2_airtime.gemspec CHANGED
@@ -29,6 +29,5 @@ Gem::Specification.new do |spec|
29
29
  spec.add_runtime_dependency 'dotenv-rails', '~> 2.2', '>= 2.2.1'
30
30
  spec.add_dependency "faraday", "0.9.1"
31
31
  spec.add_dependency "countries", "2.1.2"
32
- spec.add_dependency "money", "6.9.0"
33
32
 
34
33
  end
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.3
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: