rdstation-ruby-client 1.2.1 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/ISSUE_TEMPLATE/rdsm-ruby-client-issue-template.md +49 -0
- data/.rspec +2 -0
- data/CHANGELOG.md +59 -0
- data/README.md +154 -45
- data/lib/rdstation-ruby-client.rb +1 -0
- data/lib/rdstation/api_response.rb +3 -2
- data/lib/rdstation/authorization_header.rb +21 -0
- data/lib/rdstation/client.rb +11 -78
- data/lib/rdstation/contacts.rb +7 -11
- data/lib/rdstation/error.rb +22 -15
- data/lib/rdstation/error_handler.rb +27 -26
- data/lib/rdstation/error_handler/bad_request.rb +30 -0
- data/lib/rdstation/error_handler/unauthorized.rb +17 -9
- data/lib/rdstation/events.rb +4 -11
- data/lib/rdstation/fields.rb +4 -9
- data/lib/rdstation/version.rb +1 -1
- data/lib/rdstation/webhooks.rb +8 -12
- data/rdstation-ruby-client.gemspec +2 -0
- data/spec/lib/rdstation-ruby-client_spec.rb +1 -1
- data/spec/lib/rdstation/authorization_header_spec.rb +24 -0
- data/spec/lib/rdstation/client_spec.rb +37 -0
- data/spec/lib/rdstation/contacts_spec.rb +34 -41
- data/spec/lib/rdstation/error_handler/unauthorized_spec.rb +0 -29
- data/spec/lib/rdstation/error_handler_spec.rb +142 -29
- data/spec/lib/rdstation/events_spec.rb +15 -9
- data/spec/lib/rdstation/fields_spec.rb +5 -3
- data/spec/lib/rdstation/webhooks_spec.rb +16 -13
- metadata +12 -9
- data/lib/rdstation/error_handler/default.rb +0 -15
- data/lib/rdstation/error_handler/resource_not_found.rb +0 -24
- data/spec/lib/rdstation/error_handler/default_spec.rb +0 -14
- data/spec/lib/rdstation/error_handler/resource_not_found_spec.rb +0 -54
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5ca94a755162557e5fcca58d15583986492ee1ef64c569c54d7c8a6feab6edec
|
4
|
+
data.tar.gz: 7b258da27dd4f13148e2f9de60a4a95eb32131fb0e5e0d8f5cc133eb3e4720fd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 28bf2fc07e73df574917d1b441867146d3120d44a7e72599399648b118922c04c7e4fc75364180bdc175c14ee77c2452cf7ff02885d83d7daf6924c642876759
|
7
|
+
data.tar.gz: c70a26f5d2b8a42d6b4deb8ee3de27ad817262e58b033a88200bcda04f9c36e468f2ce919b25d29181d810eb286a018a8eaed52eb04e4f545682e7a36b7a3876
|
@@ -0,0 +1,49 @@
|
|
1
|
+
---
|
2
|
+
name: RDSM Ruby Client Issue Template
|
3
|
+
about: Template for new Issues for the RD Station Ruby Client Project
|
4
|
+
title: ''
|
5
|
+
labels: ''
|
6
|
+
assignees: ''
|
7
|
+
|
8
|
+
---
|
9
|
+
|
10
|
+
# Prerequisites
|
11
|
+
|
12
|
+
Please answer the following questions for yourself before submitting an issue. **YOU MAY DELETE THE PREREQUISITES SECTION.**
|
13
|
+
|
14
|
+
- [ ] I am running the latest version
|
15
|
+
- [ ] I checked the documentation and found no answer
|
16
|
+
- [ ] I checked to make sure that this issue has not already been filed
|
17
|
+
- [ ] I'm reporting the issue to the correct repository
|
18
|
+
|
19
|
+
# Expected Behavior
|
20
|
+
|
21
|
+
Please describe the behavior you are expecting
|
22
|
+
|
23
|
+
# Current Behavior
|
24
|
+
|
25
|
+
What is the current behavior?
|
26
|
+
|
27
|
+
# Failure Information (for bugs)
|
28
|
+
|
29
|
+
Please help to provide information about the failure if this is a bug. If it is not a bug, please remove the rest of this template.
|
30
|
+
|
31
|
+
## Steps to Reproduce
|
32
|
+
|
33
|
+
Please provide detailed steps for reproducing the issue.
|
34
|
+
|
35
|
+
1. step 1
|
36
|
+
2. step 2
|
37
|
+
3. you get it...
|
38
|
+
|
39
|
+
## Context
|
40
|
+
|
41
|
+
Please provide any relevant information about your setup. This is important in case the issue is not reproducible except for under certain conditions.
|
42
|
+
|
43
|
+
* Operating System:
|
44
|
+
* Ruby Version:
|
45
|
+
* Rails Version:
|
46
|
+
|
47
|
+
## Failure Logs
|
48
|
+
|
49
|
+
Please include any relevant log snippets or files here.
|
data/.rspec
ADDED
data/CHANGELOG.md
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
## 2.0.0
|
2
|
+
|
3
|
+
### Removals
|
4
|
+
|
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 [upgrading guide](#Upgrading-to-version-2.0.0) for a comprehensive guide on how to upgrade from version 1.2.x.
|
6
|
+
|
7
|
+
### Notable changes
|
8
|
+
|
9
|
+
#### RDStation::Client
|
10
|
+
|
11
|
+
Now `RDStation::Client` is facade to all available endpoints in the 2.0 API. It needs to be instantiated with an access_token and has accessors to those endpoints. Usage examples:
|
12
|
+
|
13
|
+
```ruby
|
14
|
+
client = RDStation::Client.new((access_token: 'my_token')
|
15
|
+
client.contacts.by_uuid('CONTACT_UUID')
|
16
|
+
client.webhooks.all
|
17
|
+
client.events.create(my_json_payload)
|
18
|
+
client.fields.all
|
19
|
+
```
|
20
|
+
|
21
|
+
`RDStation::Contacts`, `RDStation::Events`, `RDStation::Fields` and `RDStation::Webhooks` are not suposed to be instantiated directly anymore. Use `RDStation::Client` to get them instead.
|
22
|
+
|
23
|
+
#### Error handling
|
24
|
+
|
25
|
+
Now specific errors are raised for each HTTP status:
|
26
|
+
|
27
|
+
- `RDStation::Error::BadRequest` (400)
|
28
|
+
- `RDStation::Error::Unauthorized` (401)
|
29
|
+
- `RDStation::Error::Forbidden` (403)
|
30
|
+
- `RDStation::Error::NotFound` (404)
|
31
|
+
- `RDStation::Error::MethodNotAllowed` (405)
|
32
|
+
- `RDStation::Error::NotAcceptable` (406)
|
33
|
+
- `RDStation::Error::Conflict` (409)
|
34
|
+
- `RDStation::Error::UnsupportedMediaType` (415)
|
35
|
+
- `RDStation::Error::UnprocessableEntity` (422)
|
36
|
+
- `RDStation::Error::InternalServerError` (500)
|
37
|
+
- `RDStation::Error::NotImplemented` (501)
|
38
|
+
- `RDStation::Error::BadGateway` (502)
|
39
|
+
- `RDStation::Error::ServiceUnavailable` (503)
|
40
|
+
- `RDStation::Error::ServerError` (which is returned for 5xx errors different than 500, 501, 502 or 503)
|
41
|
+
|
42
|
+
In case of a Bad Request (400), the following specific errors may be raised (those are subclasses of `RDStation::Error::BadRequest`):
|
43
|
+
- `RDStation::Error::ConflictingField`
|
44
|
+
- `RDStation::Error::InvalidEventType`
|
45
|
+
|
46
|
+
In cause of Unahtorized (401), the following specific errors may be raised (those are subclasses of `RDStation::Error::Unauthorized`):
|
47
|
+
- `RDStation::Error::ExpiredAccessToken`
|
48
|
+
- `RDStation::Error::ExpiredCodeGrant`
|
49
|
+
- `RDStation::Error::InvalidCredentials`
|
50
|
+
|
51
|
+
### Dependencies
|
52
|
+
|
53
|
+
`rdstation-ruby-client` now requires `ruby >= 2.0.0`.
|
54
|
+
|
55
|
+
## 1.2.1
|
56
|
+
|
57
|
+
### Deprecations
|
58
|
+
|
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.
|
data/README.md
CHANGED
@@ -4,6 +4,25 @@
|
|
4
4
|
|
5
5
|
RDstation ruby wrapper to interact with RDStation API.
|
6
6
|
|
7
|
+
Upgrading? Check the [migration guide](#Migration-guide) before bumping to a new major version.
|
8
|
+
|
9
|
+
## Table of Contents
|
10
|
+
|
11
|
+
1. [Installation](#Installation)
|
12
|
+
2. [Usage](#Usage)
|
13
|
+
1. [Authentication](#Authentication)
|
14
|
+
2. [Contacts](#Contacts)
|
15
|
+
3. [Events](#Events)
|
16
|
+
4. [Fields](#Fields)
|
17
|
+
5. [Webhooks](#Webhooks)
|
18
|
+
6. [Errors](#Errors)
|
19
|
+
3. [Changelog](#Changelog)
|
20
|
+
4. [Migration guide](#Migration-guide)
|
21
|
+
1. [Upgrading from 1.2.x to 2.0.0](#Upgrading-from-1.2.x-to-2.0.0)
|
22
|
+
5. [Contributing](#Contributing)
|
23
|
+
6. [Maintainers](#Maintainers)
|
24
|
+
7. [Reference](#Reference)
|
25
|
+
|
7
26
|
## Installation
|
8
27
|
|
9
28
|
Add this line to your application's Gemfile:
|
@@ -20,37 +39,10 @@ Or install it yourself as:
|
|
20
39
|
|
21
40
|
## Usage
|
22
41
|
|
23
|
-
### Creating a Lead
|
24
|
-
|
25
|
-
```ruby
|
26
|
-
lead_info = {
|
27
|
-
email: 'joe@foo.bar',
|
28
|
-
name: 'Joe foo',
|
29
|
-
empresa: 'A random Company',
|
30
|
-
cargo: 'Developer',
|
31
|
-
identificador: 'nome_da_conversao'
|
32
|
-
}
|
33
|
-
|
34
|
-
rdstation_client = RDStation::Client.new('rdstation_token', 'auth_token')
|
35
|
-
rdstation_client.create_lead(lead_info)
|
36
|
-
```
|
37
|
-
|
38
|
-
### Changing a Lead
|
39
|
-
|
40
|
-
```ruby
|
41
|
-
rdstation_client = RDStation::Client.new('rdstation_token', 'auth_token')
|
42
|
-
rdstation_client.change_lead('joe@foo.bar', lifecycle_stage: 1, opportunity: true})
|
43
|
-
```
|
44
|
-
|
45
|
-
### Change Lead Status
|
46
|
-
|
47
|
-
```ruby
|
48
|
-
rdstation_client = RDStation::Client.new('rdstation_token', 'auth_token')
|
49
|
-
rdstation_client.change_lead_status(email: 'joe@foo.bar', status: 'won', value: 999)
|
50
|
-
```
|
51
|
-
|
52
42
|
### Authentication
|
53
43
|
|
44
|
+
For more details, check the [developers portal](https://developers.rdstation.com/en/authentication).
|
45
|
+
|
54
46
|
#### Getting authentication URL
|
55
47
|
|
56
48
|
```ruby
|
@@ -83,8 +75,8 @@ rdstation_authentication.update_access_token('refresh_token')
|
|
83
75
|
Returns data about a specific Contact
|
84
76
|
|
85
77
|
```ruby
|
86
|
-
|
87
|
-
|
78
|
+
client = RDStation::Client.new(access_token: 'access_token')
|
79
|
+
client.contacts.by_uuid('uuid')
|
88
80
|
```
|
89
81
|
|
90
82
|
More info: https://developers.rdstation.com/pt-BR/reference/contacts#methodGetDetailsuuid
|
@@ -94,8 +86,8 @@ More info: https://developers.rdstation.com/pt-BR/reference/contacts#methodGetDe
|
|
94
86
|
Returns data about a specific Contact
|
95
87
|
|
96
88
|
```ruby
|
97
|
-
|
98
|
-
|
89
|
+
client = RDStation::Client.new(access_token: 'access_token')
|
90
|
+
client.contacts.by_email('email')
|
99
91
|
```
|
100
92
|
|
101
93
|
More info: https://developers.rdstation.com/pt-BR/reference/contacts#methodGetDetailsemail
|
@@ -109,8 +101,8 @@ contact_info = {
|
|
109
101
|
name: "Joe Foo"
|
110
102
|
}
|
111
103
|
|
112
|
-
|
113
|
-
|
104
|
+
client = RDStation::Client.new(access_token: 'access_token')
|
105
|
+
client.contacts.update('uuid', contact_info)
|
114
106
|
```
|
115
107
|
Contact Default Parameters
|
116
108
|
- email
|
@@ -139,12 +131,132 @@ contact_info = {
|
|
139
131
|
identifier = "email"
|
140
132
|
identifier_value = "joe@foo.bar"
|
141
133
|
|
142
|
-
|
143
|
-
|
134
|
+
client = RDStation::Client.new(access_token: 'access_token')
|
135
|
+
client.contacts.upsert(identifier, identifier_value, contact_info)
|
144
136
|
```
|
145
137
|
|
146
138
|
More info: https://developers.rdstation.com/pt-BR/reference/contacts#methodPatchUpsertDetails
|
147
139
|
|
140
|
+
### Events
|
141
|
+
|
142
|
+
#### Sending a new event
|
143
|
+
|
144
|
+
The events endpoint are responsible for receiving different event types in which RD Station Contacts take part in.
|
145
|
+
|
146
|
+
It is possible to send default events to RD Station such as conversion events, lifecycle events and won and lost events. Also, RD Station supports the possibility of receiving different event types, for instance, chat events, ecommerce ones and others.
|
147
|
+
|
148
|
+
Check the [developers portal](https://developers.rdstation.com/en/reference/events) to learn about the required payload structure and which events are available.
|
149
|
+
|
150
|
+
This creates a new event on RDSM:
|
151
|
+
|
152
|
+
```ruby
|
153
|
+
payload = {} # hash representing the payload
|
154
|
+
client = RDStation::Client.new(access_token: 'access_token')
|
155
|
+
client.events.create(payload)
|
156
|
+
```
|
157
|
+
|
158
|
+
### Fields
|
159
|
+
|
160
|
+
Endpoints to [manage Contact Fields](https://developers.rdstation.com/en/reference/fields) information in your RD Station account.
|
161
|
+
|
162
|
+
#### List all fields
|
163
|
+
|
164
|
+
```ruby
|
165
|
+
client = RDStation::Client.new(access_token: 'access_token')
|
166
|
+
client.fields.all
|
167
|
+
```
|
168
|
+
|
169
|
+
### Webhooks
|
170
|
+
|
171
|
+
Webhooks provide the ability to receive real-time data updates about your contact activity.
|
172
|
+
|
173
|
+
Choose to receive data based on certain actions, re-cast or marked as an opportunity, and have all applicable data sent to a URL of your choice. You can then use your own custom application to read, save, and do actions with that data. This is a powerful option that allows you to keep all your data in sync and opens the possibility for all types of integration.
|
174
|
+
|
175
|
+
#### List all webhooks
|
176
|
+
|
177
|
+
```ruby
|
178
|
+
client = RDStation::Client.new(access_token: 'access_token')
|
179
|
+
client.webhooks.all
|
180
|
+
```
|
181
|
+
|
182
|
+
#### Getting a webhook by UUID
|
183
|
+
|
184
|
+
```ruby
|
185
|
+
client = RDStation::Client.new(access_token: 'access_token')
|
186
|
+
client.webhooks.by_uuid('WEBHOOK_UUID')
|
187
|
+
```
|
188
|
+
|
189
|
+
#### Creating a webhook
|
190
|
+
|
191
|
+
```ruby
|
192
|
+
payload = {} # payload representing a webhook
|
193
|
+
client = RDStation::Client.new(access_token: 'access_token')
|
194
|
+
client.webhooks.create(payload)
|
195
|
+
```
|
196
|
+
|
197
|
+
The required strucutre of the payload is [described here](https://developers.rdstation.com/en/reference/webhooks#methodPostDetails).
|
198
|
+
|
199
|
+
#### Updating a webhook
|
200
|
+
|
201
|
+
```ruby
|
202
|
+
payload = {} # payload representing a webhook
|
203
|
+
client = RDStation::Client.new(access_token: 'access_token')
|
204
|
+
client.webhooks.create('WEBHOOK_UUID', payload)
|
205
|
+
```
|
206
|
+
|
207
|
+
The required strucutre of the payload is [described here](https://developers.rdstation.com/en/reference/webhooks#methodPutDetails).
|
208
|
+
|
209
|
+
#### Deleting a webhook
|
210
|
+
|
211
|
+
```ruby
|
212
|
+
client = RDStation::Client.new(access_token: 'access_token')
|
213
|
+
client.webhooks.delete('WEBHOOK_UUID')
|
214
|
+
```
|
215
|
+
|
216
|
+
### Errors
|
217
|
+
|
218
|
+
Each endpoint may raise errors accoording to the HTTP response code from RDStation:
|
219
|
+
|
220
|
+
- `RDStation::Error::BadRequest` (400)
|
221
|
+
- `RDStation::Error::Unauthorized` (401)
|
222
|
+
- `RDStation::Error::Forbidden` (403)
|
223
|
+
- `RDStation::Error::NotFound` (404)
|
224
|
+
- `RDStation::Error::MethodNotAllowed` (405)
|
225
|
+
- `RDStation::Error::NotAcceptable` (406)
|
226
|
+
- `RDStation::Error::Conflict` (409)
|
227
|
+
- `RDStation::Error::UnsupportedMediaType` (415)
|
228
|
+
- `RDStation::Error::UnprocessableEntity` (422)
|
229
|
+
- `RDStation::Error::InternalServerError` (500)
|
230
|
+
- `RDStation::Error::NotImplemented` (501)
|
231
|
+
- `RDStation::Error::BadGateway` (502)
|
232
|
+
- `RDStation::Error::ServiceUnavailable` (503)
|
233
|
+
- `RDStation::Error::ServerError` (which is returned for 5xx errors different than 500, 501, 502 or 503)
|
234
|
+
|
235
|
+
In case of a Bad Request (400), the following specific errors may be raised (those are subclasses of `RDStation::Error::BadRequest`):
|
236
|
+
- `RDStation::Error::ConflictingField`
|
237
|
+
- `RDStation::Error::InvalidEventType`
|
238
|
+
|
239
|
+
In cause of Unauthorized (401), the following specific errors may be raised (those are subclasses of `RDStation::Error::Unauthorized`):
|
240
|
+
- `RDStation::Error::ExpiredAccessToken`
|
241
|
+
- `RDStation::Error::ExpiredCodeGrant`
|
242
|
+
- `RDStation::Error::InvalidCredentials`
|
243
|
+
|
244
|
+
## Changelog
|
245
|
+
|
246
|
+
See [CHANGELOG.md](CHANGELOG.md)
|
247
|
+
|
248
|
+
## Migration guide
|
249
|
+
|
250
|
+
### Upgrading from 1.2.x to 2.0.0
|
251
|
+
|
252
|
+
v2.0.0 main change is that it drops support for RDSM's old 1.x API. If you're not familiar with the 2.0 API yet, [check it out](https://developers.rdstation.com) first. Also take a look at [the release notes](CHANGELOG.md#2.0.0), as they explain the changes in greater detail.
|
253
|
+
|
254
|
+
So, here is a step-by-step guide on how to upgrade your app:
|
255
|
+
- Ensure you're using `ruby >= 2.0.0`.
|
256
|
+
- Remove every direct instantiation of `RDStation::Contacts`, `RDStation::Events`, `RDStation::Fields` and `RDStation::Webhooks` and use `RDStation::Client` to get them instead.
|
257
|
+
- 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.
|
259
|
+
|
148
260
|
## Contributing
|
149
261
|
|
150
262
|
1. Fork it
|
@@ -153,14 +265,11 @@ More info: https://developers.rdstation.com/pt-BR/reference/contacts#methodPatch
|
|
153
265
|
4. Push to the branch (`git push origin my-new-feature`)
|
154
266
|
5. Create new Pull Request
|
155
267
|
|
156
|
-
##
|
157
|
-
[Nando Sousa](mailto:fernando.sousa@resultadosdigitais.com.br)
|
268
|
+
## Maintainers
|
158
269
|
|
159
|
-
|
270
|
+
- [Filipe Nascimento](mailto:filipe.nascimento@resultadosdigitais.com.br)
|
271
|
+
- [João Hornburg](mailto:joao@rdstation.com)
|
160
272
|
|
161
|
-
|
273
|
+
## Reference
|
162
274
|
|
163
|
-
|
164
|
-
- [Wordpress & Contact Form 7](https://gist.github.com/pedrobachiega/3277536);
|
165
|
-
- [PHP](https://gist.github.com/pedrobachiega/3248293);
|
166
|
-
- [HTML+Ajax with jQuery](https://gist.github.com/pedrobachiega/3248013);
|
275
|
+
You can check out RDstation's integration documentation at our [developers portal](https://developers.rdstation.com).
|
@@ -2,8 +2,9 @@ module RDStation
|
|
2
2
|
module ApiResponse
|
3
3
|
def self.build(response)
|
4
4
|
response_body = JSON.parse(response.body)
|
5
|
-
return response_body
|
6
|
-
|
5
|
+
return response_body if response.code.between?(200, 299)
|
6
|
+
|
7
|
+
RDStation::ErrorHandler.new(response).raise_error
|
7
8
|
end
|
8
9
|
end
|
9
10
|
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module RDStation
|
2
|
+
class AuthorizationHeader
|
3
|
+
|
4
|
+
def initialize(access_token:)
|
5
|
+
@access_token = access_token
|
6
|
+
validate_access_token access_token
|
7
|
+
end
|
8
|
+
|
9
|
+
def to_h
|
10
|
+
{ "Authorization" => "Bearer #{@access_token}", "Content-Type" => "application/json" }
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
def validate_access_token(access_token)
|
16
|
+
access_token_msg = ':access_token is required'
|
17
|
+
raise ArgumentError, access_token_msg unless access_token
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
end
|
data/lib/rdstation/client.rb
CHANGED
@@ -1,90 +1,23 @@
|
|
1
|
-
# encoding: utf-8
|
2
1
|
module RDStation
|
3
|
-
#
|
4
|
-
# Mais informações em http://ajuda.rdstation.com.br/hc/pt-br/articles/204526429-Guia-de-integra%C3%A7%C3%B5es-com-o-RD-Station
|
5
|
-
#
|
6
2
|
class Client
|
7
|
-
|
8
|
-
|
9
|
-
def initialize(rdstation_token, auth_token, identifier="integração")
|
10
|
-
warn "DEPRECATION WARNING: all methods in this class has been deprecated because the version 1.x is no longer under active development and will be removed in version 2.0.0. See more details about the new version here: https://developers.rdstation.com/en/overview"
|
11
|
-
@identificador = identifier
|
12
|
-
@rdstation_token = rdstation_token
|
13
|
-
@auth_token = auth_token
|
14
|
-
end
|
15
|
-
|
16
|
-
#
|
17
|
-
# A hash do Lead pode conter os seguintes parâmetros:
|
18
|
-
# (obrigatório) :email
|
19
|
-
# :identificador
|
20
|
-
# :nome
|
21
|
-
# :empresa
|
22
|
-
# :cargo
|
23
|
-
# :telefone
|
24
|
-
# :celular
|
25
|
-
# :website
|
26
|
-
# :twitter
|
27
|
-
# :c_utmz
|
28
|
-
# :created_at
|
29
|
-
# :tags
|
30
|
-
#
|
31
|
-
# Caso algum parâmetro não seja identificado como campo padrão ou como
|
32
|
-
# campo personalizado, este parâmetro desconhecido será gravado nos
|
33
|
-
# "Detalhes do Lead".
|
34
|
-
#
|
35
|
-
def create_lead(lead_hash)
|
36
|
-
warn "DEPRECATION WARNING: create_lead has been deprecated because the version 1.x is no longer under active development and will be removed in version 2.0.0. See more details about the new version here: https://developers.rdstation.com/en/overview"
|
37
|
-
lead_hash = rdstation_token_hash.merge(lead_hash)
|
38
|
-
lead_hash = lead_hash.merge(identifier_hash) unless lead_hash.has_key?(:identificador)
|
39
|
-
post_with_body("/conversions", {:body => lead_hash})
|
40
|
-
end
|
41
|
-
alias_method :update_lead_info, :create_lead
|
42
|
-
|
43
|
-
#
|
44
|
-
# param lead:
|
45
|
-
# id ou email do Lead a ser alterado
|
46
|
-
#
|
47
|
-
# param lead_hash:
|
48
|
-
# Hash contendo:
|
49
|
-
# :lifecycle_stage
|
50
|
-
# 0 - Lead; 1 - Lead Qualificado; 2 - Cliente
|
51
|
-
# :opportunity
|
52
|
-
# true ou false
|
53
|
-
#
|
54
|
-
def change_lead(lead, lead_hash)
|
55
|
-
warn "DEPRECATION WARNING: change_lead has been deprecated because the version 1.x is no longer under active development and will be removed in version 2.0.0. See more details about the new version here: https://developers.rdstation.com/en/overview"
|
56
|
-
lead_hash = auth_token_hash.merge({:lead => lead_hash})
|
57
|
-
put_with_body("/leads/#{lead}", :body => lead_hash.to_json, :headers => {'Content-Type' => 'application/json'})
|
58
|
-
end
|
59
|
-
|
60
|
-
def change_lead_status(lead_hash)
|
61
|
-
warn "DEPRECATION WARNING: change_lead_status has been deprecated because the version 1.x is no longer under active development and will be removed in version 2.0.0. See more details about the new version here: https://developers.rdstation.com/en/overview"
|
62
|
-
post_with_body("/services/#{@auth_token}/generic", :body => lead_hash )
|
63
|
-
end
|
64
|
-
|
65
|
-
private
|
66
|
-
def base_url
|
67
|
-
"https://www.rdstation.com.br/api/1.2"
|
3
|
+
def initialize(access_token:)
|
4
|
+
@authorization_header = AuthorizationHeader.new(access_token: access_token)
|
68
5
|
end
|
69
|
-
|
70
|
-
def
|
71
|
-
|
72
|
-
end
|
73
|
-
|
74
|
-
def auth_token_hash
|
75
|
-
{ :auth_token => @auth_token }
|
6
|
+
|
7
|
+
def contacts
|
8
|
+
@contacts ||= RDStation::Contacts.new(authorization_header: @authorization_header)
|
76
9
|
end
|
77
10
|
|
78
|
-
def
|
79
|
-
|
11
|
+
def events
|
12
|
+
@events ||= RDStation::Events.new(authorization_header: @authorization_header)
|
80
13
|
end
|
81
14
|
|
82
|
-
def
|
83
|
-
|
15
|
+
def fields
|
16
|
+
@fields ||= RDStation::Fields.new(authorization_header: @authorization_header)
|
84
17
|
end
|
85
18
|
|
86
|
-
def
|
87
|
-
|
19
|
+
def webhooks
|
20
|
+
@webhooks ||= RDStation::Webhooks.new(authorization_header: @authorization_header)
|
88
21
|
end
|
89
22
|
end
|
90
23
|
end
|