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 CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ZTliOWU1N2I0MWVjNTM3MWMzMTk1MjA2MThhODQzOGQ5ZTFkNmVkZA==
4
+ OTBjMTEzZmMyMzBhNzMwZjc4YmVhNTQyYTMyZjQ2NTQ5MmIzNDVmMQ==
5
5
  data.tar.gz: !binary |-
6
- NTE4NmZhN2NkOGI3M2JmYzQ2OGVmNjBlYmUzNGFjMjRhYzIxYTkxNw==
7
- !binary "U0hBNTEy":
6
+ YWZhZGM3ZWI5MzdmMjhlMWQ0YjI1ZGY1NzRmYmI2ZTM0MDIxYTY5OA==
7
+ SHA512:
8
8
  metadata.gz: !binary |-
9
- MmQ4OTViMTlhZjZiMDIzYjM3NWIwMTU5Y2RjNmM3ZWM0YmZlYjE1NzMxZDQ5
10
- MzYwOTBhMzgyZmY0ZjZhMTY1NTVkYTY5ODU3M2VjYzRiZWU5MDYxMWExMWUw
11
- M2MxMjgwYTFlNjgyM2RkYTEzM2M2MDc3OTU3NmQwOGMxYWMzOGU=
9
+ YmFhOGU1MmM4YjZkZTEwOGQ1OGE4NDU5OWJjNzRjNDk3ZWNlZmFiYjI3Y2E1
10
+ Yjc4NTQ5YzljMzlkYWFlZTEwMmQ4NGMyNDlhOWJhYTc5ZGYwOWRlODY0YzQ0
11
+ ZTE1N2Q1ZmUxZjEzMTIzNTRmYzU4NDJjZDc2NmQ5YWJmNThlYWU=
12
12
  data.tar.gz: !binary |-
13
- NjQ1MGNjMzQ4NWNhNjhjYzMyZWJiZTcyZTU2ZDZjMGI2YzU5YmIzN2EwNWVi
14
- MWY1OGY2NjQ1NGRhN2NmMjhkZDdmMWUwZjdmOGE5YTI3Yzc3YjYzMDBjYzQ1
15
- ODlmYmE4NzQ2ZTUzZDQ3MTA5MWY2NjFmNDZlODMxNGVhNTMzZTg=
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
- api = TrustedSearch::V1.new
8
- puts api.getBusinessUpdate().data.to_s
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 "Error"
21
- puts e.message
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
- apikey: TrustedSearch.public_key,
46
- signature: sign_request(TrustedSearch.private_key, url_to_sign, body, timestamp ),
47
- timestamp: timestamp
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.message, response.code)
152
+ when 400, 404, 409
153
+ raise InvalidRequestError.new(response, response.code)
149
154
  when 401
150
- raise AuthenticationError.new(response.message, response.code)
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(message = nil, code = nil )
5
+ def initialize(response = nil, code = nil )
6
6
 
7
- @message = message
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
@@ -1,3 +1,3 @@
1
1
  module TrustedSearch
2
- VERSION = "1.0.1"
2
+ VERSION = "1.0.7"
3
3
  end
data/lib/trustedsearch.rb CHANGED
@@ -31,7 +31,7 @@ module TrustedSearch
31
31
  }
32
32
  }
33
33
 
34
- @api_base_url = "http://api.trustedsearch.org"
34
+ @api_base_url = "https://api.trustedsearch.org"
35
35
  @api_version = 1
36
36
  @api_timeout = 30
37
37
  @environment = 'sandbox'
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.6
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-10-28 00:00:00.000000000 Z
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.0.5
178
+ rubygems_version: 2.1.11
179
179
  signing_key:
180
180
  specification_version: 4
181
181
  summary: trustedSEARCH API Ruby SDK