invisiblehand 0.1.0 → 0.1.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.
- data/README.md +1 -3
- data/lib/invisiblehand/api.rb +5 -4
- data/lib/invisiblehand/errors.rb +19 -2
- data/lib/invisiblehand/version.rb +1 -1
- metadata +4 -4
data/README.md
CHANGED
@@ -54,11 +54,9 @@ api.products({
|
|
54
54
|
#=> A massive hash that you can find details of at:
|
55
55
|
# https://developer.getinvisiblehand.com/documentation
|
56
56
|
|
57
|
-
# Search for products
|
58
|
-
# options
|
57
|
+
# Search for products with sorting and ordering and a specific size.
|
59
58
|
api.products({
|
60
59
|
:query => "galaxy", # Search term
|
61
|
-
:region => "ca", # Which region to query
|
62
60
|
:sort => "popularity", # What to order results by
|
63
61
|
:order => "desc", # Direction to order results by
|
64
62
|
:size => "100" # Number of results to return
|
data/lib/invisiblehand/api.rb
CHANGED
@@ -37,9 +37,10 @@ module InvisibleHand
|
|
37
37
|
# The @config[:development] flag exists to bypass the app_id and app_key
|
38
38
|
# check in this gem (not on the server) for internal testing reasons.
|
39
39
|
if valid_config?
|
40
|
-
|
41
|
-
"
|
42
|
-
|
40
|
+
message = "Your config does not contain an app_id and app_key. " +
|
41
|
+
"Both are required to make API calls."
|
42
|
+
|
43
|
+
raise Error::InvalidConfig.new message, @config
|
43
44
|
end
|
44
45
|
|
45
46
|
@config[:protocol] = @config[:use_ssl] == false ? "http://" : "https://"
|
@@ -90,7 +91,7 @@ module InvisibleHand
|
|
90
91
|
logger.debug "API call took #{elapsed.round(3)} seconds."
|
91
92
|
logger.debug "API json response: #{json.inspect}"
|
92
93
|
|
93
|
-
raise Error::APIError.new(json["error"]) if json["error"]
|
94
|
+
raise Error::APIError.new(json["error"], url) if json["error"]
|
94
95
|
|
95
96
|
json
|
96
97
|
end
|
data/lib/invisiblehand/errors.rb
CHANGED
@@ -1,6 +1,23 @@
|
|
1
1
|
module InvisibleHand
|
2
2
|
module Error
|
3
|
-
class InvalidConfig < StandardError
|
4
|
-
|
3
|
+
class InvalidConfig < StandardError
|
4
|
+
attr_accessor :config
|
5
|
+
|
6
|
+
def initialize message, config
|
7
|
+
super message
|
8
|
+
|
9
|
+
@config = config
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
class APIError < StandardError
|
14
|
+
attr_accessor :url
|
15
|
+
|
16
|
+
def initialize message, url
|
17
|
+
super message
|
18
|
+
|
19
|
+
@url = url
|
20
|
+
end
|
21
|
+
end
|
5
22
|
end
|
6
23
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: invisiblehand
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-02-
|
12
|
+
date: 2013-02-21 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rest-client
|
@@ -110,7 +110,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
110
110
|
version: '0'
|
111
111
|
segments:
|
112
112
|
- 0
|
113
|
-
hash:
|
113
|
+
hash: 1889337055537833862
|
114
114
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
115
115
|
none: false
|
116
116
|
requirements:
|
@@ -119,7 +119,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
119
119
|
version: '0'
|
120
120
|
segments:
|
121
121
|
- 0
|
122
|
-
hash:
|
122
|
+
hash: 1889337055537833862
|
123
123
|
requirements: []
|
124
124
|
rubyforge_project:
|
125
125
|
rubygems_version: 1.8.24
|