groupon_api 0.1.2 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d5b751c7d9af33598617ccc0a882fbee366614ea
4
- data.tar.gz: 4ca23d3334015cafeb8044f5fb6c851209e175b9
3
+ metadata.gz: c4a7ed07ca90c0ec8e8ed84c5aa2487beba468b3
4
+ data.tar.gz: e108a60b48c8eb752216195011fb735889ab0334
5
5
  SHA512:
6
- metadata.gz: a1ebb42c332ba1f4a15886f9261664a4af48a3bef9395a8214e6dbc678439f27322921b187aeecff89a4e7393e01cc0a826874d9ee05df6d1e829daa41fa23ea
7
- data.tar.gz: d25fc1d11c3b9fee56438f4fa4723178f4daf55b7c0da4e2a0f1e19384f93485b39aa4eed557fd646d01d345104734b364b26c464017fabff3009c67be1c732c
6
+ metadata.gz: a23b6a89fac91cda4604b01582cd113b19a759369d099447304896ddff41fde62971f0f188450d550fa63b943a56de9504b846b17457359e3268bdafa9aae484
7
+ data.tar.gz: 698be5342c3f1f4e042b1fa6401a9e2ca133c56f869301a4a6215dbde534f67d8ae15920dee0b2b6c8578197795e0f1252b44daf8a849106ec94cc7f102d9c06
@@ -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){ {} }
@@ -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::Request.call('deals', params)
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
@@ -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
- url_str = "#{protocol}://#{API_BASE}/#{endpoint}.json?#{query_arr.join('&')}"
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 '[RESCUE]: ' + e.to_s
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
- json['deals'].collect{|deal| HashWithIndifferentAccess.new(deal)}
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
@@ -1,3 +1,3 @@
1
1
  module GrouponApi
2
- VERSION = "0.1.2"
2
+ VERSION = "0.2.1"
3
3
  end
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.2
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-04-24 00:00:00.000000000 Z
11
+ date: 2015-06-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport