rdstation-ruby-client 2.1.0 → 2.5.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.
Files changed (40) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG.md +121 -1
  3. data/README.md +106 -22
  4. data/Rakefile +4 -0
  5. data/lib/rdstation-ruby-client.rb +6 -1
  6. data/lib/rdstation.rb +19 -0
  7. data/lib/rdstation/api_response.rb +1 -2
  8. data/lib/rdstation/authentication.rb +8 -3
  9. data/lib/rdstation/{authorization_header.rb → authorization.rb} +11 -8
  10. data/lib/rdstation/builder/field.rb +70 -0
  11. data/lib/rdstation/client.rb +17 -7
  12. data/lib/rdstation/contacts.rb +22 -13
  13. data/lib/rdstation/error.rb +3 -0
  14. data/lib/rdstation/error/format.rb +29 -3
  15. data/lib/rdstation/error/formatter.rb +69 -8
  16. data/lib/rdstation/error_handler.rb +6 -1
  17. data/lib/rdstation/error_handler/invalid_refresh_token.rb +24 -0
  18. data/lib/rdstation/error_handler/unauthorized.rb +2 -0
  19. data/lib/rdstation/events.rb +7 -12
  20. data/lib/rdstation/fields.rb +35 -6
  21. data/lib/rdstation/retryable_request.rb +35 -0
  22. data/lib/rdstation/version.rb +1 -1
  23. data/lib/rdstation/webhooks.rb +25 -13
  24. data/rdstation-ruby-client.gemspec +2 -1
  25. data/spec/lib/rdstation/api_response_spec.rb +34 -0
  26. data/spec/lib/rdstation/authentication_spec.rb +105 -2
  27. data/spec/lib/rdstation/{authorization_header_spec.rb → authorization_spec.rb} +3 -3
  28. data/spec/lib/rdstation/builder/field_spec.rb +69 -0
  29. data/spec/lib/rdstation/client_spec.rb +6 -6
  30. data/spec/lib/rdstation/contacts_spec.rb +23 -3
  31. data/spec/lib/rdstation/error/format_spec.rb +63 -0
  32. data/spec/lib/rdstation/error/formatter_spec.rb +113 -0
  33. data/spec/lib/rdstation/error_handler/invalid_refresh_token_spec.rb +53 -0
  34. data/spec/lib/rdstation/error_handler_spec.rb +23 -0
  35. data/spec/lib/rdstation/events_spec.rb +8 -3
  36. data/spec/lib/rdstation/fields_spec.rb +6 -1
  37. data/spec/lib/rdstation/retryable_request_spec.rb +142 -0
  38. data/spec/lib/rdstation/webhooks_spec.rb +26 -1
  39. data/spec/lib/rdstation_spec.rb +18 -0
  40. metadata +36 -8
@@ -2,7 +2,7 @@ require 'spec_helper'
2
2
 
3
3
  RSpec.describe RDStation::Webhooks do
4
4
  let(:webhooks_client) do
5
- described_class.new(authorization_header: RDStation::AuthorizationHeader.new(access_token: 'access_token'))
5
+ described_class.new(authorization: RDStation::Authorization.new(access_token: 'access_token'))
6
6
  end
7
7
 
8
8
  let(:webhooks_endpoint) { 'https://api.rd.services/integrations/webhooks/' }
@@ -23,6 +23,11 @@ RSpec.describe RDStation::Webhooks do
23
23
  end
24
24
 
25
25
  describe '#all' do
26
+ it 'calls retryable_request' do
27
+ expect(webhooks_client).to receive(:retryable_request)
28
+ webhooks_client.all
29
+ end
30
+
26
31
  context 'when the request is successful' do
27
32
  let(:webhooks) do
28
33
  {
@@ -77,6 +82,11 @@ RSpec.describe RDStation::Webhooks do
77
82
  let(:uuid) { '5408c5a3-4711-4f2e-8d0b-13407a3e30f3' }
78
83
  let(:webhooks_endpoint_by_uuid) { webhooks_endpoint + uuid }
79
84
 
85
+ it 'calls retryable_request' do
86
+ expect(webhooks_client).to receive(:retryable_request)
87
+ webhooks_client.by_uuid('uuid')
88
+ end
89
+
80
90
  context 'when the request is successful' do
81
91
  let(:webhook) do
82
92
  {
@@ -126,6 +136,11 @@ RSpec.describe RDStation::Webhooks do
126
136
  }
127
137
  end
128
138
 
139
+ it 'calls retryable_request' do
140
+ expect(webhooks_client).to receive(:retryable_request)
141
+ webhooks_client.create('payload')
142
+ end
143
+
129
144
  context 'when the request is successful' do
130
145
  let(:webhook) do
131
146
  {
@@ -177,6 +192,11 @@ RSpec.describe RDStation::Webhooks do
177
192
  }
178
193
  end
179
194
 
195
+ it 'calls retryable_request' do
196
+ expect(webhooks_client).to receive(:retryable_request)
197
+ webhooks_client.update('uuid', 'payload')
198
+ end
199
+
180
200
  context 'when the request is successful' do
181
201
  let(:updated_webhook) do
182
202
  {
@@ -219,6 +239,11 @@ RSpec.describe RDStation::Webhooks do
219
239
  let(:uuid) { '5408c5a3-4711-4f2e-8d0b-13407a3e30f3' }
220
240
  let(:webhooks_endpoint_by_uuid) { webhooks_endpoint + uuid }
221
241
 
242
+ it 'calls retryable_request' do
243
+ expect(webhooks_client).to receive(:retryable_request)
244
+ webhooks_client.delete('uuid')
245
+ end
246
+
222
247
  context 'when the request is successful' do
223
248
  before do
224
249
  stub_request(:delete, webhooks_endpoint_by_uuid).with(headers: headers).to_return(status: 204)
@@ -0,0 +1,18 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe RDStation do
4
+ describe '.configure' do
5
+ let(:client_id) { 'client_id' }
6
+ let(:client_secret) { 'client_secret' }
7
+
8
+ it 'sets the configuration' do
9
+ RDStation.configure do |config|
10
+ config.client_id = client_id
11
+ config.client_secret = client_secret
12
+ end
13
+
14
+ expect(RDStation.configuration.client_id).to eq client_id
15
+ expect(RDStation.configuration.client_secret).to eq client_secret
16
+ end
17
+ end
18
+ end
metadata CHANGED
@@ -1,27 +1,27 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rdstation-ruby-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0
4
+ version: 2.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Paulo L F Casaretto
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-05-15 00:00:00.000000000 Z
11
+ date: 2020-09-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">"
18
18
  - !ruby/object:Gem::Version
19
19
  version: '1.3'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ">"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.3'
27
27
  - !ruby/object:Gem::Dependency
@@ -94,6 +94,20 @@ dependencies:
94
94
  - - ">="
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: pry
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
97
111
  - !ruby/object:Gem::Dependency
98
112
  name: httparty
99
113
  requirement: !ruby/object:Gem::Requirement
@@ -125,9 +139,11 @@ files:
125
139
  - README.md
126
140
  - Rakefile
127
141
  - lib/rdstation-ruby-client.rb
142
+ - lib/rdstation.rb
128
143
  - lib/rdstation/api_response.rb
129
144
  - lib/rdstation/authentication.rb
130
- - lib/rdstation/authorization_header.rb
145
+ - lib/rdstation/authorization.rb
146
+ - lib/rdstation/builder/field.rb
131
147
  - lib/rdstation/client.rb
132
148
  - lib/rdstation/contacts.rb
133
149
  - lib/rdstation/error.rb
@@ -140,15 +156,19 @@ files:
140
156
  - lib/rdstation/error_handler/expired_code_grant.rb
141
157
  - lib/rdstation/error_handler/invalid_credentials.rb
142
158
  - lib/rdstation/error_handler/invalid_event_type.rb
159
+ - lib/rdstation/error_handler/invalid_refresh_token.rb
143
160
  - lib/rdstation/error_handler/unauthorized.rb
144
161
  - lib/rdstation/events.rb
145
162
  - lib/rdstation/fields.rb
163
+ - lib/rdstation/retryable_request.rb
146
164
  - lib/rdstation/version.rb
147
165
  - lib/rdstation/webhooks.rb
148
166
  - rdstation-ruby-client.gemspec
149
167
  - spec/lib/rdstation-ruby-client_spec.rb
168
+ - spec/lib/rdstation/api_response_spec.rb
150
169
  - spec/lib/rdstation/authentication_spec.rb
151
- - spec/lib/rdstation/authorization_header_spec.rb
170
+ - spec/lib/rdstation/authorization_spec.rb
171
+ - spec/lib/rdstation/builder/field_spec.rb
152
172
  - spec/lib/rdstation/client_spec.rb
153
173
  - spec/lib/rdstation/contacts_spec.rb
154
174
  - spec/lib/rdstation/error/format_spec.rb
@@ -158,12 +178,15 @@ files:
158
178
  - spec/lib/rdstation/error_handler/expired_code_grant_spec.rb
159
179
  - spec/lib/rdstation/error_handler/invalid_credentials_spec.rb
160
180
  - spec/lib/rdstation/error_handler/invalid_event_type_spec.rb
181
+ - spec/lib/rdstation/error_handler/invalid_refresh_token_spec.rb
161
182
  - spec/lib/rdstation/error_handler/unauthorized_spec.rb
162
183
  - spec/lib/rdstation/error_handler_spec.rb
163
184
  - spec/lib/rdstation/error_spec.rb
164
185
  - spec/lib/rdstation/events_spec.rb
165
186
  - spec/lib/rdstation/fields_spec.rb
187
+ - spec/lib/rdstation/retryable_request_spec.rb
166
188
  - spec/lib/rdstation/webhooks_spec.rb
189
+ - spec/lib/rdstation_spec.rb
167
190
  - spec/spec_helper.rb
168
191
  homepage: http://resultadosdigitais.com.br
169
192
  licenses:
@@ -185,14 +208,16 @@ required_rubygems_version: !ruby/object:Gem::Requirement
185
208
  version: '0'
186
209
  requirements: []
187
210
  rubyforge_project:
188
- rubygems_version: 2.6.8
211
+ rubygems_version: 2.7.6.2
189
212
  signing_key:
190
213
  specification_version: 4
191
214
  summary: Ruby API wrapper for RD Station
192
215
  test_files:
193
216
  - spec/lib/rdstation-ruby-client_spec.rb
217
+ - spec/lib/rdstation/api_response_spec.rb
194
218
  - spec/lib/rdstation/authentication_spec.rb
195
- - spec/lib/rdstation/authorization_header_spec.rb
219
+ - spec/lib/rdstation/authorization_spec.rb
220
+ - spec/lib/rdstation/builder/field_spec.rb
196
221
  - spec/lib/rdstation/client_spec.rb
197
222
  - spec/lib/rdstation/contacts_spec.rb
198
223
  - spec/lib/rdstation/error/format_spec.rb
@@ -202,10 +227,13 @@ test_files:
202
227
  - spec/lib/rdstation/error_handler/expired_code_grant_spec.rb
203
228
  - spec/lib/rdstation/error_handler/invalid_credentials_spec.rb
204
229
  - spec/lib/rdstation/error_handler/invalid_event_type_spec.rb
230
+ - spec/lib/rdstation/error_handler/invalid_refresh_token_spec.rb
205
231
  - spec/lib/rdstation/error_handler/unauthorized_spec.rb
206
232
  - spec/lib/rdstation/error_handler_spec.rb
207
233
  - spec/lib/rdstation/error_spec.rb
208
234
  - spec/lib/rdstation/events_spec.rb
209
235
  - spec/lib/rdstation/fields_spec.rb
236
+ - spec/lib/rdstation/retryable_request_spec.rb
210
237
  - spec/lib/rdstation/webhooks_spec.rb
238
+ - spec/lib/rdstation_spec.rb
211
239
  - spec/spec_helper.rb