rdstation-ruby-client 2.8.2 → 2.9.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +14 -0
- data/README.md +12 -1
- data/lib/rdstation/account.rb +25 -0
- data/lib/rdstation/client.rb +4 -0
- data/lib/rdstation/version.rb +1 -1
- data/lib/rdstation-ruby-client.rb +1 -0
- data/spec/lib/rdstation/account_spec.rb +57 -0
- data/spec/lib/rdstation/client_spec.rb +5 -0
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c3de60aebf7582be38403250a4d049f3428241b66a18acb085cdd71f542cb8a0
|
4
|
+
data.tar.gz: '0829e4b85cae5dd80c64395f6e460ebb315fee92853d81a5feb263adaa2e3efe'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1206caba197401915572f9bb66dd2c45ad2c019d8ce5899d0667753043066cce96edfc39207054549de900cf57e3eb1179c6e4bcf58bed5bac459ef37d49cc12
|
7
|
+
data.tar.gz: c27a1e2c5d5d3ef4ddc3cfc1f0369f9be0cf09c040147fe1409bcc6d77a3c4d2fc7f697f3d40db2f83fbc2a0c79cad61e9378d4cbc3eedc9df0fe9ec9eaa91ef
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,17 @@
|
|
1
|
+
## 2.9.0
|
2
|
+
|
3
|
+
### Additions
|
4
|
+
|
5
|
+
#### 1. New Account client
|
6
|
+
|
7
|
+
Usage example:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
client = RDStation::Client.new(access_token: 'access_token', refresh_token: 'refresh_token')
|
11
|
+
client.account.info
|
12
|
+
```
|
13
|
+
|
14
|
+
|
1
15
|
## 2.8.2
|
2
16
|
|
3
17
|
- Fix TooManyRequest handler
|
data/README.md
CHANGED
@@ -20,7 +20,8 @@ Upgrading? Check the [migration guide](#Migration-guide) before bumping to a new
|
|
20
20
|
8. [Segmentations](#Segmentations)
|
21
21
|
9. [Analytics](#Analytics)
|
22
22
|
10.[LandingPages](#LandingPages)
|
23
|
-
11.[
|
23
|
+
11.[Account](#Account)
|
24
|
+
12.[Errors](#Errors)
|
24
25
|
3. [Changelog](#Changelog)
|
25
26
|
4. [Migration guide](#Migration-guide)
|
26
27
|
1. [Upgrading from 1.2.x to 2.0.0](#Upgrading-from-1.2.x-to-2.0.0)
|
@@ -377,6 +378,16 @@ client = RDStation::Client.new(access_token: 'access_token', refresh_token: 'ref
|
|
377
378
|
client.landing_pages.all
|
378
379
|
```
|
379
380
|
|
381
|
+
### Account
|
382
|
+
|
383
|
+
Returns the account information.
|
384
|
+
|
385
|
+
```ruby
|
386
|
+
client = RDStation::Client.new(access_token: 'access_token', refresh_token: 'refresh_token')
|
387
|
+
client.account.info
|
388
|
+
=> {"name"=>"www.rdstation.com"}
|
389
|
+
```
|
390
|
+
|
380
391
|
### Errors
|
381
392
|
|
382
393
|
Each endpoint may raise errors accoording to the HTTP response code from RDStation:
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RDStation
|
4
|
+
class Account
|
5
|
+
include HTTParty
|
6
|
+
include ::RDStation::RetryableRequest
|
7
|
+
|
8
|
+
def initialize(authorization:)
|
9
|
+
@authorization = authorization
|
10
|
+
end
|
11
|
+
|
12
|
+
def info
|
13
|
+
retryable_request(@authorization) do |authorization|
|
14
|
+
response = self.class.get(base_url, headers: authorization.headers)
|
15
|
+
ApiResponse.build(response)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def base_url(_path = '')
|
22
|
+
"#{RDStation.host}/marketing/account_info"
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
data/lib/rdstation/client.rb
CHANGED
data/lib/rdstation/version.rb
CHANGED
@@ -0,0 +1,57 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe RDStation::Account do
|
4
|
+
let(:client) do
|
5
|
+
described_class.new(authorization: RDStation::Authorization.new(access_token: 'access_token'))
|
6
|
+
end
|
7
|
+
|
8
|
+
let(:endpoint) { 'https://api.rd.services/marketing/account_info' }
|
9
|
+
|
10
|
+
let(:headers) do
|
11
|
+
{
|
12
|
+
'Authorization' => 'Bearer access_token',
|
13
|
+
'Content-Type' => 'application/json'
|
14
|
+
}
|
15
|
+
end
|
16
|
+
|
17
|
+
let(:error_handler) do
|
18
|
+
instance_double(RDStation::ErrorHandler, raise_error: 'mock raised errors')
|
19
|
+
end
|
20
|
+
|
21
|
+
before do
|
22
|
+
allow(RDStation::ErrorHandler).to receive(:new).and_return(error_handler)
|
23
|
+
end
|
24
|
+
|
25
|
+
describe '#info' do
|
26
|
+
it 'calls retryable_request' do
|
27
|
+
expect(client).to receive(:retryable_request)
|
28
|
+
client.info
|
29
|
+
end
|
30
|
+
|
31
|
+
context 'when the request is successful' do
|
32
|
+
before do
|
33
|
+
stub_request(:get, endpoint)
|
34
|
+
.with(headers: headers)
|
35
|
+
.to_return(status: 200, body: {name: 'www.rdstation.com'}.to_json)
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'return RDSM account information' do
|
39
|
+
response = client.info
|
40
|
+
expect(response).to eq({ 'name' => 'www.rdstation.com'})
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
context 'when the response contains errors' do
|
45
|
+
before do
|
46
|
+
stub_request(:get, endpoint)
|
47
|
+
.with(headers: headers)
|
48
|
+
.to_return(status: 404, body: { 'errors' => ['not found'] }.to_json)
|
49
|
+
end
|
50
|
+
|
51
|
+
it 'calls raise_error on error handler' do
|
52
|
+
client.info
|
53
|
+
expect(error_handler).to have_received(:raise_error)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -27,6 +27,11 @@ RSpec.describe RDStation::Client do
|
|
27
27
|
expect(RDStation::Webhooks).to receive(:new).with({ authorization: mock_authorization }).and_call_original
|
28
28
|
expect(client.webhooks).to be_instance_of RDStation::Webhooks
|
29
29
|
end
|
30
|
+
|
31
|
+
it 'returns Account endpoint' do
|
32
|
+
expect(RDStation::Account).to receive(:new).with({ authorization: mock_authorization }).and_call_original
|
33
|
+
expect(client.account).to be_instance_of RDStation::Account
|
34
|
+
end
|
30
35
|
end
|
31
36
|
|
32
37
|
context "when access_token isn't given" do
|
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.
|
4
|
+
version: 2.9.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: 2023-
|
11
|
+
date: 2023-03-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -141,6 +141,7 @@ files:
|
|
141
141
|
- Rakefile
|
142
142
|
- lib/rdstation-ruby-client.rb
|
143
143
|
- lib/rdstation.rb
|
144
|
+
- lib/rdstation/account.rb
|
144
145
|
- lib/rdstation/analytics.rb
|
145
146
|
- lib/rdstation/api_response.rb
|
146
147
|
- lib/rdstation/authentication.rb
|
@@ -170,6 +171,7 @@ files:
|
|
170
171
|
- lib/rdstation/webhooks.rb
|
171
172
|
- rdstation-ruby-client.gemspec
|
172
173
|
- spec/lib/rdstation-ruby-client_spec.rb
|
174
|
+
- spec/lib/rdstation/account_spec.rb
|
173
175
|
- spec/lib/rdstation/analytics_spec.rb
|
174
176
|
- spec/lib/rdstation/api_response_spec.rb
|
175
177
|
- spec/lib/rdstation/authentication_spec.rb
|
@@ -222,6 +224,7 @@ specification_version: 4
|
|
222
224
|
summary: Ruby API wrapper for RD Station
|
223
225
|
test_files:
|
224
226
|
- spec/lib/rdstation-ruby-client_spec.rb
|
227
|
+
- spec/lib/rdstation/account_spec.rb
|
225
228
|
- spec/lib/rdstation/analytics_spec.rb
|
226
229
|
- spec/lib/rdstation/api_response_spec.rb
|
227
230
|
- spec/lib/rdstation/authentication_spec.rb
|