tangocard 6.0.0 → 6.1.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 +3 -1
- data/lib/tangocard.rb +3 -1
- data/lib/tangocard/raas.rb +15 -0
- data/lib/tangocard/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4ac03de16035232e603b426c59ccd6224e782122
|
4
|
+
data.tar.gz: de61de3f8a4a361274a3a7689382b69f28972a94
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d736487bb1c755343ba712a77eccc2db7de51036dc5eb73f40b8a913827a811db4baba37fa3c516e1b90ecc224eb89087cb9810e3cff7e63756b1cb977d74143
|
7
|
+
data.tar.gz: 6dde06d834effdbe683bdcbcb32d52a98175388e7a0b710a743bd57bcfdb9bbc6ef374cd8e0ee28887a501da5296909006ae8b21a73618e96b5e2b945cc050dc
|
data/README.md
CHANGED
@@ -39,11 +39,13 @@ There are three required configuration parameters:
|
|
39
39
|
* `key` - The API account key you receive from Tango Card
|
40
40
|
* `base_uri` - This defaults to the Tango Card sandbox. For production, you must specify the base URI for the production RaaS API. Make sure not to include `/raas/v1` or any trailing slashes.
|
41
41
|
|
42
|
-
There are also
|
42
|
+
There are also optional configuration parameters:
|
43
43
|
|
44
44
|
* `default_brands` - An array of strings for the brands you want to retrieve with `Tangocard::Brand.default`. The strings should match the unique brand `description` fields exactly.
|
45
45
|
* `local_images` - An array of local image names/URIs that you want to display instead of the default Tango Card-provided `image_url`. `image_url` is sometimes blank, so this can be handy in those cases.
|
46
46
|
* `sku_blacklist` - Reward SKUs that are blacklisted, ie. should never be returned as a purchasable reward.
|
47
|
+
* `use_cache` - Use cache for Tangocard::Brand queries, defaults to `true`.
|
48
|
+
* `cache_ttl` - Cache time-to-Live in seconds, only effective if `use_cache` is enabled. Default is `0` (cache never expires).
|
47
49
|
|
48
50
|
## Getting Started
|
49
51
|
|
data/lib/tangocard.rb
CHANGED
@@ -4,7 +4,8 @@ require 'ostruct'
|
|
4
4
|
|
5
5
|
module Tangocard
|
6
6
|
class Configuration
|
7
|
-
attr_accessor :name, :key, :base_uri, :default_brands, :local_images, :sku_blacklist,
|
7
|
+
attr_accessor :name, :key, :base_uri, :default_brands, :local_images, :sku_blacklist,
|
8
|
+
:use_cache, :cache_ttl
|
8
9
|
|
9
10
|
def initialize
|
10
11
|
self.name = nil
|
@@ -14,6 +15,7 @@ module Tangocard
|
|
14
15
|
self.local_images = {}
|
15
16
|
self.sku_blacklist = []
|
16
17
|
self.use_cache = true
|
18
|
+
self.cache_ttl = 0
|
17
19
|
end
|
18
20
|
end
|
19
21
|
|
data/lib/tangocard/raas.rb
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
class Tangocard::Raas
|
2
2
|
include HTTParty
|
3
3
|
|
4
|
+
@@rewards_response_expires_at = 0
|
5
|
+
|
4
6
|
# Create a new account. Returns Tangocard::Response object.
|
5
7
|
#
|
6
8
|
# Example:
|
@@ -71,7 +73,11 @@ class Tangocard::Raas
|
|
71
73
|
# none
|
72
74
|
def self.rewards_index
|
73
75
|
if Tangocard.configuration.use_cache
|
76
|
+
clear_cache! if cache_expired?
|
77
|
+
|
74
78
|
@@rewards_response ||= Tangocard::Response.new(get(endpoint + '/rewards', basic_auth_param))
|
79
|
+
@@rewards_response_expires_at = (Time.now.to_i + Tangocard.configuration.cache_ttl) if cache_expired?
|
80
|
+
@@rewards_response
|
75
81
|
else
|
76
82
|
Tangocard::Response.new(get(endpoint + '/rewards', basic_auth_param))
|
77
83
|
end
|
@@ -123,6 +129,7 @@ class Tangocard::Raas
|
|
123
129
|
|
124
130
|
def self.clear_cache!
|
125
131
|
@@rewards_response = nil
|
132
|
+
@@rewards_response_expires_at = 0
|
126
133
|
end
|
127
134
|
|
128
135
|
private
|
@@ -131,6 +138,14 @@ class Tangocard::Raas
|
|
131
138
|
{:basic_auth => {:username => Tangocard.configuration.name, :password => Tangocard.configuration.key}}
|
132
139
|
end
|
133
140
|
|
141
|
+
def self.use_cache_ttl?
|
142
|
+
Tangocard.configuration.use_cache && Tangocard.configuration.cache_ttl > 0
|
143
|
+
end
|
144
|
+
|
145
|
+
def self.cache_expired?
|
146
|
+
use_cache_ttl? && @@rewards_response_expires_at < Time.now.to_i
|
147
|
+
end
|
148
|
+
|
134
149
|
def self.endpoint
|
135
150
|
Tangocard.configuration.base_uri + '/raas/v1.1'
|
136
151
|
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.1.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-04-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|
@@ -127,7 +127,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
127
127
|
version: '0'
|
128
128
|
requirements: []
|
129
129
|
rubyforge_project:
|
130
|
-
rubygems_version: 2.
|
130
|
+
rubygems_version: 2.5.1
|
131
131
|
signing_key:
|
132
132
|
specification_version: 4
|
133
133
|
summary: Ruby Wrapper for Tango Card RaaS API.
|