tangocard 3.1.0 → 3.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/brand.rb +24 -8
- data/lib/tangocard/response.rb +3 -3
- data/lib/tangocard/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1b146ae717f7cbdb68ac360039e6a35cf676f0c8
|
4
|
+
data.tar.gz: 94980ddca9137e80fbe12ecc5ae6b5910f1cb8e8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4a5624ddb2268a3c993ac9e59681477b9477c06e3351cea4289587425b76fa8321cf8c6c24db44b65597cdec033c9639bcc2317069277ca4a7d0647074db2a39
|
7
|
+
data.tar.gz: 1fd5aad408539b3734e757d7126d738152c3f2501392e815f89820ae4c9b084af96afb8a73274983f729410fe1057abc6a94fad08899b4eaddd5500e106b5982
|
data/lib/tangocard/brand.rb
CHANGED
@@ -1,9 +1,25 @@
|
|
1
1
|
class Tangocard::Brand
|
2
2
|
attr_reader :description, :rewards
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
3
|
+
@result = nil
|
4
|
+
@brands = nil
|
5
|
+
@default_brands = nil
|
6
|
+
@brand_finder = {}
|
7
|
+
|
8
|
+
# Clear all cached responses. Next request for brand info will pull fresh from the Tango Card API.
|
9
|
+
#
|
10
|
+
# Example:
|
11
|
+
# >> Tangocard::Brand.clear_cache!
|
12
|
+
# => true
|
13
|
+
#
|
14
|
+
# Arguments:
|
15
|
+
# none
|
16
|
+
def self.clear_cache!
|
17
|
+
@result = nil
|
18
|
+
@brands = nil
|
19
|
+
@default_brands = nil
|
20
|
+
@brand_finder = {}
|
21
|
+
true
|
22
|
+
end
|
7
23
|
|
8
24
|
# Return an array of all brands.
|
9
25
|
#
|
@@ -14,8 +30,8 @@ class Tangocard::Brand
|
|
14
30
|
# Arguments:
|
15
31
|
# none
|
16
32
|
def self.all
|
17
|
-
|
18
|
-
|
33
|
+
@result ||= Tangocard::Raas.rewards_index.parsed_response
|
34
|
+
@brands ||= @result['brands'].map{|p| Tangocard::Brand.new(p)}
|
19
35
|
end
|
20
36
|
|
21
37
|
# Return an array of default brands. Must set default_brands in your Tangocard initializer (see README).
|
@@ -27,7 +43,7 @@ class Tangocard::Brand
|
|
27
43
|
# Arguments:
|
28
44
|
# none
|
29
45
|
def self.default_brands
|
30
|
-
|
46
|
+
@default_brands ||= self.all.select{|b| Tangocard.configuration.default_brands.include?(b.description)}
|
31
47
|
end
|
32
48
|
|
33
49
|
# Find a brand by its :description field.
|
@@ -43,7 +59,7 @@ class Tangocard::Brand
|
|
43
59
|
# Arguments:
|
44
60
|
# brand_name: (String)
|
45
61
|
def self.find(brand_name)
|
46
|
-
|
62
|
+
@brand_finder[brand_name] ||= self.all.select{|b| b.description == brand_name}.first
|
47
63
|
end
|
48
64
|
|
49
65
|
def initialize(params)
|
data/lib/tangocard/response.rb
CHANGED
@@ -7,14 +7,14 @@ class Tangocard::Response
|
|
7
7
|
end
|
8
8
|
|
9
9
|
def success?
|
10
|
-
parsed_response['success']
|
10
|
+
parsed_response['success'] rescue false
|
11
11
|
end
|
12
12
|
|
13
13
|
def error_message
|
14
|
-
parsed_response['error_message']
|
14
|
+
parsed_response['error_message'] rescue 'UNKNOWN ERROR'
|
15
15
|
end
|
16
16
|
|
17
17
|
def invalid_inputs
|
18
|
-
parsed_response['invalid_inputs']
|
18
|
+
parsed_response['invalid_inputs'] rescue 'UNKNOWN INVALID INPUTS'
|
19
19
|
end
|
20
20
|
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: 3.
|
4
|
+
version: 3.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:
|
11
|
+
date: 2015-03-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|