rdstation-ruby-client 2.0.0 → 2.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +116 -4
- data/README.md +114 -22
- data/lib/rdstation-ruby-client.rb +6 -1
- data/lib/rdstation.rb +19 -0
- data/lib/rdstation/api_response.rb +1 -2
- data/lib/rdstation/authentication.rb +32 -3
- data/lib/rdstation/{authorization_header.rb → authorization.rb} +11 -8
- data/lib/rdstation/builder/field.rb +70 -0
- data/lib/rdstation/client.rb +17 -7
- data/lib/rdstation/contacts.rb +22 -13
- data/lib/rdstation/error.rb +2 -0
- data/lib/rdstation/error/format.rb +29 -3
- data/lib/rdstation/error/formatter.rb +69 -8
- data/lib/rdstation/error_handler.rb +6 -1
- data/lib/rdstation/events.rb +7 -12
- data/lib/rdstation/fields.rb +35 -6
- data/lib/rdstation/retryable_request.rb +35 -0
- data/lib/rdstation/version.rb +1 -1
- data/lib/rdstation/webhooks.rb +25 -13
- data/rdstation-ruby-client.gemspec +2 -1
- data/spec/lib/rdstation/api_response_spec.rb +34 -0
- data/spec/lib/rdstation/authentication_spec.rb +164 -0
- data/spec/lib/rdstation/{authorization_header_spec.rb → authorization_spec.rb} +3 -3
- data/spec/lib/rdstation/builder/field_spec.rb +69 -0
- data/spec/lib/rdstation/client_spec.rb +6 -6
- data/spec/lib/rdstation/contacts_spec.rb +23 -3
- data/spec/lib/rdstation/error/format_spec.rb +63 -0
- data/spec/lib/rdstation/error/formatter_spec.rb +113 -0
- data/spec/lib/rdstation/error_handler_spec.rb +23 -0
- data/spec/lib/rdstation/events_spec.rb +8 -3
- data/spec/lib/rdstation/fields_spec.rb +6 -1
- data/spec/lib/rdstation/retryable_request_spec.rb +142 -0
- data/spec/lib/rdstation/webhooks_spec.rb +26 -1
- data/spec/lib/rdstation_spec.rb +18 -0
- metadata +36 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d51df272057d17abe280b0fe23f7a97f9ef2ceb543f823db1ce8b047788d1887
|
4
|
+
data.tar.gz: d59bd8063663bb95df477c672066e4c6655172a193d9b2244bba6b8608a92869
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1451abf2db818f4551575ea88befdb63b6f8f8b1afa3270b96ee50b059f0f69676d6c6104a6e217d58e9c84384527d77e81d257d5a222a1ab2df74e1ed525446
|
7
|
+
data.tar.gz: 06c2620cdf413e945207f7b0bad15bcdb762038b360ef3c9ed5371e2ff06edc4949f97602fc0c3ffc352ff14bf66774234c398b291a5606d34931ab0eded84e9
|
data/CHANGELOG.md
CHANGED
@@ -1,8 +1,118 @@
|
|
1
|
+
## 2.4.0
|
2
|
+
|
3
|
+
- Add the TooManyRequests errors in case of rate limit exceeded. See [API request limit](https://developers.rdstation.com/en/request-limit) for more details
|
4
|
+
|
5
|
+
## 2.3.1
|
6
|
+
|
7
|
+
- Fixed a bug when no error is found in the known errors list (issue [#52](https://github.com/ResultadosDigitais/rdstation-ruby-client/issues/52))
|
8
|
+
|
9
|
+
## 2.3.0
|
10
|
+
|
11
|
+
### Additions
|
12
|
+
|
13
|
+
#### 1. New Field methods
|
14
|
+
|
15
|
+
The following methods were added to "Fields" client:
|
16
|
+
|
17
|
+
- create
|
18
|
+
- update
|
19
|
+
- delete
|
20
|
+
|
21
|
+
Besides reading, this client is now capable of create, update or delete a field.
|
22
|
+
|
23
|
+
Usage example:
|
24
|
+
|
25
|
+
```ruby
|
26
|
+
client = RDStation::Client.new(access_token: 'ACCESS_TOKEN', refresh_token: 'REFRESH_TOKEN')
|
27
|
+
client.fields.delete('FIELD_UUID')
|
28
|
+
```
|
29
|
+
|
30
|
+
#### 2. New format of errors supported
|
31
|
+
|
32
|
+
Two new formats of errors are now supported by the error handler:
|
33
|
+
|
34
|
+
##### `HASH_OF_HASHES`
|
35
|
+
|
36
|
+
When the error message is a hash containing other hashes as values, for example:
|
37
|
+
|
38
|
+
```ruby
|
39
|
+
{
|
40
|
+
'error' => {
|
41
|
+
'field1' => {...},
|
42
|
+
'field2' => {...}
|
43
|
+
}
|
44
|
+
}
|
45
|
+
```
|
46
|
+
|
47
|
+
##### `HASH_OF_MULTIPLE_TYPES`
|
48
|
+
|
49
|
+
When the error message is a hash that could contain multiple data types as values, for example:
|
50
|
+
|
51
|
+
```ruby
|
52
|
+
{
|
53
|
+
'error' => {
|
54
|
+
'field1' => [...] # Array,
|
55
|
+
'field2' => {...} # Hash
|
56
|
+
}
|
57
|
+
}
|
58
|
+
```
|
59
|
+
|
60
|
+
## 2.2.0
|
61
|
+
|
62
|
+
### Additions
|
63
|
+
|
64
|
+
#### Configuration
|
65
|
+
|
66
|
+
Now it is possible to configure global params like client_id and client_secret only once, so you don't need to provide them to `RDStation::Authentication` every time.
|
67
|
+
|
68
|
+
This can be done in the following way:
|
69
|
+
|
70
|
+
```ruby
|
71
|
+
RDStation.configure do |config|
|
72
|
+
config.client_id = YOUR_CLIENT_ID
|
73
|
+
config.client_secret = YOUR_CLIENT_SECRET
|
74
|
+
end
|
75
|
+
```
|
76
|
+
|
77
|
+
If you're using Rails, this can be done in `config/initializers`.
|
78
|
+
|
79
|
+
#### Automatic refresh of access_tokens
|
80
|
+
|
81
|
+
When an access_token expires, a new one will be obtained automatically and the request will be made again.
|
82
|
+
|
83
|
+
For this to work, you have to use `RDStation.configure` as described above, and provide the refresh token when instantiating `RDStation::Client` (ex: RDStation::Client.new(access_token: MY_ACCESS_TOKEN, refresh_token: MY_REFRESH_TOKEN).
|
84
|
+
|
85
|
+
You can keep track of access_token changes, by providing a callback block inconfiguration. This block will be called with an `RDStation::Authorization` object, which contains the updated `access_token` and `refresh_token`. For example:
|
86
|
+
|
87
|
+
```ruby
|
88
|
+
RDStation.configure do |config|
|
89
|
+
config.on_access_token_refresh do |authorization|
|
90
|
+
MyStoredAuth.where(refresh_token: authorization.refresh_token).update_all(access_token: authorization.access_token)
|
91
|
+
end
|
92
|
+
end
|
93
|
+
```
|
94
|
+
|
95
|
+
### Deprecations
|
96
|
+
|
97
|
+
Providing `client_id` and `client_secret` directly to `RDStation::Authentication.new` is deprecated and will be removed in future versions. Use `RDStation.configure` instead.
|
98
|
+
|
99
|
+
Specifying refresh_token in `RDStation::Client.new(access_token: 'at', refresh_token: 'rt')` is optional right now, but will be mandatory in future versions.
|
100
|
+
|
101
|
+
## 2.1.1
|
102
|
+
|
103
|
+
- Fixed a bug in error handling (issue [#47](https://github.com/ResultadosDigitais/rdstation-ruby-client/issues/47))
|
104
|
+
|
105
|
+
## 2.1.0
|
106
|
+
|
107
|
+
### Additions
|
108
|
+
|
109
|
+
`RDStation::Authentication.revoke` added. This method revokes an access_token at RD Station.
|
110
|
+
|
1
111
|
## 2.0.0
|
2
112
|
|
3
113
|
### Removals
|
4
114
|
|
5
|
-
All API methods that were called directly on `RDStation::Client` (ex: `RDStation::Client.new('rdstation_token', 'auth_token').create_lead(lead_info)`) have been removed. See the [
|
115
|
+
All API methods that were called directly on `RDStation::Client` (ex: `RDStation::Client.new('rdstation_token', 'auth_token').create_lead(lead_info)`) have been removed. See the [migration guide](README.md#Upgrading-from-1.2.x-to-2.0.0) for a comprehensive guide on how to upgrade from version 1.2.x.
|
6
116
|
|
7
117
|
### Notable changes
|
8
118
|
|
@@ -43,17 +153,19 @@ In case of a Bad Request (400), the following specific errors may be raised (tho
|
|
43
153
|
- `RDStation::Error::ConflictingField`
|
44
154
|
- `RDStation::Error::InvalidEventType`
|
45
155
|
|
46
|
-
In cause of
|
156
|
+
In cause of Unauthorized (401), the following specific errors may be raised (those are subclasses of `RDStation::Error::Unauthorized`):
|
47
157
|
- `RDStation::Error::ExpiredAccessToken`
|
48
158
|
- `RDStation::Error::ExpiredCodeGrant`
|
49
159
|
- `RDStation::Error::InvalidCredentials`
|
50
160
|
|
161
|
+
The specific message and the http code are now returned by the `details` method.
|
162
|
+
|
51
163
|
### Dependencies
|
52
164
|
|
53
165
|
`rdstation-ruby-client` now requires `ruby >= 2.0.0`.
|
54
166
|
|
55
|
-
## 1.2.1
|
167
|
+
## 1.2.1
|
56
168
|
|
57
169
|
### Deprecations
|
58
170
|
|
59
|
-
All API methods that were called directly on `RDStation::Client` (ex: `RDStation::Client.new('rdstation_token', 'auth_token').create_lead(lead_info)`) are now deprecated. Those methods call RDSM's 1.3 API and will be removed in the next release.
|
171
|
+
All API methods that were called directly on `RDStation::Client` (ex: `RDStation::Client.new('rdstation_token', 'auth_token').create_lead(lead_info)`) are now deprecated. Those methods call RDSM's 1.3 API and will be removed in the next release.
|
data/README.md
CHANGED
@@ -10,12 +10,13 @@ Upgrading? Check the [migration guide](#Migration-guide) before bumping to a new
|
|
10
10
|
|
11
11
|
1. [Installation](#Installation)
|
12
12
|
2. [Usage](#Usage)
|
13
|
-
1. [
|
14
|
-
2. [
|
15
|
-
3. [
|
16
|
-
4. [
|
17
|
-
5. [
|
18
|
-
6. [
|
13
|
+
1. [Configuration](#Configuration)
|
14
|
+
2. [Authentication](#Authentication)
|
15
|
+
3. [Contacts](#Contacts)
|
16
|
+
4. [Events](#Events)
|
17
|
+
5. [Fields](#Fields)
|
18
|
+
6. [Webhooks](#Webhooks)
|
19
|
+
7. [Errors](#Errors)
|
19
20
|
3. [Changelog](#Changelog)
|
20
21
|
4. [Migration guide](#Migration-guide)
|
21
22
|
1. [Upgrading from 1.2.x to 2.0.0](#Upgrading-from-1.2.x-to-2.0.0)
|
@@ -39,6 +40,19 @@ Or install it yourself as:
|
|
39
40
|
|
40
41
|
## Usage
|
41
42
|
|
43
|
+
### Configuration
|
44
|
+
|
45
|
+
Before getting youre credentials, you need to configure client_id and client_secret as following:
|
46
|
+
|
47
|
+
```ruby
|
48
|
+
RDStation.configure do |config|
|
49
|
+
config.client_id = YOUR_CLIENT_ID
|
50
|
+
config.client_secret = YOUR_CLIENT_SECRET
|
51
|
+
end
|
52
|
+
```
|
53
|
+
|
54
|
+
For details on what `client_id` and `client_secret` are, check the [developers portal](https://developers.rdstation.com/en/authentication).
|
55
|
+
|
42
56
|
### Authentication
|
43
57
|
|
44
58
|
For more details, check the [developers portal](https://developers.rdstation.com/en/authentication).
|
@@ -46,7 +60,7 @@ For more details, check the [developers portal](https://developers.rdstation.com
|
|
46
60
|
#### Getting authentication URL
|
47
61
|
|
48
62
|
```ruby
|
49
|
-
rdstation_authentication = RDStation::Authentication.new
|
63
|
+
rdstation_authentication = RDStation::Authentication.new
|
50
64
|
|
51
65
|
redirect_url = 'https://yourapp.org/auth/callback'
|
52
66
|
rdstation_authentication.auth_url(redirect_url)
|
@@ -57,17 +71,43 @@ rdstation_authentication.auth_url(redirect_url)
|
|
57
71
|
You will need the code param that is returned from RD Station to your application after the user confirms the access at the authorization dialog.
|
58
72
|
|
59
73
|
```ruby
|
60
|
-
rdstation_authentication = RDStation::Authentication.new
|
74
|
+
rdstation_authentication = RDStation::Authentication.new
|
61
75
|
rdstation_authentication.authenticate(code_returned_from_rdstation)
|
76
|
+
# => { 'access_token' => '54321', 'expires_in' => 86_400, 'refresh_token' => 'refresh' }
|
62
77
|
```
|
63
78
|
|
64
|
-
#### Updating access_token
|
79
|
+
#### Updating an expired access_token
|
65
80
|
|
66
81
|
```ruby
|
67
|
-
rdstation_authentication = RDStation::Authentication.new
|
82
|
+
rdstation_authentication = RDStation::Authentication.new
|
68
83
|
rdstation_authentication.update_access_token('refresh_token')
|
69
84
|
```
|
70
85
|
|
86
|
+
**NOTE**: This is done automatically when a request fails due to access_token expiration. To keep track of the new token, you have to provide a callback block in configuration. For example:
|
87
|
+
|
88
|
+
```ruby
|
89
|
+
RDStation.configure do |config|
|
90
|
+
config.client_id = YOUR_CLIENT_ID
|
91
|
+
config.client_secret = YOUR_CLIENT_SECRET
|
92
|
+
config.on_access_token_refresh do |authorization|
|
93
|
+
# authorization.access_token_expires_in is the time (in seconds for with the token is valid)
|
94
|
+
# authorization.access_token is the new token
|
95
|
+
# authorization.refresh_token is the existing refresh_token
|
96
|
+
#
|
97
|
+
# If you are using ActiveRecord, you may want to update the stored access_token, like in the following code:
|
98
|
+
MyStoredAuth.where(refresh_token: authorization.refresh_token).update_all(access_token: authorization.access_token)
|
99
|
+
end
|
100
|
+
end
|
101
|
+
```
|
102
|
+
|
103
|
+
#### Revoking an access_token
|
104
|
+
|
105
|
+
```ruby
|
106
|
+
RDStation::Authentication.revoke(access_token: "your token")
|
107
|
+
```
|
108
|
+
|
109
|
+
Note: this will completely remove your credentials from RD Station (`update_access_token` won't work anymore).
|
110
|
+
|
71
111
|
### Contacts
|
72
112
|
|
73
113
|
#### Getting a Contact by UUID
|
@@ -75,7 +115,7 @@ rdstation_authentication.update_access_token('refresh_token')
|
|
75
115
|
Returns data about a specific Contact
|
76
116
|
|
77
117
|
```ruby
|
78
|
-
client = RDStation::Client.new(access_token: 'access_token')
|
118
|
+
client = RDStation::Client.new(access_token: 'access_token', refresh_token: 'refresh_token')
|
79
119
|
client.contacts.by_uuid('uuid')
|
80
120
|
```
|
81
121
|
|
@@ -86,7 +126,7 @@ More info: https://developers.rdstation.com/pt-BR/reference/contacts#methodGetDe
|
|
86
126
|
Returns data about a specific Contact
|
87
127
|
|
88
128
|
```ruby
|
89
|
-
client = RDStation::Client.new(access_token: 'access_token')
|
129
|
+
client = RDStation::Client.new(access_token: 'access_token', refresh_token: 'refresh_token')
|
90
130
|
client.contacts.by_email('email')
|
91
131
|
```
|
92
132
|
|
@@ -101,7 +141,7 @@ contact_info = {
|
|
101
141
|
name: "Joe Foo"
|
102
142
|
}
|
103
143
|
|
104
|
-
client = RDStation::Client.new(access_token: 'access_token')
|
144
|
+
client = RDStation::Client.new(access_token: 'access_token', refresh_token: 'refresh_token')
|
105
145
|
client.contacts.update('uuid', contact_info)
|
106
146
|
```
|
107
147
|
Contact Default Parameters
|
@@ -131,7 +171,7 @@ contact_info = {
|
|
131
171
|
identifier = "email"
|
132
172
|
identifier_value = "joe@foo.bar"
|
133
173
|
|
134
|
-
client = RDStation::Client.new(access_token: 'access_token')
|
174
|
+
client = RDStation::Client.new(access_token: 'access_token', refresh_token: 'refresh_token')
|
135
175
|
client.contacts.upsert(identifier, identifier_value, contact_info)
|
136
176
|
```
|
137
177
|
|
@@ -151,7 +191,7 @@ This creates a new event on RDSM:
|
|
151
191
|
|
152
192
|
```ruby
|
153
193
|
payload = {} # hash representing the payload
|
154
|
-
client = RDStation::Client.new(access_token: 'access_token')
|
194
|
+
client = RDStation::Client.new(access_token: 'access_token', refresh_token: 'refresh_token')
|
155
195
|
client.events.create(payload)
|
156
196
|
```
|
157
197
|
|
@@ -162,10 +202,59 @@ Endpoints to [manage Contact Fields](https://developers.rdstation.com/en/referen
|
|
162
202
|
#### List all fields
|
163
203
|
|
164
204
|
```ruby
|
165
|
-
client = RDStation::Client.new(access_token: 'access_token')
|
205
|
+
client = RDStation::Client.new(access_token: 'access_token', refresh_token: 'refresh_token')
|
166
206
|
client.fields.all
|
167
207
|
```
|
168
208
|
|
209
|
+
#### Create a field
|
210
|
+
|
211
|
+
```ruby
|
212
|
+
payload = {} # hash representing the payload
|
213
|
+
client = RDStation::Client.new(access_token: 'access_token', refresh_token: 'refresh_token')
|
214
|
+
client.fields.create payload
|
215
|
+
```
|
216
|
+
Or you can use the new `RDStation::Builder::Field`
|
217
|
+
|
218
|
+
```ruby
|
219
|
+
payload = {} # hash representing the payload
|
220
|
+
builder = RDStation::Builder::Field.new payload['api_identifier']
|
221
|
+
builder.data_type(payload['data_type'])
|
222
|
+
builder.presentation_type(payload['presentation_type'])
|
223
|
+
builder.name('pt-BR', payload['name'])
|
224
|
+
builder.label('pt-BR', payload['label'])
|
225
|
+
|
226
|
+
client = RDStation::Client.new(access_token: 'access_token', refresh_token: 'refresh_token')
|
227
|
+
client.fields.create builder.build
|
228
|
+
```
|
229
|
+
|
230
|
+
#### Update a field
|
231
|
+
|
232
|
+
```ruby
|
233
|
+
payload = {} # hash representing the payload
|
234
|
+
client = RDStation::Client.new(access_token: 'access_token', refresh_token: 'refresh_token')
|
235
|
+
client.fields.update('FIELD_UUID', payload)
|
236
|
+
```
|
237
|
+
Or you can use the new `RDStation::Builder::Field`
|
238
|
+
|
239
|
+
```ruby
|
240
|
+
payload = {} # hash representing the payload
|
241
|
+
builder = RDStation::Builder::Field.new payload['api_identifier']
|
242
|
+
builder.data_type(payload['data_type'])
|
243
|
+
builder.presentation_type(payload['presentation_type'])
|
244
|
+
builder.name('pt-BR', payload['name'])
|
245
|
+
builder.label('pt-BR', payload['label'])
|
246
|
+
|
247
|
+
client = RDStation::Client.new(access_token: 'access_token', refresh_token: 'refresh_token')
|
248
|
+
client.fields.update('FIELD_UUID', builder.build)
|
249
|
+
```
|
250
|
+
#### Deleting a field
|
251
|
+
|
252
|
+
```ruby
|
253
|
+
client = RDStation::Client.new(access_token: 'access_token', refresh_token: 'refresh_token')
|
254
|
+
client.fields.delete('FIELD_UUID')
|
255
|
+
```
|
256
|
+
|
257
|
+
|
169
258
|
### Webhooks
|
170
259
|
|
171
260
|
Webhooks provide the ability to receive real-time data updates about your contact activity.
|
@@ -175,14 +264,14 @@ Choose to receive data based on certain actions, re-cast or marked as an opportu
|
|
175
264
|
#### List all webhooks
|
176
265
|
|
177
266
|
```ruby
|
178
|
-
client = RDStation::Client.new(access_token: 'access_token')
|
267
|
+
client = RDStation::Client.new(access_token: 'access_token', refresh_token: 'refresh_token')
|
179
268
|
client.webhooks.all
|
180
269
|
```
|
181
270
|
|
182
271
|
#### Getting a webhook by UUID
|
183
272
|
|
184
273
|
```ruby
|
185
|
-
client = RDStation::Client.new(access_token: 'access_token')
|
274
|
+
client = RDStation::Client.new(access_token: 'access_token', refresh_token: 'refresh_token')
|
186
275
|
client.webhooks.by_uuid('WEBHOOK_UUID')
|
187
276
|
```
|
188
277
|
|
@@ -190,7 +279,7 @@ client.webhooks.by_uuid('WEBHOOK_UUID')
|
|
190
279
|
|
191
280
|
```ruby
|
192
281
|
payload = {} # payload representing a webhook
|
193
|
-
client = RDStation::Client.new(access_token: 'access_token')
|
282
|
+
client = RDStation::Client.new(access_token: 'access_token', refresh_token: 'refresh_token')
|
194
283
|
client.webhooks.create(payload)
|
195
284
|
```
|
196
285
|
|
@@ -200,7 +289,7 @@ The required strucutre of the payload is [described here](https://developers.rds
|
|
200
289
|
|
201
290
|
```ruby
|
202
291
|
payload = {} # payload representing a webhook
|
203
|
-
client = RDStation::Client.new(access_token: 'access_token')
|
292
|
+
client = RDStation::Client.new(access_token: 'access_token', refresh_token: 'refresh_token')
|
204
293
|
client.webhooks.create('WEBHOOK_UUID', payload)
|
205
294
|
```
|
206
295
|
|
@@ -209,7 +298,7 @@ The required strucutre of the payload is [described here](https://developers.rds
|
|
209
298
|
#### Deleting a webhook
|
210
299
|
|
211
300
|
```ruby
|
212
|
-
client = RDStation::Client.new(access_token: 'access_token')
|
301
|
+
client = RDStation::Client.new(access_token: 'access_token', refresh_token: 'refresh_token')
|
213
302
|
client.webhooks.delete('WEBHOOK_UUID')
|
214
303
|
```
|
215
304
|
|
@@ -226,6 +315,7 @@ Each endpoint may raise errors accoording to the HTTP response code from RDStati
|
|
226
315
|
- `RDStation::Error::Conflict` (409)
|
227
316
|
- `RDStation::Error::UnsupportedMediaType` (415)
|
228
317
|
- `RDStation::Error::UnprocessableEntity` (422)
|
318
|
+
- `RDStation::Error::TooManyRequests` (429)
|
229
319
|
- `RDStation::Error::InternalServerError` (500)
|
230
320
|
- `RDStation::Error::NotImplemented` (501)
|
231
321
|
- `RDStation::Error::BadGateway` (502)
|
@@ -241,6 +331,8 @@ In cause of Unauthorized (401), the following specific errors may be raised (tho
|
|
241
331
|
- `RDStation::Error::ExpiredCodeGrant`
|
242
332
|
- `RDStation::Error::InvalidCredentials`
|
243
333
|
|
334
|
+
Any error class has a `details` method which returns the specific error message and the http_status.
|
335
|
+
|
244
336
|
## Changelog
|
245
337
|
|
246
338
|
See [CHANGELOG.md](CHANGELOG.md)
|
@@ -255,7 +347,7 @@ So, here is a step-by-step guide on how to upgrade your app:
|
|
255
347
|
- Ensure you're using `ruby >= 2.0.0`.
|
256
348
|
- Remove every direct instantiation of `RDStation::Contacts`, `RDStation::Events`, `RDStation::Fields` and `RDStation::Webhooks` and use `RDStation::Client` to get them instead.
|
257
349
|
- Replace any call of `RDStation::Client#create_lead`, `RDStation::Client#change_lead` or `RDStation::Client#change_lead_status` with the equivalent method in the [Contacts API](#Contacts).
|
258
|
-
- Review your error handling, as [more options](CHANGELOG.md#Error-handling) are available now.
|
350
|
+
- Review your error handling, as [more options](CHANGELOG.md#Error-handling) are available now. `http_status` method will always return nil. To get the status now use `error.details[:http_status]` or check the type of the class.
|
259
351
|
|
260
352
|
## Contributing
|
261
353
|
|
@@ -4,8 +4,10 @@ require 'httparty'
|
|
4
4
|
require 'rdstation/api_response'
|
5
5
|
|
6
6
|
# API requests
|
7
|
+
require 'rdstation'
|
8
|
+
require 'rdstation/retryable_request'
|
7
9
|
require 'rdstation/authentication'
|
8
|
-
require 'rdstation/
|
10
|
+
require 'rdstation/authorization'
|
9
11
|
require 'rdstation/client'
|
10
12
|
require 'rdstation/contacts'
|
11
13
|
require 'rdstation/events'
|
@@ -15,3 +17,6 @@ require 'rdstation/webhooks'
|
|
15
17
|
# Error handling
|
16
18
|
require 'rdstation/error'
|
17
19
|
require 'rdstation/error_handler'
|
20
|
+
|
21
|
+
# Builders
|
22
|
+
require 'rdstation/builder/field'
|
data/lib/rdstation.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
module RDStation
|
2
|
+
class << self
|
3
|
+
attr_accessor :configuration
|
4
|
+
|
5
|
+
def configure
|
6
|
+
self.configuration ||= Configuration.new
|
7
|
+
yield(configuration)
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
class Configuration
|
12
|
+
attr_accessor :client_id, :client_secret
|
13
|
+
attr_reader :access_token_refresh_callback
|
14
|
+
|
15
|
+
def on_access_token_refresh(&block)
|
16
|
+
@access_token_refresh_callback = block
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|