rdstation-ruby-client 1.2.1 → 2.3.1

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.
Files changed (46) hide show
  1. checksums.yaml +4 -4
  2. data/.github/ISSUE_TEMPLATE/rdsm-ruby-client-issue-template.md +49 -0
  3. data/.rspec +2 -0
  4. data/CHANGELOG.md +167 -0
  5. data/README.md +243 -43
  6. data/lib/rdstation-ruby-client.rb +6 -0
  7. data/lib/rdstation.rb +19 -0
  8. data/lib/rdstation/api_response.rb +3 -3
  9. data/lib/rdstation/authentication.rb +32 -3
  10. data/lib/rdstation/authorization.rb +24 -0
  11. data/lib/rdstation/builder/field.rb +70 -0
  12. data/lib/rdstation/client.rb +17 -74
  13. data/lib/rdstation/contacts.rb +21 -16
  14. data/lib/rdstation/error.rb +23 -15
  15. data/lib/rdstation/error/format.rb +21 -3
  16. data/lib/rdstation/error/formatter.rb +53 -7
  17. data/lib/rdstation/error_handler.rb +31 -26
  18. data/lib/rdstation/error_handler/bad_request.rb +30 -0
  19. data/lib/rdstation/error_handler/unauthorized.rb +17 -9
  20. data/lib/rdstation/events.rb +7 -19
  21. data/lib/rdstation/fields.rb +31 -7
  22. data/lib/rdstation/retryable_request.rb +35 -0
  23. data/lib/rdstation/version.rb +1 -1
  24. data/lib/rdstation/webhooks.rb +25 -17
  25. data/rdstation-ruby-client.gemspec +4 -1
  26. data/spec/lib/rdstation-ruby-client_spec.rb +1 -1
  27. data/spec/lib/rdstation/api_response_spec.rb +34 -0
  28. data/spec/lib/rdstation/authentication_spec.rb +164 -0
  29. data/spec/lib/rdstation/authorization_spec.rb +24 -0
  30. data/spec/lib/rdstation/builder/field_spec.rb +69 -0
  31. data/spec/lib/rdstation/client_spec.rb +37 -0
  32. data/spec/lib/rdstation/contacts_spec.rb +54 -41
  33. data/spec/lib/rdstation/error/format_spec.rb +46 -0
  34. data/spec/lib/rdstation/error/formatter_spec.rb +83 -0
  35. data/spec/lib/rdstation/error_handler/unauthorized_spec.rb +0 -29
  36. data/spec/lib/rdstation/error_handler_spec.rb +162 -26
  37. data/spec/lib/rdstation/events_spec.rb +20 -9
  38. data/spec/lib/rdstation/fields_spec.rb +10 -3
  39. data/spec/lib/rdstation/retryable_request_spec.rb +142 -0
  40. data/spec/lib/rdstation/webhooks_spec.rb +41 -13
  41. data/spec/lib/rdstation_spec.rb +18 -0
  42. metadata +41 -12
  43. data/lib/rdstation/error_handler/default.rb +0 -15
  44. data/lib/rdstation/error_handler/resource_not_found.rb +0 -24
  45. data/spec/lib/rdstation/error_handler/default_spec.rb +0 -14
  46. data/spec/lib/rdstation/error_handler/resource_not_found_spec.rb +0 -54
@@ -1,15 +0,0 @@
1
- module RDStation
2
- class ErrorHandler
3
- class Default
4
- attr_reader :errors
5
-
6
- def initialize(errors)
7
- @errors = errors
8
- end
9
-
10
- def raise_error
11
- raise RDStation::Error::Default, errors.first
12
- end
13
- end
14
- end
15
- end
@@ -1,24 +0,0 @@
1
- module RDStation
2
- class ErrorHandler
3
- class ResourceNotFound
4
- attr_reader :errors
5
-
6
- ERROR_CODE = 'RESOURCE_NOT_FOUND'.freeze
7
-
8
- def initialize(errors)
9
- @errors = errors
10
- end
11
-
12
- def raise_error
13
- return if resource_not_found_errors.empty?
14
- raise RDStation::Error::ResourceNotFound, resource_not_found_errors.first
15
- end
16
-
17
- private
18
-
19
- def resource_not_found_errors
20
- errors.select { |error| error['error_type'] == ERROR_CODE }
21
- end
22
- end
23
- end
24
- end
@@ -1,14 +0,0 @@
1
- require 'spec_helper'
2
-
3
- RSpec.describe RDStation::ErrorHandler::Default do
4
- describe '#raise_error' do
5
- let(:errors) { [{ 'error_message' => 'Error Message' }] }
6
- let(:default_error) { described_class.new(errors) }
7
-
8
- it 'raises the received error' do
9
- expect do
10
- default_error.raise_error
11
- end.to raise_error(RDStation::Error::Default, errors.first['error_message'])
12
- end
13
- end
14
- end
@@ -1,54 +0,0 @@
1
- require 'spec_helper'
2
-
3
- RSpec.describe RDStation::ErrorHandler::ResourceNotFound do
4
- describe '#raise_error' do
5
-
6
- subject(:resource_not_found_error) { described_class.new(errors) }
7
-
8
- context 'when there is a resource not found error' do
9
- let(:errors) do
10
- [
11
- {
12
- 'error_message' => 'Error Message',
13
- 'error_type' => 'RESOURCE_NOT_FOUND'
14
- }
15
- ]
16
- end
17
-
18
- it 'raises an ResourceNotFound error' do
19
- expect do
20
- resource_not_found_error.raise_error
21
- end.to raise_error(RDStation::Error::ResourceNotFound, 'Error Message')
22
- end
23
- end
24
-
25
- context 'when none of the errors are resource not found errors' do
26
- let(:errors) do
27
- [
28
- {
29
- 'error_message' => 'Error Message',
30
- 'error_type' => 'RANDOM_ERROR_TYPE'
31
- },
32
- {
33
- 'error_message' => 'Another Error Message',
34
- 'error_type' => 'ANOTHER_RANDOM_ERROR_TYPE'
35
- }
36
- ]
37
- end
38
-
39
- it 'does not raise an ResourceNotFound error' do
40
- result = resource_not_found_error.raise_error
41
- expect(result).to be_nil
42
- end
43
- end
44
-
45
- context 'when there are no errors' do
46
- let(:errors) { [] }
47
-
48
- it 'does not raise an ResourceNotFound error' do
49
- result = resource_not_found_error.raise_error
50
- expect(result).to be_nil
51
- end
52
- end
53
- end
54
- end