tangocard 6.1.0 → 6.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/tangocard.rb +3 -1
- data/lib/tangocard/brand.rb +3 -1
- data/lib/tangocard/raas.rb +21 -13
- data/lib/tangocard/raas_exception.rb +2 -0
- data/lib/tangocard/response.rb +11 -5
- data/lib/tangocard/version.rb +1 -1
- metadata +6 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7f7d4ed6be48184c160a1fdba063b0a4927dce67
|
4
|
+
data.tar.gz: eab7f8d2e7558c42e1fc45f5a110eb2f52fe6457
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 232120b85c5a52108958f0534abda04c4069cb07c7d489a7cfb227eb81071207b0767528c481c1da34b7a265fe081daf7aa265ec67faf36c3119926254c2bfec
|
7
|
+
data.tar.gz: 1a7d9eecaf0a0ca4b0d39a08169061c31f5dc7ebe42accd322f66cc7e25dff1dcbe3498df486eff127bce04ce7aa1a0d44d872c6023f72981884b13c9b8e28da
|
data/lib/tangocard.rb
CHANGED
@@ -20,7 +20,7 @@ module Tangocard
|
|
20
20
|
end
|
21
21
|
|
22
22
|
def self.configuration
|
23
|
-
@configuration ||=
|
23
|
+
@configuration ||= Configuration.new
|
24
24
|
end
|
25
25
|
|
26
26
|
def self.configure
|
@@ -40,5 +40,7 @@ require 'tangocard/brand'
|
|
40
40
|
require 'tangocard/order'
|
41
41
|
require 'tangocard/order_create_failed_exception'
|
42
42
|
require 'tangocard/order_not_found_exception'
|
43
|
+
require 'tangocard/raas_exception'
|
43
44
|
require 'tangocard/reward'
|
44
45
|
require 'tangocard/exchange_rate'
|
46
|
+
|
data/lib/tangocard/brand.rb
CHANGED
@@ -22,7 +22,9 @@ class Tangocard::Brand
|
|
22
22
|
# Arguments:
|
23
23
|
# none
|
24
24
|
def self.all
|
25
|
-
Tangocard::Raas.rewards_index
|
25
|
+
rewards_index = Tangocard::Raas.rewards_index
|
26
|
+
raise Tangocard::RaasException.new("Tangocard error with response code #{rewards_index.code}") unless rewards_index.success?
|
27
|
+
rewards_index.parsed_response['brands'].map{|p| Tangocard::Brand.new(p)}
|
26
28
|
end
|
27
29
|
|
28
30
|
# Find a brand by its :description field.
|
data/lib/tangocard/raas.rb
CHANGED
@@ -12,7 +12,7 @@ class Tangocard::Raas
|
|
12
12
|
# Arguments:
|
13
13
|
# params: (Hash - see https://www.tangocard.com/docs/raas-api/#create-account for details)
|
14
14
|
def self.create_account(params)
|
15
|
-
Tangocard::Response.new(
|
15
|
+
Tangocard::Response.new(post_request('/accounts', { body: params.to_json }))
|
16
16
|
end
|
17
17
|
|
18
18
|
# Gets account details. Returns Tangocard::Response object.
|
@@ -24,7 +24,7 @@ class Tangocard::Raas
|
|
24
24
|
# Arguments:
|
25
25
|
# params: (Hash - see https://www.tangocard.com/docs/raas-api/#get-account for details)
|
26
26
|
def self.show_account(params)
|
27
|
-
Tangocard::Response.new(
|
27
|
+
Tangocard::Response.new(get_request("/accounts/#{params['customer']}/#{params['identifier']}"))
|
28
28
|
end
|
29
29
|
|
30
30
|
# Funds an account. Returns Tangocard::Response object.
|
@@ -36,7 +36,7 @@ class Tangocard::Raas
|
|
36
36
|
# Arguments:
|
37
37
|
# params: (Hash - see https://www.tangocard.com/docs/raas-api/#create-cc-fund for details)
|
38
38
|
def self.cc_fund_account(params)
|
39
|
-
Tangocard::Response.new(
|
39
|
+
Tangocard::Response.new(post_request('/cc_fund', { body: params.to_json }))
|
40
40
|
end
|
41
41
|
|
42
42
|
# Registers a credit card to an account. Returns Tangocard::Response object.
|
@@ -48,7 +48,7 @@ class Tangocard::Raas
|
|
48
48
|
# Arguments:
|
49
49
|
# params: (Hash - see https://www.tangocard.com/docs/raas-api/#create-cc-registration for details)
|
50
50
|
def self.register_credit_card(params)
|
51
|
-
Tangocard::Response.new(
|
51
|
+
Tangocard::Response.new(post_request('/cc_register', { body: params.to_json }))
|
52
52
|
end
|
53
53
|
|
54
54
|
# Deletes a credit card from an account. Returns Tangocard::Response object.
|
@@ -60,7 +60,7 @@ class Tangocard::Raas
|
|
60
60
|
# Arguments:
|
61
61
|
# params: (Hash - see https://www.tangocard.com/docs/raas-api/#create-cc-un-registration for details)
|
62
62
|
def self.delete_credit_card(params)
|
63
|
-
Tangocard::Response.new(
|
63
|
+
Tangocard::Response.new(post_request('/cc_unregister', { body: params.to_json }))
|
64
64
|
end
|
65
65
|
|
66
66
|
# Retrieve all rewards. Returns Tangocard::Response object.
|
@@ -75,11 +75,11 @@ class Tangocard::Raas
|
|
75
75
|
if Tangocard.configuration.use_cache
|
76
76
|
clear_cache! if cache_expired?
|
77
77
|
|
78
|
-
@@rewards_response ||= Tangocard::Response.new(
|
78
|
+
@@rewards_response ||= Tangocard::Response.new(get_request('/rewards'))
|
79
79
|
@@rewards_response_expires_at = (Time.now.to_i + Tangocard.configuration.cache_ttl) if cache_expired?
|
80
80
|
@@rewards_response
|
81
81
|
else
|
82
|
-
Tangocard::Response.new(
|
82
|
+
Tangocard::Response.new(get_request('/rewards'))
|
83
83
|
end
|
84
84
|
end
|
85
85
|
|
@@ -92,7 +92,7 @@ class Tangocard::Raas
|
|
92
92
|
# Arguments:
|
93
93
|
# params: (Hash - see https://www.tangocard.com/docs/raas-api/#create-order for details)
|
94
94
|
def self.create_order(params)
|
95
|
-
Tangocard::Response.new(
|
95
|
+
Tangocard::Response.new(post_request('/orders', { body: params.to_json }))
|
96
96
|
end
|
97
97
|
|
98
98
|
# Get order details. Returns Tangocard::Response object.
|
@@ -104,7 +104,7 @@ class Tangocard::Raas
|
|
104
104
|
# Arguments:
|
105
105
|
# params: (Hash - see https://www.tangocard.com/docs/raas-api/#get-order for details)
|
106
106
|
def self.show_order(params)
|
107
|
-
Tangocard::Response.new(
|
107
|
+
Tangocard::Response.new(get_request("/orders/#{params['order_id']}"))
|
108
108
|
end
|
109
109
|
|
110
110
|
# Retrieve a list of historical orders. Returns Tangocard::Response object.
|
@@ -119,12 +119,12 @@ class Tangocard::Raas
|
|
119
119
|
query_string = ""
|
120
120
|
if params.any?
|
121
121
|
query_string = "?"
|
122
|
-
params.keys.each_with_index do |k,i|
|
122
|
+
params.keys.each_with_index do |k, i|
|
123
123
|
query_string += "&" unless i == 0
|
124
124
|
query_string += "#{k}=#{params[k]}"
|
125
125
|
end
|
126
126
|
end
|
127
|
-
Tangocard::Response.new(
|
127
|
+
Tangocard::Response.new(get_request("/orders#{query_string}"))
|
128
128
|
end
|
129
129
|
|
130
130
|
def self.clear_cache!
|
@@ -135,7 +135,7 @@ class Tangocard::Raas
|
|
135
135
|
private
|
136
136
|
|
137
137
|
def self.basic_auth_param
|
138
|
-
{:
|
138
|
+
{ basic_auth: { username: Tangocard.configuration.name, password: Tangocard.configuration.key } }
|
139
139
|
end
|
140
140
|
|
141
141
|
def self.use_cache_ttl?
|
@@ -147,6 +147,14 @@ class Tangocard::Raas
|
|
147
147
|
end
|
148
148
|
|
149
149
|
def self.endpoint
|
150
|
-
Tangocard.configuration.base_uri
|
150
|
+
"#{Tangocard.configuration.base_uri}/raas/v1.1"
|
151
|
+
end
|
152
|
+
|
153
|
+
def self.get_request(path)
|
154
|
+
get("#{endpoint}#{path}", basic_auth_param)
|
155
|
+
end
|
156
|
+
|
157
|
+
def self.post_request(path, params)
|
158
|
+
post("#{endpoint}#{path}", basic_auth_param.merge(params))
|
151
159
|
end
|
152
160
|
end
|
data/lib/tangocard/response.rb
CHANGED
@@ -7,22 +7,28 @@ class Tangocard::Response
|
|
7
7
|
end
|
8
8
|
|
9
9
|
def success?
|
10
|
-
|
10
|
+
safe_response['success'] || false
|
11
11
|
end
|
12
12
|
|
13
13
|
def error_message
|
14
|
-
|
14
|
+
safe_response['error_message']
|
15
15
|
end
|
16
16
|
|
17
17
|
def denial_message
|
18
|
-
|
18
|
+
safe_response['denial_message']
|
19
19
|
end
|
20
20
|
|
21
21
|
def denial_code
|
22
|
-
|
22
|
+
safe_response['denial_code']
|
23
23
|
end
|
24
24
|
|
25
25
|
def invalid_inputs
|
26
|
-
|
26
|
+
safe_response['invalid_inputs']
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
def safe_response
|
32
|
+
parsed_response || {}
|
27
33
|
end
|
28
34
|
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: 6.
|
4
|
+
version: 6.2.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: 2016-
|
11
|
+
date: 2016-12-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|
@@ -56,28 +56,14 @@ dependencies:
|
|
56
56
|
name: rspec
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - "
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '2.14'
|
62
|
-
type: :development
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - "~>"
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: '2.14'
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: rr
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
72
|
-
requirements:
|
73
|
-
- - "~>"
|
59
|
+
- - ">="
|
74
60
|
- !ruby/object:Gem::Version
|
75
61
|
version: '0'
|
76
62
|
type: :development
|
77
63
|
prerelease: false
|
78
64
|
version_requirements: !ruby/object:Gem::Requirement
|
79
65
|
requirements:
|
80
|
-
- - "
|
66
|
+
- - ">="
|
81
67
|
- !ruby/object:Gem::Version
|
82
68
|
version: '0'
|
83
69
|
description: |-
|
@@ -105,6 +91,7 @@ files:
|
|
105
91
|
- lib/tangocard/order_create_failed_exception.rb
|
106
92
|
- lib/tangocard/order_not_found_exception.rb
|
107
93
|
- lib/tangocard/raas.rb
|
94
|
+
- lib/tangocard/raas_exception.rb
|
108
95
|
- lib/tangocard/response.rb
|
109
96
|
- lib/tangocard/reward.rb
|
110
97
|
- lib/tangocard/version.rb
|
@@ -132,3 +119,4 @@ signing_key:
|
|
132
119
|
specification_version: 4
|
133
120
|
summary: Ruby Wrapper for Tango Card RaaS API.
|
134
121
|
test_files: []
|
122
|
+
has_rdoc:
|