trustedsearch 1.0.5 → 1.0.6

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
- MTgyOWNiNjE2MWQ1YTcyZjkyM2FkNDgyNjc5ZWM1YmJhMjljZjliMQ==
4
+ ZTliOWU1N2I0MWVjNTM3MWMzMTk1MjA2MThhODQzOGQ5ZTFkNmVkZA==
5
5
  data.tar.gz: !binary |-
6
- Zjc0Y2U2YjQyZDU0NTc1YTFkNTQ0ZDMwZGM1Y2E2NjQ3NWJjYzNhMw==
6
+ NTE4NmZhN2NkOGI3M2JmYzQ2OGVmNjBlYmUzNGFjMjRhYzIxYTkxNw==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- ZjYzMzU0ODQwODcxYjM3YzkzM2M1ZWEyMWMxMjg1MTc3ODZhMjlhYjZiNzUz
10
- YzBhMTM4ZThiYzhkNjIyOTM2M2JjZThkMTYwNGJjYzlhNGRkYjJjZWNhM2I5
11
- ZGE0NmJiYzE5MjA3NDU4NzY3N2NkYjZhNDcwNmM5MWMyYWNhMjk=
9
+ MmQ4OTViMTlhZjZiMDIzYjM3NWIwMTU5Y2RjNmM3ZWM0YmZlYjE1NzMxZDQ5
10
+ MzYwOTBhMzgyZmY0ZjZhMTY1NTVkYTY5ODU3M2VjYzRiZWU5MDYxMWExMWUw
11
+ M2MxMjgwYTFlNjgyM2RkYTEzM2M2MDc3OTU3NmQwOGMxYWMzOGU=
12
12
  data.tar.gz: !binary |-
13
- NzEzZDE0M2VkZjFkM2MyNGNhMTE5MGYzOWYwYTYwZjhkNGE2Yzg4OWRkYWVh
14
- MGFjYTc2MWM2ZDY3NWRhNDU2OWQ3YTU0NTk2NTMxZGFkZjgxZTViMTFjZTJm
15
- YzUyZDcyNGIxNTFiNmViZDYyYTVhMTliZGE5MjcwZDk3M2Y0MWM=
13
+ NjQ1MGNjMzQ4NWNhNjhjYzMyZWJiZTcyZTU2ZDZjMGI2YzU5YmIzN2EwNWVi
14
+ MWY1OGY2NjQ1NGRhN2NmMjhkZDdmMWUwZjdmOGE5YTI3Yzc3YjYzMDBjYzQ1
15
+ ODlmYmE4NzQ2ZTUzZDQ3MTA5MWY2NjFmNDZlODMxNGVhNTMzZTg=
data/lib/tasks/v1.rake CHANGED
@@ -14,7 +14,15 @@ namespace :v1 do
14
14
  end
15
15
  since = ( args.since.nil? ? nil : args.since)
16
16
  api = TrustedSearch::V1.new
17
- puts api.getBusinessUpdate(uuid, since).data.to_s
17
+ begin
18
+ puts api.getBusinessUpdate(uuid, since).data.to_s
19
+ rescue Exception => e
20
+ puts "Error"
21
+ puts e.message
22
+ puts e.body
23
+ puts e.code
24
+ end
25
+
18
26
  end
19
27
 
20
28
  desc "Submit a listings to be enhanced and created."
@@ -29,12 +37,20 @@ namespace :v1 do
29
37
  next
30
38
  end
31
39
 
32
- api = TrustedSearch::V1.new
40
+
33
41
  file = File.open(body_file, "rb")
34
- contents = file.read
35
- response = api.postBusiness(JSON.parse(contents))
42
+ begin
43
+ api = TrustedSearch::V1.new
44
+ contents = file.read
45
+ response = api.postBusiness(JSON.parse(contents))
46
+ puts response.code
47
+ puts response.data
48
+ rescue Exception => e
49
+ puts e.body
50
+ end
51
+
36
52
  file.close
37
- puts response.data
53
+
38
54
  end
39
55
 
40
56
  task :test_fulfillment, [:public_key, :private_key, :uuid] do |t, args|
@@ -51,7 +67,15 @@ namespace :v1 do
51
67
  end
52
68
 
53
69
  api = TrustedSearch::V1.new
54
- response = api.putTestFulfillment(location_id)
55
- puts response.data
70
+
71
+ begin
72
+ response = api.putTestFulfillment(location_id)
73
+ puts response.code
74
+ puts response.data
75
+ rescue Exception => e
76
+ puts e.body
77
+ end
78
+
79
+
56
80
  end
57
81
  end
@@ -138,9 +138,10 @@ module TrustedSearch
138
138
 
139
139
 
140
140
  def process(response)
141
- #puts response.to_json
141
+ #puts response.code
142
142
 
143
143
  case response.code
144
+
144
145
  when 200, 201, 204
145
146
  APIResponse.new(response)
146
147
  when 400, 404
@@ -148,8 +149,12 @@ module TrustedSearch
148
149
  when 401
149
150
  raise AuthenticationError.new(response.message, response.code)
150
151
  else
151
- raise Error.new(response.message, response.code)
152
+ error = Error.new(response.message, response.code)
153
+ error.body = response.body
154
+ raise error
155
+
152
156
  end
157
+
153
158
  end
154
159
  end
155
160
  end
@@ -1,10 +1,13 @@
1
1
  module TrustedSearch
2
2
  class APIResponse
3
- attr_reader :meta, :data, :request
3
+ attr_reader :meta, :data, :request, :code
4
4
 
5
5
  def initialize(response)
6
6
  @request = response.request
7
- @data = response.body.strip.to_json
7
+ @code = response.code
8
+ #handle case where body has no response and thus JSON.parse requires octet aka a byte.
9
+ @data = (response.body.length >=2) ? JSON.parse(response.body.strip) : nil
10
+
8
11
  end
9
12
 
10
13
  end
@@ -1,15 +1,19 @@
1
1
  module TrustedSearch
2
2
  class Error < StandardError
3
- attr_reader :message, :code
3
+ attr_accessor :message, :code, :body
4
+
5
+ def initialize(message = nil, code = nil )
4
6
 
5
- def initialize(message = nil, code = nil)
6
7
  @message = message
7
8
  @code = code
9
+
8
10
  end
9
11
 
10
12
  def to_s
11
13
  code_string = code.nil? ? "" : " (Code #{code})"
12
14
  "#{message}#{code_string}"
13
15
  end
16
+
17
+
14
18
  end
15
19
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: trustedsearch
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.5
4
+ version: 1.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - trustedSEARCH Team