tangocard 4.1.0 → 5.0.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/README.md +2 -2
- data/lib/tangocard.rb +1 -0
- data/lib/tangocard/account.rb +3 -45
- data/lib/tangocard/account_create_failed_exception.rb +2 -2
- data/lib/tangocard/account_delete_credit_card_failed_exception.rb +1 -1
- data/lib/tangocard/account_fund_failed_exception.rb +1 -1
- data/lib/tangocard/account_not_found_exception.rb +2 -2
- data/lib/tangocard/account_register_credit_card_failed_exception.rb +1 -1
- data/lib/tangocard/brand.rb +13 -8
- data/lib/tangocard/exchange_rate.rb +86 -0
- data/lib/tangocard/order.rb +21 -16
- data/lib/tangocard/order_create_failed_exception.rb +2 -2
- data/lib/tangocard/order_not_found_exception.rb +2 -2
- data/lib/tangocard/raas.rb +9 -22
- data/lib/tangocard/reward.rb +18 -18
- data/lib/tangocard/version.rb +1 -1
- metadata +7 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 49c965036413c7a215002d6607a6d620196f1ed7
|
4
|
+
data.tar.gz: 98763bca37c622a6fa2c8d8f3a55ec0e898c9ab3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f3faadaa33b916d60448dd6e322a20afeb6dc76cf69dc1e39e1e2a58734803aa4b7c37bb9672257cfe829e0e126d38c391f406af8a47bf0600bd49ba257fcabb
|
7
|
+
data.tar.gz: 0d684e0d75017033b467a5b07d9385e68829c2d007b68e0240d2109f644daf966059d18b6c2c234d6b3d0e39c7bf812a5379ac468c4ac051d3736eced76543a1
|
data/README.md
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
|
4
4
|
Ruby Wrapper for Tango Card RaaS API.
|
5
5
|
|
6
|
-
Tango Card provides a RaaS API for developers (https://
|
6
|
+
Tango Card provides a RaaS API for developers (https://www.tangocard.com/docs/raas-api/). This gem provides commonsense Ruby
|
7
7
|
objects to wrap the JSON endpoints of the RaaS API.
|
8
8
|
|
9
9
|
## Information
|
@@ -50,7 +50,7 @@ There are also three optional configuration parameters:
|
|
50
50
|
This gem provides two tools:
|
51
51
|
|
52
52
|
1. A simple wrapper for the Tango Card RaaS API, consisting of two classes: `Tangocard::Raas` and `Tangocard::Response`.
|
53
|
-
2. Models for each of the Tango Card objects: `Tangocard::Account`, `Tangocard::Brand`, `Tangocard::Reward`, and `Tangocard::
|
53
|
+
2. Models for each of the Tango Card objects: `Tangocard::Account`, `Tangocard::Brand`, `Tangocard::Reward`, `Tangocard::Order` and `Tangocard::ExchangeRate`. These provide a greater level of abstraction and ease of use.
|
54
54
|
|
55
55
|
## Notes and Credits
|
56
56
|
|
data/lib/tangocard.rb
CHANGED
data/lib/tangocard/account.rb
CHANGED
@@ -80,13 +80,13 @@ class Tangocard::Account
|
|
80
80
|
# Arguments:
|
81
81
|
# client_ip: (String)
|
82
82
|
# credit_card: (Hash) - see
|
83
|
-
# https://
|
83
|
+
# https://www.tangocard.com/docs/raas-api/#create-cc-registration for details
|
84
84
|
#
|
85
85
|
# Credit Card Hash Example:
|
86
86
|
#
|
87
87
|
# {
|
88
88
|
# 'number' => '4111111111111111',
|
89
|
-
# 'expiration' => '01
|
89
|
+
# 'expiration' => '2017-01',
|
90
90
|
# 'security_code' => '123',
|
91
91
|
# 'billing_address' => {
|
92
92
|
# 'f_name' => 'Jane',
|
@@ -112,7 +112,7 @@ class Tangocard::Account
|
|
112
112
|
@cc_token = response.parsed_response['cc_token']
|
113
113
|
response.parsed_response
|
114
114
|
else
|
115
|
-
raise Tangocard::AccountRegisterCreditCardFailedException, "#{response.denial_message}"
|
115
|
+
raise Tangocard::AccountRegisterCreditCardFailedException, "#{response.error_message} #{response.denial_message} #{response.invalid_inputs}"
|
116
116
|
end
|
117
117
|
end
|
118
118
|
|
@@ -158,48 +158,6 @@ class Tangocard::Account
|
|
158
158
|
end
|
159
159
|
end
|
160
160
|
|
161
|
-
# (DEPRECATED)
|
162
|
-
# Add funds to the account.
|
163
|
-
#
|
164
|
-
# Example:
|
165
|
-
# >> account.fund!(10000, '128.128.128.128', Hash (see example below))
|
166
|
-
# => #<Tangocard::Account:0x007f9a6fec0138 @customer="bonusly", @email="dev@bonus.ly", @identifier="test", @available_balance=0>
|
167
|
-
#
|
168
|
-
# Arguments:
|
169
|
-
# amount: (Integer)
|
170
|
-
# client_ip: (String)
|
171
|
-
# credit_card: (Hash) - see https://github.com/tangocarddev/RaaS/blob/master/fund_create.schema.json for details
|
172
|
-
#
|
173
|
-
# Credit Card Hash Example:
|
174
|
-
#
|
175
|
-
# {
|
176
|
-
# 'number' => '4111111111111111',
|
177
|
-
# 'expiration' => '01/17',
|
178
|
-
# 'security_code' => '123',
|
179
|
-
# 'billing_address' => {
|
180
|
-
# 'f_name' => 'Jane',
|
181
|
-
# 'l_name' => 'User',
|
182
|
-
# 'address' => '123 Main Street',
|
183
|
-
# 'city' => 'Anytown',
|
184
|
-
# 'state' => 'NY',
|
185
|
-
# 'zip' => '11222',
|
186
|
-
# 'country' => 'USA',
|
187
|
-
# 'email' => 'jane@company.com'
|
188
|
-
# }
|
189
|
-
# }
|
190
|
-
def fund!(amount, client_ip, credit_card)
|
191
|
-
warn "[DEPRECATION] `fund!` is deprecated. Please use `cc_fund` instead. See https://github.com/tangocarddev/RaaS#fund-a-platforms-account"
|
192
|
-
|
193
|
-
params = {
|
194
|
-
'amount' => amount,
|
195
|
-
'client_ip' => client_ip,
|
196
|
-
'credit_card' => credit_card,
|
197
|
-
'customer' => customer,
|
198
|
-
'account_identifier' => identifier
|
199
|
-
}
|
200
|
-
Tangocard::Raas.fund_account(params)
|
201
|
-
end
|
202
|
-
|
203
161
|
# Delete a credit card from an account
|
204
162
|
# Raises Tangocard::AccountDeleteCreditCardFailedException failure.
|
205
163
|
# Example:
|
@@ -1,3 +1,3 @@
|
|
1
|
-
class Tangocard::AccountCreateFailedException <
|
1
|
+
class Tangocard::AccountCreateFailedException < StandardError
|
2
2
|
|
3
|
-
end
|
3
|
+
end
|
@@ -1,3 +1,3 @@
|
|
1
|
-
class Tangocard::AccountNotFoundException <
|
1
|
+
class Tangocard::AccountNotFoundException < StandardError
|
2
2
|
|
3
|
-
end
|
3
|
+
end
|
data/lib/tangocard/brand.rb
CHANGED
@@ -29,11 +29,12 @@ class Tangocard::Brand
|
|
29
29
|
#
|
30
30
|
# Example:
|
31
31
|
# >> Tangocard::Brand.find("Amazon.com")
|
32
|
-
# => #<Tangocard::Brand:
|
33
|
-
# @image_url="
|
34
|
-
# @rewards=[#<Tangocard::Reward:
|
35
|
-
# @sku="AMZN-E-V-STD", @
|
36
|
-
# @max_price=100000
|
32
|
+
# => #<Tangocard::Brand:0x007f96a9cbe980 @description="Amazon.com",
|
33
|
+
# @image_url="https://dwwvg90koz96l.cloudfront.net/graphics/item-images/amazon-gift-card.png",
|
34
|
+
# @rewards=[#<Tangocard::Reward:0x007f96a9cbe930 @type="reward",
|
35
|
+
# @description="Amazon.com Gift Card (Custom)", @sku="AMZN-E-V-STD", @is_variable=true,
|
36
|
+
# @denomination=0, @min_price=1, @max_price=100000, @currency_code="USD", @available=true,
|
37
|
+
# @countries=["US"]>]>
|
37
38
|
#
|
38
39
|
# Arguments:
|
39
40
|
# brand_name: (String)
|
@@ -64,8 +65,12 @@ class Tangocard::Brand
|
|
64
65
|
#
|
65
66
|
# Example:
|
66
67
|
# >> itunes_brand.purchasable_rewards(1000)
|
67
|
-
# => [#<Tangocard::Reward:
|
68
|
-
# @
|
68
|
+
# => [#<Tangocard::Reward:0x007f96aa3b4dc0 @type="reward", @description="iTunes Code USD $5",
|
69
|
+
# @sku="APPL-E-500-STD", @is_variable=false, @denomination=500, @min_price=0, @max_price=0,
|
70
|
+
# @currency_code="USD", @available=true, @countries=["US"]>,
|
71
|
+
# #<Tangocard::Reward:0x007f96aa3b4d98 @type="reward", @description="iTunes Code USD $10",
|
72
|
+
# @sku="APPL-E-1000-STD", @is_variable=false, @denomination=1000, @min_price=0, @max_price=0,
|
73
|
+
# @currency_code="USD", @available=true, @countries=["US"]>]
|
69
74
|
#
|
70
75
|
# Arguments:
|
71
76
|
# balance_in_cents: (Integer)
|
@@ -98,4 +103,4 @@ class Tangocard::Brand
|
|
98
103
|
def variable_price?
|
99
104
|
rewards.select{|r| r.variable_price? }.any?
|
100
105
|
end
|
101
|
-
end
|
106
|
+
end
|
@@ -0,0 +1,86 @@
|
|
1
|
+
class Tangocard::ExchangeRate
|
2
|
+
attr_reader :currency_code, :rate
|
3
|
+
|
4
|
+
# Clear all cached responses. Next request for exchange rate info will pull fresh from the Tango Card API.
|
5
|
+
#
|
6
|
+
# Example:
|
7
|
+
# >> Tangocard::ExchangeRate.clear_cache!
|
8
|
+
# => true
|
9
|
+
#
|
10
|
+
# Arguments:
|
11
|
+
# none
|
12
|
+
def self.clear_cache!
|
13
|
+
Tangocard::Raas.clear_cache!
|
14
|
+
end
|
15
|
+
|
16
|
+
# Return current currency exchange rate timestamp.
|
17
|
+
#
|
18
|
+
# Example:
|
19
|
+
# >> Tangocard::ExchangeRate.timestamp
|
20
|
+
# => 1456956187
|
21
|
+
#
|
22
|
+
# Arguments:
|
23
|
+
# none
|
24
|
+
def self.timestamp
|
25
|
+
Tangocard::Raas.rewards_index.parsed_response['xrates']['timestamp']
|
26
|
+
end
|
27
|
+
|
28
|
+
# Return an array of all currency exchange rates.
|
29
|
+
#
|
30
|
+
# Example:
|
31
|
+
# >> Tangocard::ExchangeRate.all
|
32
|
+
# => [#<Tangocard::ExchangeRate:0x007ff31ab927a0 @currency_code="USD", @rate="1.00000">,
|
33
|
+
# #<Tangocard::ExchangeRate:0x007ff31ab92750 @currency_code="JPY", @rate="123.44700">, ...]
|
34
|
+
#
|
35
|
+
# Arguments:
|
36
|
+
# none
|
37
|
+
def self.all
|
38
|
+
Tangocard::Raas.rewards_index.parsed_response['xrates']['rates'].map do |currency_code, rate|
|
39
|
+
Tangocard::ExchangeRate.new(currency_code, rate)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
# Find a exchange rate by its currency code.
|
44
|
+
#
|
45
|
+
# Example:
|
46
|
+
# >> Tangocard::ExchangeRate.find("EUR")
|
47
|
+
# => #<Tangocard::ExchangeRate:0x007ff31a2dd808 @currency_code="EUR", @rate="0.88870">
|
48
|
+
#
|
49
|
+
# Arguments:
|
50
|
+
# currency_code: (String)
|
51
|
+
def self.find(currency_code)
|
52
|
+
self.all.select{|r| r.currency_code == currency_code}.first
|
53
|
+
end
|
54
|
+
|
55
|
+
# Set all available exchange rates for Money gem. Once set allows to get reward USD representation
|
56
|
+
# of other currencies. For more information and use cases refer to Money gem docs.
|
57
|
+
#
|
58
|
+
# Example:
|
59
|
+
# >> Tangocard::ExchangeRate.populate_money_rates
|
60
|
+
# => true
|
61
|
+
# >> reward.to_money(:denomination)
|
62
|
+
# => #<Money fractional:500 currency:EUR>
|
63
|
+
# >> reward.to_money(:denomination).exchange_to('USD')
|
64
|
+
# => #<Money fractional:563 currency:USD>
|
65
|
+
#
|
66
|
+
# Arguments:
|
67
|
+
# none
|
68
|
+
def self.populate_money_rates
|
69
|
+
self.all.each {|r| Money.add_rate(r.currency_code, 'USD', r.inverse_rate)}
|
70
|
+
true
|
71
|
+
end
|
72
|
+
|
73
|
+
def initialize(currency_code, rate)
|
74
|
+
@currency_code = currency_code
|
75
|
+
@rate = rate.to_f
|
76
|
+
end
|
77
|
+
|
78
|
+
# Return an inverse rate of original (float). Used to pupulate Money gem rates.
|
79
|
+
#
|
80
|
+
# Arguments:
|
81
|
+
# none
|
82
|
+
def inverse_rate
|
83
|
+
1.0 / rate
|
84
|
+
end
|
85
|
+
|
86
|
+
end
|
data/lib/tangocard/order.rb
CHANGED
@@ -3,11 +3,14 @@ class Tangocard::Order
|
|
3
3
|
:account_identifier,
|
4
4
|
:customer,
|
5
5
|
:sku,
|
6
|
-
:
|
6
|
+
:denomination,
|
7
|
+
:amount_charged,
|
7
8
|
:reward_message,
|
9
|
+
:reward_subject,
|
8
10
|
:reward_from,
|
9
11
|
:delivered_at,
|
10
12
|
:recipient,
|
13
|
+
:external_id,
|
11
14
|
:reward,
|
12
15
|
:raw_response
|
13
16
|
|
@@ -20,7 +23,7 @@ class Tangocard::Order
|
|
20
23
|
# => [#<Tangocard::Order:0x007f9a6c4bca68 ...>, #<Tangocard::Order:0x007f9a6c4bca68 ...>, ...]
|
21
24
|
#
|
22
25
|
# Arguments:
|
23
|
-
# params: (Hash - optional, see https://
|
26
|
+
# params: (Hash - optional, see https://www.tangocard.com/docs/raas-api/#list-orders for details)
|
24
27
|
def self.all(params = {})
|
25
28
|
response = Tangocard::Raas.orders_index(params)
|
26
29
|
if response.success?
|
@@ -54,29 +57,31 @@ class Tangocard::Order
|
|
54
57
|
# => #<Tangocard::Order:0x007f9a6c4bca68 ...>
|
55
58
|
#
|
56
59
|
# Arguments:
|
57
|
-
# params: (Hash - see https://
|
60
|
+
# params: (Hash - see https://www.tangocard.com/docs/raas-api/#create-order for details)
|
58
61
|
def self.create(params)
|
59
62
|
response = Tangocard::Raas.create_order(params)
|
60
63
|
if response.success?
|
61
64
|
new(response.parsed_response['order'], response)
|
62
65
|
else
|
63
|
-
raise Tangocard::OrderCreateFailedException, "#{response.error_message}"
|
66
|
+
raise Tangocard::OrderCreateFailedException, "#{response.error_message} #{response.invalid_inputs}"
|
64
67
|
end
|
65
68
|
end
|
66
69
|
|
67
70
|
def initialize(params, raw_response = nil)
|
68
|
-
@order_id
|
71
|
+
@order_id = params['order_id']
|
69
72
|
@account_identifier = params['account_identifier']
|
70
|
-
@customer
|
71
|
-
@sku
|
72
|
-
@
|
73
|
-
@
|
74
|
-
@
|
75
|
-
@
|
76
|
-
@
|
77
|
-
@
|
78
|
-
@
|
79
|
-
@
|
73
|
+
@customer = params['customer']
|
74
|
+
@sku = params['sku']
|
75
|
+
@denomination = params['denomination'] || {}
|
76
|
+
@amount_charged = params['amount_charged'] || {}
|
77
|
+
@reward_message = params['reward_message']
|
78
|
+
@reward_subject = params['reward_subject']
|
79
|
+
@reward_from = params['reward_from']
|
80
|
+
@delivered_at = params['delivered_at']
|
81
|
+
@recipient = params['recipient'] || {}
|
82
|
+
@external_id = params['external_id']
|
83
|
+
@reward = params['reward'] || {}
|
84
|
+
@raw_response = raw_response
|
80
85
|
end
|
81
86
|
|
82
87
|
def reward
|
@@ -86,4 +91,4 @@ class Tangocard::Order
|
|
86
91
|
def identifier
|
87
92
|
@account_identifier
|
88
93
|
end
|
89
|
-
end
|
94
|
+
end
|
@@ -1,3 +1,3 @@
|
|
1
|
-
class Tangocard::OrderCreateFailedException <
|
1
|
+
class Tangocard::OrderCreateFailedException < StandardError
|
2
2
|
|
3
|
-
end
|
3
|
+
end
|
@@ -1,3 +1,3 @@
|
|
1
|
-
class Tangocard::OrderNotFoundException <
|
1
|
+
class Tangocard::OrderNotFoundException < StandardError
|
2
2
|
|
3
|
-
end
|
3
|
+
end
|
data/lib/tangocard/raas.rb
CHANGED
@@ -8,7 +8,7 @@ class Tangocard::Raas
|
|
8
8
|
# => #<Tangocard::Response:0x007f9a6c4bca68 ...>
|
9
9
|
#
|
10
10
|
# Arguments:
|
11
|
-
# params: (Hash - see https://
|
11
|
+
# params: (Hash - see https://www.tangocard.com/docs/raas-api/#create-account for details)
|
12
12
|
def self.create_account(params)
|
13
13
|
Tangocard::Response.new(post(endpoint + '/accounts', {:body => params.to_json}.merge(basic_auth_param)))
|
14
14
|
end
|
@@ -20,24 +20,11 @@ class Tangocard::Raas
|
|
20
20
|
# => #<Tangocard::Response:0x007f9a6c4bca68 ...>
|
21
21
|
#
|
22
22
|
# Arguments:
|
23
|
-
# params: (Hash - see https://
|
23
|
+
# params: (Hash - see https://www.tangocard.com/docs/raas-api/#get-account for details)
|
24
24
|
def self.show_account(params)
|
25
25
|
Tangocard::Response.new(get(endpoint + "/accounts/#{params['customer']}/#{params['identifier']}", basic_auth_param))
|
26
26
|
end
|
27
27
|
|
28
|
-
# (Deprecated)
|
29
|
-
# Funds an account. Returns Tangocard::Response object.
|
30
|
-
#
|
31
|
-
# Example:
|
32
|
-
# >> Tangocard::Raas.fund_account(params)
|
33
|
-
# => #<Tangocard::Response:0x007f9a6c4bca68 ...>
|
34
|
-
#
|
35
|
-
# Arguments:
|
36
|
-
# params: (Hash - see https://github.com/tangocarddev/RaaS#fund-a-platforms-account for details)
|
37
|
-
def self.fund_account(params)
|
38
|
-
Tangocard::Response.new(post(endpoint + '/funds', {:body => params.to_json}.merge(basic_auth_param)))
|
39
|
-
end
|
40
|
-
|
41
28
|
# Funds an account. Returns Tangocard::Response object.
|
42
29
|
#
|
43
30
|
# Example:
|
@@ -45,7 +32,7 @@ class Tangocard::Raas
|
|
45
32
|
# => #<Tangocard::Response:0x007f9a6c4bca68 ...>
|
46
33
|
#
|
47
34
|
# Arguments:
|
48
|
-
# params: (Hash - see https://
|
35
|
+
# params: (Hash - see https://www.tangocard.com/docs/raas-api/#create-cc-fund for details)
|
49
36
|
def self.cc_fund_account(params)
|
50
37
|
Tangocard::Response.new(post(endpoint + '/cc_fund', {:body => params.to_json}.merge(basic_auth_param)))
|
51
38
|
end
|
@@ -57,7 +44,7 @@ class Tangocard::Raas
|
|
57
44
|
# => #<Tangocard::Response:0x007f9a6c4bca68 ...>
|
58
45
|
#
|
59
46
|
# Arguments:
|
60
|
-
# params: (Hash - see https://
|
47
|
+
# params: (Hash - see https://www.tangocard.com/docs/raas-api/#create-cc-registration for details)
|
61
48
|
def self.register_credit_card(params)
|
62
49
|
Tangocard::Response.new(post(endpoint + '/cc_register', {:body => params.to_json}.merge(basic_auth_param)))
|
63
50
|
end
|
@@ -69,7 +56,7 @@ class Tangocard::Raas
|
|
69
56
|
# => #<Tangocard::Response:0x007f9a6c4bca68 ...>
|
70
57
|
#
|
71
58
|
# Arguments:
|
72
|
-
# params: (Hash - see https://
|
59
|
+
# params: (Hash - see https://www.tangocard.com/docs/raas-api/#create-cc-un-registration for details)
|
73
60
|
def self.delete_credit_card(params)
|
74
61
|
Tangocard::Response.new(post(endpoint + '/cc_unregister', {:body => params.to_json}.merge(basic_auth_param)))
|
75
62
|
end
|
@@ -97,7 +84,7 @@ class Tangocard::Raas
|
|
97
84
|
# => #<Tangocard::Response:0x007f9a6c4bca68 ...>
|
98
85
|
#
|
99
86
|
# Arguments:
|
100
|
-
# params: (Hash - see https://
|
87
|
+
# params: (Hash - see https://www.tangocard.com/docs/raas-api/#create-order for details)
|
101
88
|
def self.create_order(params)
|
102
89
|
Tangocard::Response.new(post(endpoint + '/orders', {:body => params.to_json}.merge(basic_auth_param)))
|
103
90
|
end
|
@@ -109,7 +96,7 @@ class Tangocard::Raas
|
|
109
96
|
# => #<Tangocard::Response:0x007f9a6c4bca68 ...>
|
110
97
|
#
|
111
98
|
# Arguments:
|
112
|
-
# params: (Hash - see https://
|
99
|
+
# params: (Hash - see https://www.tangocard.com/docs/raas-api/#get-order for details)
|
113
100
|
def self.show_order(params)
|
114
101
|
Tangocard::Response.new(get(endpoint + "/orders/#{params['order_id']}", basic_auth_param))
|
115
102
|
end
|
@@ -121,7 +108,7 @@ class Tangocard::Raas
|
|
121
108
|
# => #<Tangocard::Response:0x007f9a6c4bca68 ...>
|
122
109
|
#
|
123
110
|
# Arguments:
|
124
|
-
# params: (Hash - see https://
|
111
|
+
# params: (Hash - see https://www.tangocard.com/docs/raas-api/#list-orders for details)
|
125
112
|
def self.orders_index(params = {})
|
126
113
|
query_string = ""
|
127
114
|
if params.any?
|
@@ -145,6 +132,6 @@ class Tangocard::Raas
|
|
145
132
|
end
|
146
133
|
|
147
134
|
def self.endpoint
|
148
|
-
Tangocard.configuration.base_uri + '/raas/v1'
|
135
|
+
Tangocard.configuration.base_uri + '/raas/v1.1'
|
149
136
|
end
|
150
137
|
end
|
data/lib/tangocard/reward.rb
CHANGED
@@ -1,18 +1,18 @@
|
|
1
1
|
class Tangocard::Reward
|
2
|
-
attr_reader :
|
3
|
-
:currency_code, :
|
2
|
+
attr_reader :type, :description, :sku, :is_variable, :denomination, :min_price, :max_price,
|
3
|
+
:currency_code, :available, :countries
|
4
4
|
|
5
5
|
def initialize(params)
|
6
|
-
@
|
7
|
-
@
|
8
|
-
@
|
9
|
-
@
|
10
|
-
@
|
11
|
-
@min_price
|
12
|
-
@max_price
|
6
|
+
@type = params['type']
|
7
|
+
@description = params['description']
|
8
|
+
@sku = params['sku']
|
9
|
+
@is_variable = params['is_variable']
|
10
|
+
@denomination = params['denomination'].to_i
|
11
|
+
@min_price = params['min_price'].to_i
|
12
|
+
@max_price = params['max_price'].to_i
|
13
13
|
@currency_code = params['currency_code']
|
14
|
-
@
|
15
|
-
@
|
14
|
+
@available = params['available']
|
15
|
+
@countries = params['countries']
|
16
16
|
end
|
17
17
|
|
18
18
|
# Is this a variable-priced reward?
|
@@ -24,7 +24,7 @@ class Tangocard::Reward
|
|
24
24
|
# Arguments:
|
25
25
|
# none
|
26
26
|
def variable_price?
|
27
|
-
|
27
|
+
is_variable
|
28
28
|
end
|
29
29
|
|
30
30
|
# Is this reward purchasable given a certain number of cents available to purchase it?
|
@@ -43,21 +43,21 @@ class Tangocard::Reward
|
|
43
43
|
if variable_price?
|
44
44
|
min_price <= balance_in_cents
|
45
45
|
else
|
46
|
-
|
46
|
+
denomination <= balance_in_cents
|
47
47
|
end
|
48
48
|
end
|
49
49
|
|
50
|
-
# Converts price in cents for given field to Money object using
|
50
|
+
# Converts price in cents for given field to Money object using currency_code
|
51
51
|
#
|
52
52
|
# Example:
|
53
53
|
# >> reward.to_money(:unit_price)
|
54
54
|
# => #<Money fractional:5000 currency:USD>
|
55
55
|
#
|
56
56
|
# Arguments:
|
57
|
-
# field_name: (Symbol - must be :min_price, :max_price, or :
|
57
|
+
# field_name: (Symbol - must be :min_price, :max_price, or :denomination)
|
58
58
|
def to_money(field_name)
|
59
|
-
return nil unless [:min_price, :max_price, :
|
59
|
+
return nil unless [:min_price, :max_price, :denomination].include?(field_name)
|
60
60
|
|
61
|
-
Money.new(self.send(field_name),
|
61
|
+
Money.new(self.send(field_name), currency_code)
|
62
62
|
end
|
63
|
-
end
|
63
|
+
end
|
data/lib/tangocard/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tangocard
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 5.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Raphael Crawford-Marks
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-03-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|
@@ -44,14 +44,14 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 0.
|
47
|
+
version: '0.7'
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: 0.
|
54
|
+
version: '0.7'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rspec
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -81,7 +81,7 @@ dependencies:
|
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
83
|
description: |-
|
84
|
-
Tango Card provides a RaaS API for developers (https://
|
84
|
+
Tango Card provides a RaaS API for developers (https://www.tangocard.com/docs/raas-api/). This gem
|
85
85
|
provides commonsense Ruby objects to wrap the JSON endpoints of the RaaS API.
|
86
86
|
email:
|
87
87
|
- raphael@bonus.ly
|
@@ -100,6 +100,7 @@ files:
|
|
100
100
|
- lib/tangocard/account_not_found_exception.rb
|
101
101
|
- lib/tangocard/account_register_credit_card_failed_exception.rb
|
102
102
|
- lib/tangocard/brand.rb
|
103
|
+
- lib/tangocard/exchange_rate.rb
|
103
104
|
- lib/tangocard/order.rb
|
104
105
|
- lib/tangocard/order_create_failed_exception.rb
|
105
106
|
- lib/tangocard/order_not_found_exception.rb
|
@@ -126,7 +127,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
126
127
|
version: '0'
|
127
128
|
requirements: []
|
128
129
|
rubyforge_project:
|
129
|
-
rubygems_version: 2.
|
130
|
+
rubygems_version: 2.5.1
|
130
131
|
signing_key:
|
131
132
|
specification_version: 4
|
132
133
|
summary: Ruby Wrapper for Tango Card RaaS API.
|