trustedsearch 1.0.6 → 1.0.7
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 +9 -9
- data/README.md +46 -2
- data/lib/tasks/test.rb +9 -3
- data/lib/tasks/v1.rake +6 -5
- data/lib/trustedsearch/api_resource.rb +14 -9
- data/lib/trustedsearch/errors/error.rb +8 -2
- data/lib/trustedsearch/version.rb +1 -1
- data/lib/trustedsearch.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
OTBjMTEzZmMyMzBhNzMwZjc4YmVhNTQyYTMyZjQ2NTQ5MmIzNDVmMQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
7
|
-
|
6
|
+
YWZhZGM3ZWI5MzdmMjhlMWQ0YjI1ZGY1NzRmYmI2ZTM0MDIxYTY5OA==
|
7
|
+
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
YmFhOGU1MmM4YjZkZTEwOGQ1OGE4NDU5OWJjNzRjNDk3ZWNlZmFiYjI3Y2E1
|
10
|
+
Yjc4NTQ5YzljMzlkYWFlZTEwMmQ4NGMyNDlhOWJhYTc5ZGYwOWRlODY0YzQ0
|
11
|
+
ZTE1N2Q1ZmUxZjEzMTIzNTRmYzU4NDJjZDc2NmQ5YWJmNThlYWU=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ZWQwYTY3YjI4MWUxNzFmZGE2ZjhlNDVhMzIxYmU5MmM3YmZiOTIwOTk4ODU5
|
14
|
+
YThhMGMwNTJjYzBkYTg2MjJmNjU0OGFhYjhmZTY1OTNmNzM1N2U4MzIxODAz
|
15
|
+
ODJmNTViOTA1NTdjNmRmNTdiMzM3MTBmM2MxNjMwM2Y1ZTdlNTU=
|
data/README.md
CHANGED
@@ -3,7 +3,9 @@ ruby-trustedsearch
|
|
3
3
|
trustedSEARCH Ruby Gem
|
4
4
|
|
5
5
|
|
6
|
-
Full Documentation: [http://developers.trustedsearch.org](http://developers.trustedsearch.org
|
6
|
+
Full Documentation: [http://developers.trustedsearch.org](http://developers.trustedsearch.org)
|
7
|
+
|
8
|
+
Ruby Gems: [https://rubygems.org/gems/trustedsearch](https://rubygems.org/gems/trustedsearch)
|
7
9
|
|
8
10
|
## <a id="requirement"></a>Requirements
|
9
11
|
|
@@ -150,6 +152,44 @@ response = api.putTestFulfillment(uuid)
|
|
150
152
|
|
151
153
|
```
|
152
154
|
|
155
|
+
### Error Handling
|
156
|
+
Exceptions are thrown when there is an api issue.
|
157
|
+
|
158
|
+
```ruby
|
159
|
+
|
160
|
+
since = ( args.since.nil? ? nil : args.since)
|
161
|
+
api = TrustedSearch::V1.new
|
162
|
+
begin
|
163
|
+
puts api.getBusinessUpdate(uuid, since).data.to_s
|
164
|
+
rescue Exception => e
|
165
|
+
puts "Message: " + e.message
|
166
|
+
puts "Body:"
|
167
|
+
puts e.body
|
168
|
+
puts "Code: " + e.code.to_s
|
169
|
+
|
170
|
+
end
|
171
|
+
|
172
|
+
```
|
173
|
+
|
174
|
+
Output: (Body is formatted for readability.)
|
175
|
+
|
176
|
+
```javascript
|
177
|
+
|
178
|
+
Message: Bummer, we couldn't save this record. You might have to fix a few things first and try again.
|
179
|
+
Body:
|
180
|
+
{
|
181
|
+
"status"=>"error",
|
182
|
+
"code"=>409,
|
183
|
+
"message"=>"Bummer, we couldn't save this record. You might have to fix a few things first and try again.",
|
184
|
+
"error"=>"ModelSaveFailedException",
|
185
|
+
"debug"=>"Model was unable to save, check validation errors.",
|
186
|
+
"validations"=>{"uuid"=>["The uuid field is required."],
|
187
|
+
"business_name"=>["The business name field is required."]},
|
188
|
+
"data"=>[]
|
189
|
+
}
|
190
|
+
Code: 409
|
191
|
+
|
192
|
+
```
|
153
193
|
|
154
194
|
|
155
195
|
### Rake Examples
|
@@ -168,4 +208,8 @@ Get update for location 534f95e8-1de1-558f-885c-3962f22c9a28 since 1380611103
|
|
168
208
|
|
169
209
|
Submit a new location using JSON data in file relative path "examples/body.json"
|
170
210
|
|
171
|
-
rake v1:submit[YourPublicKey,YourPrivateKey,"examples/body.json"]
|
211
|
+
rake v1:submit[YourPublicKey,YourPrivateKey,"examples/body.json"]
|
212
|
+
|
213
|
+
SANDBOX ONLY: Test the fulfilment process for development & testing purposes
|
214
|
+
|
215
|
+
rake v1:test_fulfillment[YourPublicKey,YourPrivateKey,534f95e8-1de1-558f-885c-3962f22c9a28]
|
data/lib/tasks/test.rb
CHANGED
@@ -1,8 +1,14 @@
|
|
1
|
-
require "trustedsearch"
|
1
|
+
require "../trustedsearch.rb"
|
2
2
|
|
3
3
|
TrustedSearch.public_key = "0e2e66593bd4e7423ab83b2ded17acfa"
|
4
4
|
TrustedSearch.private_key = "pakaThe3rupHuprEnupraCha"
|
5
5
|
TrustedSearch.environment = "sandbox" #default is 'sandbox'
|
6
6
|
|
7
|
-
|
8
|
-
|
7
|
+
begin
|
8
|
+
api = TrustedSearch::V1.new
|
9
|
+
puts api.getBusinessUpdate().data.to_s
|
10
|
+
puts "hi"
|
11
|
+
rescue Exception => e
|
12
|
+
puts "error"
|
13
|
+
puts e.message()
|
14
|
+
end
|
data/lib/tasks/v1.rake
CHANGED
@@ -17,16 +17,15 @@ namespace :v1 do
|
|
17
17
|
begin
|
18
18
|
puts api.getBusinessUpdate(uuid, since).data.to_s
|
19
19
|
rescue Exception => e
|
20
|
-
puts "
|
21
|
-
puts
|
20
|
+
puts "Message: " + e.message
|
21
|
+
puts "Body:"
|
22
22
|
puts e.body
|
23
|
-
puts e.code
|
23
|
+
puts "Code: " + e.code.to_s
|
24
24
|
end
|
25
25
|
|
26
26
|
end
|
27
27
|
|
28
28
|
desc "Submit a listings to be enhanced and created."
|
29
|
-
|
30
29
|
task :submit, [:public_key, :private_key, :file] do |t, args|
|
31
30
|
TrustedSearch.public_key = args.public_key
|
32
31
|
TrustedSearch.private_key = args.private_key
|
@@ -37,7 +36,6 @@ namespace :v1 do
|
|
37
36
|
next
|
38
37
|
end
|
39
38
|
|
40
|
-
|
41
39
|
file = File.open(body_file, "rb")
|
42
40
|
begin
|
43
41
|
api = TrustedSearch::V1.new
|
@@ -46,7 +44,10 @@ namespace :v1 do
|
|
46
44
|
puts response.code
|
47
45
|
puts response.data
|
48
46
|
rescue Exception => e
|
47
|
+
puts "Message: " + e.message
|
48
|
+
puts "Body:"
|
49
49
|
puts e.body
|
50
|
+
puts "Code: " + e.code.to_s
|
50
51
|
end
|
51
52
|
|
52
53
|
file.close
|
@@ -41,11 +41,13 @@ module TrustedSearch
|
|
41
41
|
|
42
42
|
url_to_sign = base_path + api_resource
|
43
43
|
|
44
|
-
params.merge!(
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
44
|
+
params.merge!(
|
45
|
+
{
|
46
|
+
apikey: TrustedSearch.public_key,
|
47
|
+
signature: sign_request(TrustedSearch.private_key, url_to_sign, body, timestamp ),
|
48
|
+
timestamp: timestamp
|
49
|
+
}
|
50
|
+
)
|
49
51
|
|
50
52
|
resource_url = end_point + url_to_sign
|
51
53
|
request('get', resource_url, params, body)
|
@@ -138,16 +140,19 @@ module TrustedSearch
|
|
138
140
|
|
139
141
|
|
140
142
|
def process(response)
|
141
|
-
#puts response.code
|
143
|
+
# puts response.code
|
144
|
+
# body = JSON.parse(response.body)
|
145
|
+
# puts body.to_json
|
146
|
+
# puts response.message
|
142
147
|
|
143
148
|
case response.code
|
144
149
|
|
145
150
|
when 200, 201, 204
|
146
151
|
APIResponse.new(response)
|
147
|
-
when 400, 404
|
148
|
-
raise InvalidRequestError.new(response
|
152
|
+
when 400, 404, 409
|
153
|
+
raise InvalidRequestError.new(response, response.code)
|
149
154
|
when 401
|
150
|
-
raise AuthenticationError.new(response
|
155
|
+
raise AuthenticationError.new(response, response.code)
|
151
156
|
else
|
152
157
|
error = Error.new(response.message, response.code)
|
153
158
|
error.body = response.body
|
@@ -2,10 +2,12 @@ module TrustedSearch
|
|
2
2
|
class Error < StandardError
|
3
3
|
attr_accessor :message, :code, :body
|
4
4
|
|
5
|
-
def initialize(
|
5
|
+
def initialize(response = nil, code = nil )
|
6
6
|
|
7
|
-
|
7
|
+
body = JSON.parse(response.body)
|
8
|
+
@message = body['message']
|
8
9
|
@code = code
|
10
|
+
@body = body
|
9
11
|
|
10
12
|
end
|
11
13
|
|
@@ -14,6 +16,10 @@ module TrustedSearch
|
|
14
16
|
"#{message}#{code_string}"
|
15
17
|
end
|
16
18
|
|
19
|
+
def message
|
20
|
+
@message
|
21
|
+
end
|
22
|
+
|
17
23
|
|
18
24
|
end
|
19
25
|
end
|
data/lib/trustedsearch.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: trustedsearch
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- trustedSEARCH Team
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-11-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: addressable
|
@@ -175,7 +175,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
175
175
|
version: '0'
|
176
176
|
requirements: []
|
177
177
|
rubyforge_project:
|
178
|
-
rubygems_version: 2.
|
178
|
+
rubygems_version: 2.1.11
|
179
179
|
signing_key:
|
180
180
|
specification_version: 4
|
181
181
|
summary: trustedSEARCH API Ruby SDK
|