trustedsearch 1.10.0 → 1.11.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 CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ZmRjZTJiNDgwZTM0YTc4MjMxNGE5YWE1ZGRhMjJmMzdhYWYwNjY1YQ==
4
+ YzIwYjM3NGI5ZjAxYWNiNzFhYjIwNmYzN2QyMGFmODYzYTE0MjVlMg==
5
5
  data.tar.gz: !binary |-
6
- YWNhYTMyZmViYzc0Zjc3YmFjZmZlNjI3MTkwMzBmYzFjY2Y5ZWI2NA==
6
+ NDk1ZmQwMjU3MDc4YmM5NTI5MWI5NDA2M2JlZjFiOGY3MzdiZWU3Mw==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- OTdkZjg0NTYyM2I4Y2ZiNzM5Y2ZiNGM0NjIwZmEyYzU0MTJkMTM5NmM0ODU0
10
- NjI1NWIzM2EyMzkxYWE2OTI0NzE0OTcyMmUwYTlmZGNjMzQyNTFjYTlkNzQx
11
- NGU3MWNiZTVlMzc0MTllYzBmYzg1OGYwMmZkOTc5YjdmNzM1NmY=
9
+ N2I1Y2EzYmRkNmQ4NWYxNWQ3NGUwOTgyMjllZDUyYTU4YzQ2OGNkNDYzYjFk
10
+ ZmRiMjYyYzVjYzQwNDkwYTA0MjkzODcwOGFhNTZkMzQwZGVlZmU2ZjFjOTQ2
11
+ ZjA0MzMzMDIxMmQ0YWY2YzdkMTZlZTI1NDZlMTdmYzRjMmZhMGE=
12
12
  data.tar.gz: !binary |-
13
- ZDUxYWFlNmJlZTQ3OTU0ZjM2MWRhNDZlMDU5ZTA0MmI2NWZlYTE4ZTdkZDEy
14
- MTZkNjVjODIxZGJhZGI3ZTg4OGIxZGRkZWIyMjQ4ODRmYjNmMmI2YWFhZmEy
15
- OGVkZGExOTM4YjQ4YmE2NjBkMzUzZjNmMzk1Y2EwYjA2ZmExZDE=
13
+ YTU0MTU2MjgxOWI5MDE0ZDljOTYzZjVmMzg2ZGJkMTRlNDNhZmEzYjAwOTI0
14
+ ZjM4Y2ViYWMwODIyMjJmYWU0NzFmY2ViYjQyMzUxMzU3MTBlODhhZGE2NDc0
15
+ MGNkYTA5NGQyN2I0OTJkMjQ5YmNjNmNlY2RlNDA3NTM3ODJlOWQ=
data/README.md CHANGED
@@ -122,6 +122,7 @@ business_data = {
122
122
 
123
123
  api = TrustedSearch::V1.new
124
124
  response = api.postValidate(business_data)
125
+ ```
125
126
 
126
127
  ##### Rake
127
128
  Validate single business record.
data/lib/trustedsearch.rb CHANGED
@@ -18,6 +18,7 @@ require_relative "trustedsearch/v2/hooks"
18
18
  require_relative "trustedsearch/v2/hook_subscriptions"
19
19
 
20
20
  require_relative "trustedsearch/errors/error"
21
+ require_relative "trustedsearch/errors/api_mock_response"
21
22
  require_relative "trustedsearch/errors/authentication_error"
22
23
  require_relative "trustedsearch/errors/connection_error"
23
24
  require_relative "trustedsearch/errors/invalid_request_error"
@@ -141,7 +141,6 @@ module TrustedSearch
141
141
  end
142
142
  end
143
143
 
144
-
145
144
  def request(method='get', resource_url, params, body)
146
145
  #puts resource_url
147
146
  #puts params.to_json
@@ -161,7 +160,8 @@ module TrustedSearch
161
160
  end
162
161
 
163
162
  rescue Timeout::Error
164
- raise ConnectionError.new("Timeout error (#{timeout}s)")
163
+ connection_response = ApiMockResponse.new("Timeout error (#{timeout}s)", nil, 500)
164
+ raise ConnectionError.new(connection_response)
165
165
  end
166
166
  process(response)
167
167
  end
@@ -0,0 +1,9 @@
1
+ class ApiMockResponse
2
+ attr_accessor :message, :body, :code
3
+
4
+ def initialize(message, body = nil, code = 500)
5
+ @message = message
6
+ @body = body
7
+ @code = code
8
+ end
9
+ end
@@ -4,8 +4,19 @@ module TrustedSearch
4
4
 
5
5
  def initialize(response = nil, code = nil )
6
6
 
7
- body = JSON.parse(response.body)
8
- @message = body['message']
7
+ @message = ''
8
+ body = ''
9
+ if(response.respond_to?("message"))
10
+ @message = response.message.to_s
11
+ end
12
+
13
+ if(response.respond_to?("body") && (response.body != nil))
14
+ body = JSON.parse(response.body.to_s)
15
+ # Use API message instead of exception message for more detail about issue when possible.
16
+ if(body.key?('message'))
17
+ @message = body['message']
18
+ end
19
+ end
9
20
  @code = code
10
21
  @body = body
11
22
 
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.10.0
4
+ version: 1.11.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - trustedSEARCH Team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-02 00:00:00.000000000 Z
11
+ date: 2014-06-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable
@@ -151,6 +151,7 @@ files:
151
151
  - lib/trustedsearch/api.rb
152
152
  - lib/trustedsearch/api_resource.rb
153
153
  - lib/trustedsearch/api_response.rb
154
+ - lib/trustedsearch/errors/api_mock_response.rb
154
155
  - lib/trustedsearch/errors/authentication_error.rb
155
156
  - lib/trustedsearch/errors/connection_error.rb
156
157
  - lib/trustedsearch/errors/error.rb