groupon_api 0.1.2 → 0.2.1
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/lib/groupon_api/config.rb +2 -0
- data/lib/groupon_api/deals.rb +3 -1
- data/lib/groupon_api/request.rb +7 -3
- data/lib/groupon_api/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: c4a7ed07ca90c0ec8e8ed84c5aa2487beba468b3
|
4
|
+
data.tar.gz: e108a60b48c8eb752216195011fb735889ab0334
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a23b6a89fac91cda4604b01582cd113b19a759369d099447304896ddff41fde62971f0f188450d550fa63b943a56de9504b846b17457359e3268bdafa9aae484
|
7
|
+
data.tar.gz: 698be5342c3f1f4e042b1fa6401a9e2ca133c56f869301a4a6215dbde534f67d8ae15920dee0b2b6c8578197795e0f1252b44daf8a849106ec94cc7f102d9c06
|
data/lib/groupon_api/config.rb
CHANGED
@@ -4,6 +4,7 @@ module GrouponApi
|
|
4
4
|
# configure GrouponApi global settings
|
5
5
|
# GrouponApi.configure do |config|
|
6
6
|
# config.ts_token = 'US_AFF_0_201236_212556_0'
|
7
|
+
# config.debug = true
|
7
8
|
# end
|
8
9
|
def self.configure &block
|
9
10
|
yield @config ||= GrouponApi::Configuration.new
|
@@ -19,6 +20,7 @@ module GrouponApi
|
|
19
20
|
|
20
21
|
config_accessor(:ts_token){ nil }
|
21
22
|
config_accessor(:use_ssl){ true }
|
23
|
+
config_accessor(:debug){ false }
|
22
24
|
|
23
25
|
#deals
|
24
26
|
config_accessor(:deals){ {} }
|
data/lib/groupon_api/deals.rb
CHANGED
@@ -6,6 +6,8 @@ module GrouponApi
|
|
6
6
|
params.merge!(tsToken: GrouponApi.config.ts_token)
|
7
7
|
params.merge!(GrouponApi.config.deals) if GrouponApi.config.deals.kind_of?(Hash)
|
8
8
|
|
9
|
-
GrouponApi
|
9
|
+
puts "#{__FILE__}:#{__LINE__} params: #{params}" if GrouponApi.config.debug
|
10
|
+
|
11
|
+
GrouponApi::Request.call('deals', params)['deals'].collect{|deal| HashWithIndifferentAccess.new(deal)}
|
10
12
|
end
|
11
13
|
end
|
data/lib/groupon_api/request.rb
CHANGED
@@ -14,17 +14,21 @@ module GrouponApi
|
|
14
14
|
|
15
15
|
# Call API with config.use_ssl
|
16
16
|
protocol = GrouponApi.config.use_ssl ? 'https' : 'http'
|
17
|
-
|
17
|
+
query_str = query_arr.join('&')
|
18
|
+
url_str = "#{protocol}://#{API_BASE}/#{endpoint}.json?#{query_str}"
|
19
|
+
puts "#{__FILE__}:#{__LINE__} url_str: #{url_str}" if GrouponApi.config.debug
|
18
20
|
begin
|
19
21
|
result = Net::HTTP.get(URI.parse(url_str))
|
20
22
|
rescue => e
|
21
|
-
puts
|
23
|
+
puts "#{__FILE__}:#{__LINE__} [RESCUE]: #{e}" if GrouponApi.config.debug
|
22
24
|
return []
|
23
25
|
end
|
24
26
|
|
25
27
|
# return result as Array of HashWithIndifferentAccess
|
26
28
|
json = JSON.parse(result)
|
27
|
-
|
29
|
+
puts "#{__FILE__}:#{__LINE__} json:" if GrouponApi.config.debug
|
30
|
+
puts "#{json}" if GrouponApi.config.debug
|
31
|
+
json
|
28
32
|
end
|
29
33
|
end
|
30
34
|
end
|
data/lib/groupon_api/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: groupon_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bryan Liff
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-06-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|