rdstation-ruby-client 1.2.0 → 2.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. checksums.yaml +5 -5
  2. data/.github/ISSUE_TEMPLATE/rdsm-ruby-client-issue-template.md +49 -0
  3. data/.rspec +2 -0
  4. data/CHANGELOG.md +163 -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 -70
  13. data/lib/rdstation/contacts.rb +21 -16
  14. data/lib/rdstation/error.rb +22 -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 +29 -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 +153 -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 +40 -13
  43. data/Gemfile.lock +0 -59
  44. data/lib/rdstation/error_handler/default.rb +0 -15
  45. data/lib/rdstation/error_handler/resource_not_found.rb +0 -24
  46. data/spec/lib/rdstation/error_handler/default_spec.rb +0 -14
  47. data/spec/lib/rdstation/error_handler/resource_not_found_spec.rb +0 -54
@@ -1,59 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- rdstation-ruby-client (1.2.0)
5
- httparty (~> 0.12)
6
-
7
- GEM
8
- remote: https://rubygems.org/
9
- specs:
10
- addressable (2.5.2)
11
- public_suffix (>= 2.0.2, < 4.0)
12
- ansi (1.5.0)
13
- crack (0.4.3)
14
- safe_yaml (~> 1.0.0)
15
- diff-lcs (1.2.5)
16
- hashdiff (0.3.7)
17
- httparty (0.16.2)
18
- multi_xml (>= 0.5.2)
19
- minitest (4.7.5)
20
- multi_xml (0.6.0)
21
- public_suffix (3.0.2)
22
- rake (10.1.0)
23
- rspec (3.1.0)
24
- rspec-core (~> 3.1.0)
25
- rspec-expectations (~> 3.1.0)
26
- rspec-mocks (~> 3.1.0)
27
- rspec-core (3.1.7)
28
- rspec-support (~> 3.1.0)
29
- rspec-expectations (3.1.2)
30
- diff-lcs (>= 1.2.0, < 2.0)
31
- rspec-support (~> 3.1.0)
32
- rspec-mocks (3.1.3)
33
- rspec-support (~> 3.1.0)
34
- rspec-support (3.1.2)
35
- rspec_junit_formatter (0.3.0)
36
- rspec-core (>= 2, < 4, != 2.12.0)
37
- safe_yaml (1.0.4)
38
- turn (0.9.7)
39
- ansi
40
- minitest (~> 4)
41
- webmock (2.3.2)
42
- addressable (>= 2.3.6)
43
- crack (>= 0.3.2)
44
- hashdiff
45
-
46
- PLATFORMS
47
- ruby
48
-
49
- DEPENDENCIES
50
- bundler (~> 1.3)
51
- rake
52
- rdstation-ruby-client!
53
- rspec
54
- rspec_junit_formatter
55
- turn
56
- webmock (~> 2.1)
57
-
58
- BUNDLED WITH
59
- 1.16.1
@@ -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