rdstation-ruby-client 2.5.1 → 2.5.3
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.
- checksums.yaml +4 -4
- data/.github/dependabot.yml +11 -0
- data/lib/rdstation/authentication.rb +3 -5
- data/lib/rdstation/contacts.rb +1 -1
- data/lib/rdstation/events.rb +9 -3
- data/lib/rdstation/fields.rb +5 -6
- data/lib/rdstation/version.rb +3 -1
- data/lib/rdstation/webhooks.rb +1 -1
- data/lib/rdstation.rb +9 -2
- data/spec/lib/rdstation/fields_spec.rb +9 -1
- data/spec/lib/rdstation_spec.rb +31 -8
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a86741ab9503d0df23891a8c5f5624ecfa1aa16239bdcceff547b38600490ce3
|
4
|
+
data.tar.gz: ee42acbda82c510a976cc6219eba9ac84761cdcbc74923f3c6ba59047ac25102
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d8bfed006377c6561dfc35e5951a303d8efa17b049d20523abcf6a580b467280b30a8072d320756fbaa7420af142e7c2c99f9d5f7b93732bc0dcbcb2a41fbdde
|
7
|
+
data.tar.gz: 182cda1194b7fad1a853663c0eed931615acaf9c13dc60f60ff378f63765175a3a622e9e349801cda369d06aff84b2b0ca2541f7fe3fa755c8122e31f81b9220
|
@@ -3,9 +3,7 @@ module RDStation
|
|
3
3
|
class Authentication
|
4
4
|
include HTTParty
|
5
5
|
|
6
|
-
AUTH_TOKEN_URL = 'https://api.rd.services/auth/token'.freeze
|
7
6
|
DEFAULT_HEADERS = { 'Content-Type' => 'application/json' }.freeze
|
8
|
-
REVOKE_URL = 'https://api.rd.services/auth/revoke'.freeze
|
9
7
|
|
10
8
|
def initialize(client_id = nil, client_secret = nil)
|
11
9
|
warn_deprecation if client_id || client_secret
|
@@ -19,7 +17,7 @@ module RDStation
|
|
19
17
|
# after confirming application authorization
|
20
18
|
#
|
21
19
|
def auth_url(redirect_url)
|
22
|
-
"
|
20
|
+
"#{RDStation.host}/auth/dialog?client_id=#{@client_id}&redirect_url=#{redirect_url}"
|
23
21
|
end
|
24
22
|
|
25
23
|
# Public: Get the credentials from RD Station API
|
@@ -51,7 +49,7 @@ module RDStation
|
|
51
49
|
|
52
50
|
def self.revoke(access_token:)
|
53
51
|
response = self.post(
|
54
|
-
|
52
|
+
"#{RDStation.host}/auth/revoke",
|
55
53
|
body: revoke_body(access_token),
|
56
54
|
headers: revoke_headers(access_token)
|
57
55
|
)
|
@@ -79,7 +77,7 @@ module RDStation
|
|
79
77
|
body = default_body.merge(params)
|
80
78
|
|
81
79
|
self.class.post(
|
82
|
-
|
80
|
+
"#{RDStation.host}/auth/token",
|
83
81
|
body: body.to_json,
|
84
82
|
headers: DEFAULT_HEADERS
|
85
83
|
)
|
data/lib/rdstation/contacts.rb
CHANGED
data/lib/rdstation/events.rb
CHANGED
@@ -1,19 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module RDStation
|
2
4
|
class Events
|
3
5
|
include HTTParty
|
4
6
|
include ::RDStation::RetryableRequest
|
5
7
|
|
6
|
-
EVENTS_ENDPOINT = 'https://api.rd.services/platform/events'.freeze
|
7
|
-
|
8
8
|
def initialize(authorization:)
|
9
9
|
@authorization = authorization
|
10
10
|
end
|
11
11
|
|
12
12
|
def create(payload)
|
13
13
|
retryable_request(@authorization) do |authorization|
|
14
|
-
response = self.class.post(
|
14
|
+
response = self.class.post(base_url, headers: authorization.headers, body: payload.to_json)
|
15
15
|
ApiResponse.build(response)
|
16
16
|
end
|
17
17
|
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def base_url
|
22
|
+
"#{RDStation.host}/platform/events"
|
23
|
+
end
|
18
24
|
end
|
19
25
|
end
|
data/lib/rdstation/fields.rb
CHANGED
@@ -1,26 +1,25 @@
|
|
1
|
-
#
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
2
3
|
module RDStation
|
3
4
|
# More info: https://developers.rdstation.com/pt-BR/reference/fields
|
4
5
|
class Fields
|
5
6
|
include HTTParty
|
6
7
|
include ::RDStation::RetryableRequest
|
7
8
|
|
8
|
-
BASE_URL = 'https://api.rd.services/platform/contacts/fields'.freeze
|
9
|
-
|
10
9
|
def initialize(authorization:)
|
11
10
|
@authorization = authorization
|
12
11
|
end
|
13
12
|
|
14
13
|
def all
|
15
14
|
retryable_request(@authorization) do |authorization|
|
16
|
-
response = self.class.get(
|
15
|
+
response = self.class.get(base_url, headers: authorization.headers)
|
17
16
|
ApiResponse.build(response)
|
18
17
|
end
|
19
18
|
end
|
20
19
|
|
21
20
|
def create(payload)
|
22
21
|
retryable_request(@authorization) do |authorization|
|
23
|
-
response = self.class.post(
|
22
|
+
response = self.class.post(base_url, headers: authorization.headers, body: payload.to_json)
|
24
23
|
ApiResponse.build(response)
|
25
24
|
end
|
26
25
|
end
|
@@ -42,7 +41,7 @@ module RDStation
|
|
42
41
|
private
|
43
42
|
|
44
43
|
def base_url(path = '')
|
45
|
-
"#{
|
44
|
+
"#{RDStation.host}/platform/contacts/fields/#{path}"
|
46
45
|
end
|
47
46
|
end
|
48
47
|
end
|
data/lib/rdstation/version.rb
CHANGED
data/lib/rdstation/webhooks.rb
CHANGED
data/lib/rdstation.rb
CHANGED
@@ -2,14 +2,21 @@ module RDStation
|
|
2
2
|
class << self
|
3
3
|
attr_accessor :configuration
|
4
4
|
|
5
|
+
HOST = 'https://api.rd.services'.freeze
|
6
|
+
|
5
7
|
def configure
|
6
8
|
self.configuration ||= Configuration.new
|
9
|
+
self.configuration.base_host = HOST
|
7
10
|
yield(configuration)
|
8
11
|
end
|
12
|
+
|
13
|
+
def host
|
14
|
+
self.configuration&.base_host || HOST
|
15
|
+
end
|
9
16
|
end
|
10
|
-
|
17
|
+
|
11
18
|
class Configuration
|
12
|
-
attr_accessor :client_id, :client_secret
|
19
|
+
attr_accessor :client_id, :client_secret, :base_host
|
13
20
|
attr_reader :access_token_refresh_callback
|
14
21
|
|
15
22
|
def on_access_token_refresh(&block)
|
@@ -1,6 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
RSpec.describe RDStation::Fields do
|
6
|
+
before do
|
7
|
+
RDStation.configure do |config|
|
8
|
+
config.base_host = 'https://sample.rd.services'
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
4
12
|
let(:valid_access_token) { 'valid_access_token' }
|
5
13
|
let(:rdstation_fields_with_valid_token) do
|
6
14
|
described_class.new(authorization: RDStation::Authorization.new(access_token: valid_access_token))
|
@@ -14,7 +22,7 @@ RSpec.describe RDStation::Fields do
|
|
14
22
|
end
|
15
23
|
|
16
24
|
describe '#all' do
|
17
|
-
let(:fields_endpoint) { 'https://
|
25
|
+
let(:fields_endpoint) { 'https://sample.rd.services/platform/contacts/fields/' }
|
18
26
|
let(:all_account_fields) do
|
19
27
|
{
|
20
28
|
'fields' => [
|
data/spec/lib/rdstation_spec.rb
CHANGED
@@ -1,18 +1,41 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
RSpec.describe RDStation do
|
4
|
-
|
5
|
-
|
6
|
-
|
4
|
+
let(:client_id) { 'client_id' }
|
5
|
+
let(:client_secret) { 'client_secret' }
|
6
|
+
let(:base_host) { 'https://test-api.rd.services' }
|
7
|
+
|
8
|
+
before do
|
9
|
+
RDStation.configure do |config|
|
10
|
+
config.client_id = client_id
|
11
|
+
config.client_secret = client_secret
|
12
|
+
config.base_host = base_host
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
after { RDStation.configure {} }
|
7
17
|
|
18
|
+
describe '.configure' do
|
8
19
|
it 'sets the configuration' do
|
9
|
-
RDStation.
|
10
|
-
|
11
|
-
|
20
|
+
expect(RDStation.configuration.client_id).to eq(client_id)
|
21
|
+
expect(RDStation.configuration.client_secret).to eq(client_secret)
|
22
|
+
expect(RDStation.configuration.base_host).to eq(base_host)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
describe '.host' do
|
27
|
+
context 'when base_host is defined in configuration' do
|
28
|
+
it 'returns specified host' do
|
29
|
+
expect(RDStation.host).to eq(base_host)
|
12
30
|
end
|
31
|
+
end
|
32
|
+
|
33
|
+
context 'when base_host is not defined in configuration' do
|
34
|
+
it 'returns default host' do
|
35
|
+
RDStation.configure {}
|
13
36
|
|
14
|
-
|
15
|
-
|
37
|
+
expect(RDStation.host).to eq('https://api.rd.services')
|
38
|
+
end
|
16
39
|
end
|
17
40
|
end
|
18
41
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rdstation-ruby-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.5.
|
4
|
+
version: 2.5.3
|
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:
|
11
|
+
date: 2022-10-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -131,6 +131,7 @@ extra_rdoc_files: []
|
|
131
131
|
files:
|
132
132
|
- ".circleci/config.yml"
|
133
133
|
- ".github/ISSUE_TEMPLATE/rdsm-ruby-client-issue-template.md"
|
134
|
+
- ".github/dependabot.yml"
|
134
135
|
- ".gitignore"
|
135
136
|
- ".rspec"
|
136
137
|
- CHANGELOG.md
|
@@ -207,7 +208,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
207
208
|
- !ruby/object:Gem::Version
|
208
209
|
version: '0'
|
209
210
|
requirements: []
|
210
|
-
rubygems_version: 3.
|
211
|
+
rubygems_version: 3.2.32
|
211
212
|
signing_key:
|
212
213
|
specification_version: 4
|
213
214
|
summary: Ruby API wrapper for RD Station
|