rsqoot 0.2.2 → 0.3.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 +13 -5
- data/lib/rsqoot/category.rb +5 -1
- data/lib/rsqoot/click.rb +1 -1
- data/lib/rsqoot/client.rb +2 -0
- data/lib/rsqoot/commission.rb +1 -1
- data/lib/rsqoot/deal.rb +12 -8
- data/lib/rsqoot/helper.rb +15 -0
- data/lib/rsqoot/merchant.rb +5 -1
- data/lib/rsqoot/provider.rb +5 -1
- data/lib/rsqoot/request.rb +18 -15
- data/lib/rsqoot/version.rb +1 -1
- metadata +6 -5
checksums.yaml
CHANGED
@@ -1,7 +1,15 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
OTA2NTI1OGNiM2VkN2NmMTM5ODRiMDE3NTI5Y2Q5NjYxMGNiYjBiMQ==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
ZWU5MmJjNjU2NzJiZGJhZDMzYTJjZWViMjNiMGQ4N2RhZWExNTkyMA==
|
5
7
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
MTA4NGM0MjI0YTk0MGMyZjRlZjA3NjI5YWE5MzhkNTA3NWU0ZmVjMzQyZWY0
|
10
|
+
YWMzODFhZGFkMzdjODc4MDZmNmQyNThjNTJmNTJjNTAzNTg2MWQ3MTBiNTQy
|
11
|
+
ZTRmOTk0NzdkNzhhOGNhMGJjMTAwNTQ2ZWZiNjE4MmJiOTc1OTM=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
YzQ1OTI4NDNkMDI3NzBhYjhiYTY1MDRkYTI3OGI0MWRjNWNjMTQyZWU0MWI5
|
14
|
+
NTQxZTdiYzg0NmM1MDE4Y2MwMWNiNGQ2M2U3MTY3YmZjMWU3ZDEyMTAxNzYw
|
15
|
+
NTRiOGRmMjA3YzExMTk1NjRhYTI4MWY4OTVkYzkzY2VkZDJjYzU=
|
data/lib/rsqoot/category.rb
CHANGED
@@ -5,7 +5,11 @@ module RSqoot
|
|
5
5
|
#
|
6
6
|
# @return [Hashie::Mash] category list
|
7
7
|
def categories(options={})
|
8
|
-
|
8
|
+
if categories_not_latest?(options)
|
9
|
+
@rsqoot_categories = get('categories', options)
|
10
|
+
@rsqoot_categories = @rsqoot_categories.categories if @rsqoot_categories
|
11
|
+
end
|
12
|
+
@rsqoot_categories
|
9
13
|
end
|
10
14
|
end
|
11
15
|
end
|
data/lib/rsqoot/click.rb
CHANGED
data/lib/rsqoot/client.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
require "rsqoot/helper"
|
1
2
|
require "rsqoot/merchant"
|
2
3
|
require "rsqoot/category"
|
3
4
|
require "rsqoot/provider"
|
@@ -8,6 +9,7 @@ require "rsqoot/request"
|
|
8
9
|
|
9
10
|
module RSqoot
|
10
11
|
class Client
|
12
|
+
include Helper
|
11
13
|
include Category
|
12
14
|
include Click
|
13
15
|
include Commission
|
data/lib/rsqoot/commission.rb
CHANGED
data/lib/rsqoot/deal.rb
CHANGED
@@ -9,21 +9,25 @@ module RSqoot
|
|
9
9
|
# @param [Integer] page (Which page of result to return. Default to 1.)
|
10
10
|
# @param [Integer] per_page (Number of results to return at once. Defaults to 10.)
|
11
11
|
def deals(options={})
|
12
|
-
|
12
|
+
if deals_not_latest?(options)
|
13
|
+
@rsqoot_deals = get('deals', options) || []
|
14
|
+
@rsqoot_deals = @rsqoot_deals.deals.map(&:deal) if !@rsqoot_deals.empty?
|
15
|
+
end
|
16
|
+
@rsqoot_deals
|
13
17
|
end
|
14
18
|
|
15
19
|
# Retrieve a deal by id
|
16
20
|
#
|
17
21
|
def deal(id, options={})
|
18
|
-
|
22
|
+
if deal_not_latest?(id)
|
23
|
+
@rsqoot_deal = get("deals/#{id}", options)
|
24
|
+
@rsqoot_deal = @rsqoot_deal.deal if @rsqoot_deal
|
25
|
+
end
|
26
|
+
@rsqoot_deal
|
19
27
|
end
|
20
28
|
|
21
|
-
def
|
22
|
-
|
23
|
-
end
|
24
|
-
|
25
|
-
def deal_impression(id, options={})
|
26
|
-
get("deals/#{id}/image", options, parse = false)
|
29
|
+
def impression(deal_id, options={})
|
30
|
+
url_generator("deals/#{deal_id}/image", options, require_key = true).first.to_s
|
27
31
|
end
|
28
32
|
|
29
33
|
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module RSqoot
|
2
|
+
module Helper
|
3
|
+
def self.included(base)
|
4
|
+
['deals', 'deal', 'categories', 'providers', 'merchant'].each do |name|
|
5
|
+
attr_reader ('rsqoot_' + name).to_sym
|
6
|
+
attr_accessor (name + '_options').to_sym
|
7
|
+
base.send :define_method, (name + '_not_latest?').to_sym do |opt|
|
8
|
+
result = method(name + '_options').call == opt ? false : true
|
9
|
+
method(name + '_options=').call opt if result
|
10
|
+
result
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
data/lib/rsqoot/merchant.rb
CHANGED
@@ -7,7 +7,11 @@ module RSqoot
|
|
7
7
|
# @param [String] namespace (One of the supported namespaces. Factual, Foursquare, Facebook, Google, CitySearch, Yelp.)
|
8
8
|
|
9
9
|
def merchant(id, options={})
|
10
|
-
|
10
|
+
if merchant_not_latest?(id)
|
11
|
+
@rsqoot_merchant = get("merchants/#{id}", options)
|
12
|
+
@rsqoot_merchant = @rsqoot_merchant.merchant if @rsqoot_merchant
|
13
|
+
end
|
14
|
+
@rsqoot_merchant
|
11
15
|
end
|
12
16
|
end
|
13
17
|
end
|
data/lib/rsqoot/provider.rb
CHANGED
@@ -4,7 +4,11 @@ module RSqoot
|
|
4
4
|
#
|
5
5
|
# @return [Hashie::Mash]
|
6
6
|
def providers(options={})
|
7
|
-
|
7
|
+
if providers_not_latest?(options)
|
8
|
+
@rsqoot_providers = get('providers', options)
|
9
|
+
@rsqoot_providers = @rsqoot_providers.providers if @rsqoot_providers
|
10
|
+
end
|
11
|
+
@rsqoot_providers
|
8
12
|
end
|
9
13
|
end
|
10
14
|
end
|
data/lib/rsqoot/request.rb
CHANGED
@@ -5,28 +5,31 @@ require 'json'
|
|
5
5
|
module RSqoot
|
6
6
|
module Request
|
7
7
|
|
8
|
-
def get(path, opts = {}
|
9
|
-
uri
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
8
|
+
def get(path, opts = {})
|
9
|
+
uri, headers = url_generator(path, opts)
|
10
|
+
begin
|
11
|
+
json = JSON.parse uri.open(headers).read
|
12
|
+
::Hashie::Mash.new json
|
13
|
+
rescue
|
14
|
+
nil
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def url_generator(path, opts = {}, require_key = false)
|
19
|
+
uri = URI.parse base_api_url
|
20
|
+
headers = {read_timeout: read_timeout}
|
21
|
+
uri.path = '/v2/' + path
|
22
|
+
query = options_parser opts
|
23
|
+
endpoint = path.split('/')[0]
|
14
24
|
case authentication_method
|
15
25
|
when :header
|
16
26
|
headers.merge! h = {"Authorization" => "api_key #{api_key(endpoint)}"}
|
17
|
-
query = query + "&api_key=#{api_key(endpoint)}" if
|
27
|
+
query = query + "&api_key=#{api_key(endpoint)}" if require_key
|
18
28
|
when :parameter
|
19
29
|
query = query + "&api_key=#{api_key(endpoint)}"
|
20
30
|
end
|
21
31
|
uri.query = query
|
22
|
-
|
23
|
-
begin
|
24
|
-
json = JSON.parse uri.open(headers).read
|
25
|
-
::Hashie::Mash.new json
|
26
|
-
end
|
27
|
-
else
|
28
|
-
uri.to_s
|
29
|
-
end
|
32
|
+
[uri, headers]
|
30
33
|
end
|
31
34
|
|
32
35
|
private
|
data/lib/rsqoot/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rsqoot
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Felix Liu
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-11-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: hashie
|
@@ -60,6 +60,7 @@ files:
|
|
60
60
|
- lib/rsqoot/client.rb
|
61
61
|
- lib/rsqoot/commission.rb
|
62
62
|
- lib/rsqoot/deal.rb
|
63
|
+
- lib/rsqoot/helper.rb
|
63
64
|
- lib/rsqoot/merchant.rb
|
64
65
|
- lib/rsqoot/provider.rb
|
65
66
|
- lib/rsqoot/request.rb
|
@@ -75,17 +76,17 @@ require_paths:
|
|
75
76
|
- lib
|
76
77
|
required_ruby_version: !ruby/object:Gem::Requirement
|
77
78
|
requirements:
|
78
|
-
- - '>='
|
79
|
+
- - ! '>='
|
79
80
|
- !ruby/object:Gem::Version
|
80
81
|
version: '0'
|
81
82
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
82
83
|
requirements:
|
83
|
-
- - '>='
|
84
|
+
- - ! '>='
|
84
85
|
- !ruby/object:Gem::Version
|
85
86
|
version: '0'
|
86
87
|
requirements: []
|
87
88
|
rubyforge_project:
|
88
|
-
rubygems_version: 2.
|
89
|
+
rubygems_version: 2.1.10
|
89
90
|
signing_key:
|
90
91
|
specification_version: 4
|
91
92
|
summary: Wrapper for Sqoot API V2
|