docusign_dtr 0.3.2 → 0.3.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 65d316f60d05b3daca51ba5e8ba96bbcf3882d77
4
- data.tar.gz: 7c7deb709fee8e487ac7a957b769f499784e2974
2
+ SHA256:
3
+ metadata.gz: 304f53ac13abf8675980078b6726e011b97dccd04ea8f66960b9fdbd011bf295
4
+ data.tar.gz: 553f4afc451445758c905ffe41daf0dd08f624711249d0c743e929d49242854a
5
5
  SHA512:
6
- metadata.gz: d0add2e061bbc8034ee8d3df4c9340153df2bc62eaf0b8d2f049dca7f61a0057146b567f1896c8f231d89dec3373b7b6221b7ad0ed2d1c94b8879be22142dea0
7
- data.tar.gz: bc155de1fc63efc5ae81566cb5fcca62868b8c159389e8c061ec040e43659e630fe2df61ef9702f5f606da19dbe3236f50207c2d3e23a0639f7aef475c9effdf
6
+ metadata.gz: ac44253fbc773477faeffed5681d1a6c701aca29fd7de7d339f6d0e19b734a41556f372008150f0b556ee615e790d38e18d0b5e7ea6822e20db50556e8d7bdbd
7
+ data.tar.gz: e111da02dd6d52ae6da28e2dc522f5c1bd8d07393c4f0246d3e08dd7bb4204a6ce5c909757a70a8050142ec900fee2b5aeb1dd9144cc33084ff3ba5423f81cd3
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -8,6 +8,7 @@ require 'docusign_dtr/exceptions'
8
8
  require 'docusign_dtr/auth/base'
9
9
  require 'docusign_dtr/auth/code'
10
10
  require 'docusign_dtr/auth/jwt'
11
+ require 'docusign_dtr/auth/error'
11
12
  require 'docusign_dtr/client'
12
13
  require 'docusign_dtr/activity'
13
14
  require 'docusign_dtr/document'
@@ -65,25 +65,7 @@ module DocusignDtr
65
65
  end
66
66
 
67
67
  def handle_error(response)
68
- raise error_type(response), "Error communicating: Response code #{response.code}"
69
- end
70
-
71
- def error_type(response)
72
- case response.code
73
- when 400
74
- # {"error":"invalid_grant"}
75
- return DocusignDtr::InvalidGrant if response.parsed_response['error'].match?(/grant/)
76
-
77
- DocusignDtr::ConsentRequired # {"error":"consent_required"}
78
- when 401
79
- DocusignDtr::Unauthorized
80
- when 403
81
- DocusignDtr::Forbidden
82
- when 204
83
- DocusignDtr::NoContent
84
- else
85
- StandardError
86
- end
68
+ raise DocusignDtr::Auth::Error.new(response: response).build
87
69
  end
88
70
  end
89
71
  end
@@ -0,0 +1,53 @@
1
+ module DocusignDtr
2
+ module Auth
3
+ class Error
4
+ def initialize(response:)
5
+ @response = response
6
+ end
7
+
8
+ def build
9
+ return nil if @response.code == 200
10
+
11
+ exception.new(full_message)
12
+ end
13
+
14
+ def full_message
15
+ "Error communicating: Response code #{@response.code}"
16
+ end
17
+
18
+ def exception
19
+ case @response.code
20
+ when 400
21
+ general_error
22
+ when 401
23
+ DocusignDtr::Unauthorized
24
+ when 403
25
+ DocusignDtr::Forbidden
26
+ when 204
27
+ DocusignDtr::NoContent
28
+ else
29
+ StandardError
30
+ end
31
+ end
32
+
33
+ private
34
+
35
+ def general_error
36
+ return DocusignDtr::InvalidGrant if error_code.match?(/grant/)
37
+ return DocusignDtr::ApiLimitExceeded if error_code.match?(/HOURLY_APIINVOCATION_LIMIT_EXCEEDED/)
38
+
39
+ DocusignDtr::ConsentRequired
40
+ end
41
+
42
+ def error_code
43
+ return '' unless parsed_response
44
+
45
+ @error_code ||= parsed_response.fetch(:error) || parsed_response.fetch(:errorCode, '')
46
+ end
47
+
48
+ def parsed_response
49
+ @parsed_response ||= @response.parsed_response&.transform_keys(&:to_sym)
50
+ end
51
+ end
52
+ end
53
+ end
@@ -23,7 +23,7 @@ module DocusignDtr
23
23
  end
24
24
 
25
25
  def handle_error(response)
26
- raise error_type(response), "Error communicating: Response code #{response.code}"
26
+ raise DocusignDtr::Auth::Error.new(response: response).build
27
27
  end
28
28
 
29
29
  def Document # rubocop:disable Naming/MethodName
@@ -179,23 +179,5 @@ module DocusignDtr
179
179
  object.to_snake_keys
180
180
  end
181
181
  end
182
-
183
- def error_type(response)
184
- case response.code
185
- when 400
186
- # {"error":"invalid_grant"}
187
- return DocusignDtr::InvalidGrant if response.parsed_response['error'].match?(/grant/)
188
-
189
- DocusignDtr::ConsentRequired # {"error":"consent_required"}
190
- when 401
191
- DocusignDtr::Unauthorized
192
- when 403
193
- DocusignDtr::Forbidden
194
- when 204
195
- DocusignDtr::NoContent
196
- else
197
- StandardError
198
- end
199
- end
200
182
  end
201
183
  end
@@ -1,8 +1,9 @@
1
1
  module DocusignDtr
2
+ class ApiLimitExceeded < StandardError; end
2
3
  class ConsentRequired < StandardError; end
4
+ class Forbidden < StandardError; end
3
5
  class InvalidGrant < StandardError; end
4
6
  class InvalidParameter < StandardError; end
5
- class Forbidden < StandardError; end
6
7
  class NoContent < StandardError; end
7
8
  class Unauthorized < StandardError; end
8
9
  end
@@ -1,3 +1,3 @@
1
1
  module DocusignDtr
2
- VERSION = '0.3.2'.freeze
2
+ VERSION = '0.3.3'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: docusign_dtr
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Loft47
@@ -34,7 +34,7 @@ cert_chain:
34
34
  WPTyTwBv5qAL48mT3OBIV99mY13XurTi2s2OCJAgkQZIQlGsFzmT/4IDYivCoABO
35
35
  QVWtuf6LfMkXYW5shBsTlpiGbXeVlm0QW2Av3w==
36
36
  -----END CERTIFICATE-----
37
- date: 2018-10-25 00:00:00.000000000 Z
37
+ date: 2018-11-02 00:00:00.000000000 Z
38
38
  dependencies:
39
39
  - !ruby/object:Gem::Dependency
40
40
  name: coveralls
@@ -242,6 +242,7 @@ files:
242
242
  - lib/docusign_dtr/activity.rb
243
243
  - lib/docusign_dtr/auth/base.rb
244
244
  - lib/docusign_dtr/auth/code.rb
245
+ - lib/docusign_dtr/auth/error.rb
245
246
  - lib/docusign_dtr/auth/jwt.rb
246
247
  - lib/docusign_dtr/client.rb
247
248
  - lib/docusign_dtr/document.rb
@@ -332,7 +333,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
332
333
  version: '0'
333
334
  requirements: []
334
335
  rubyforge_project:
335
- rubygems_version: 2.6.14
336
+ rubygems_version: 2.7.6
336
337
  signing_key:
337
338
  specification_version: 4
338
339
  summary: Docusign DTR library
metadata.gz.sig CHANGED
Binary file