rdstation-ruby-client 2.6.0 → 2.7.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/.circleci/config.yml +2 -2
- data/CHANGELOG.md +14 -0
- data/README.md +12 -1
- data/lib/rdstation/analytics.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/analytics_spec.rb +107 -0
- data/spec/lib/rdstation/fields_spec.rb +6 -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: f95c666afffacdbac2a2903c5b8909999bb24bba716f89d4646ee19c165bc262
|
4
|
+
data.tar.gz: 1beded8e2c402f5bb89523e3e20d5ee8ed485f6687819317f558f958bdd90353
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4803cf2a2f16e6982c84d84d9109c03130f8df4ff4d92ecfc9b5500e96383afdf6527b7dd834d7d1256d9947ab67f4aeed6d70591a2a86c3edf9b10ad7cced70
|
7
|
+
data.tar.gz: 344733aa7473f0d0db3391e26fc4a00648b9123ded0a5713549ab67462fdc528ef1a3256774d728aa2df6490cbdc989e65c2538e9a81c3f9829ab6f0622c303f
|
data/.circleci/config.yml
CHANGED
@@ -22,7 +22,7 @@ jobs:
|
|
22
22
|
# Download and cache dependencies
|
23
23
|
- restore_cache:
|
24
24
|
keys:
|
25
|
-
- v1-dependencies-{{ checksum "
|
25
|
+
- v1-dependencies-{{ checksum "rdstation-ruby-client.gemspec" }}
|
26
26
|
# fallback to using the latest cache if no exact match is found
|
27
27
|
- v1-dependencies-
|
28
28
|
|
@@ -34,7 +34,7 @@ jobs:
|
|
34
34
|
- save_cache:
|
35
35
|
paths:
|
36
36
|
- ./vendor/bundle
|
37
|
-
key: v1-dependencies-{{ checksum "
|
37
|
+
key: v1-dependencies-{{ checksum "rdstation-ruby-client.gemspec" }}
|
38
38
|
|
39
39
|
# run tests!
|
40
40
|
- run:
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,17 @@
|
|
1
|
+
## 2.7.0
|
2
|
+
|
3
|
+
### Additions
|
4
|
+
|
5
|
+
#### 1. New Analytics client
|
6
|
+
|
7
|
+
Usage example:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
client = RDStation::Client.new(access_token: 'access_token', refresh_token: 'refresh_token')
|
11
|
+
query_parms = { start_date:'2022-11-02', end_date:'2022-11-08' }
|
12
|
+
client.analytics.email_marketing(query_params)
|
13
|
+
```
|
14
|
+
|
1
15
|
## 2.6.0
|
2
16
|
|
3
17
|
### Additions
|
data/README.md
CHANGED
@@ -18,7 +18,8 @@ Upgrading? Check the [migration guide](#Migration-guide) before bumping to a new
|
|
18
18
|
6. [Webhooks](#Webhooks)
|
19
19
|
7. [Emails](#Emails)
|
20
20
|
8. [Segmentations](#Segmentations)
|
21
|
-
9. [
|
21
|
+
9. [Analytics](#Analytics)
|
22
|
+
10. [Errors](#Errors)
|
22
23
|
3. [Changelog](#Changelog)
|
23
24
|
4. [Migration guide](#Migration-guide)
|
24
25
|
1. [Upgrading from 1.2.x to 2.0.0](#Upgrading-from-1.2.x-to-2.0.0)
|
@@ -343,7 +344,17 @@ client.segmentations.all
|
|
343
344
|
client = RDStation::Client.new(access_token: 'access_token', refresh_token: 'refresh_token')
|
344
345
|
client.segmentations.contacts(segmentation_id)
|
345
346
|
```
|
347
|
+
### Analytics
|
348
|
+
Endpoints to [Analytics](https://developers.rdstation.com/reference/get_platform-analytics-emails) information in your RD Station account.
|
346
349
|
|
350
|
+
#### List all email marketing analytics data
|
351
|
+
- NOTE: The query params `start_date`(yyyy-mm-dd) and `end_date`(yyyy-mm-dd) are required
|
352
|
+
|
353
|
+
```ruby
|
354
|
+
client = RDStation::Client.new(access_token: 'access_token', refresh_token: 'refresh_token')
|
355
|
+
query_parms = { start_date:'2022-11-02', end_date:'2022-11-08' }
|
356
|
+
client.analytics.email_marketing(query_params)
|
357
|
+
```
|
347
358
|
### Errors
|
348
359
|
|
349
360
|
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 Analytics
|
5
|
+
include HTTParty
|
6
|
+
include ::RDStation::RetryableRequest
|
7
|
+
|
8
|
+
def initialize(authorization:)
|
9
|
+
@authorization = authorization
|
10
|
+
end
|
11
|
+
|
12
|
+
def email_marketing(query_params={})
|
13
|
+
retryable_request(@authorization) do |authorization|
|
14
|
+
response = self.class.get(base_url, headers: authorization.headers, query: query_params)
|
15
|
+
ApiResponse.build(response)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def base_url
|
22
|
+
"#{RDStation.host}/platform/analytics/emails"
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
data/lib/rdstation/client.rb
CHANGED
data/lib/rdstation/version.rb
CHANGED
@@ -0,0 +1,107 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe RDStation::Analytics do
|
4
|
+
let(:analytics_client) do
|
5
|
+
described_class.new(authorization: RDStation::Authorization.new(access_token: 'access_token'))
|
6
|
+
end
|
7
|
+
|
8
|
+
let(:analytics_endpoint) { 'https://api.rd.services/platform/analytics/emails' }
|
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 '#email_marketing' do
|
26
|
+
let(:analytics_list) do
|
27
|
+
{
|
28
|
+
account_id: 1,
|
29
|
+
query_date: {
|
30
|
+
start_date: "2022-11-08",
|
31
|
+
end_date: "2022-11-08"
|
32
|
+
},
|
33
|
+
emails: [
|
34
|
+
{
|
35
|
+
campaign_id: 6061281,
|
36
|
+
campaign_name: "Desconto",
|
37
|
+
send_at: "2021-08-06T17:26:39-03:00",
|
38
|
+
contacts_count: 1000,
|
39
|
+
email_dropped_count: 3,
|
40
|
+
email_delivered_count: 997,
|
41
|
+
email_bounced_count: 5,
|
42
|
+
email_opened_count: 500,
|
43
|
+
email_clicked_count: 500,
|
44
|
+
email_unsubscribed_count: 4,
|
45
|
+
email_spam_reported_count: 1,
|
46
|
+
email_delivered_rate: 98.7,
|
47
|
+
email_opened_rate: 46.9,
|
48
|
+
email_clicked_rate: 36.5,
|
49
|
+
email_spam_reported_rate: 0
|
50
|
+
}
|
51
|
+
]
|
52
|
+
}.to_json
|
53
|
+
end
|
54
|
+
|
55
|
+
it 'calls retryable_request' do
|
56
|
+
expect(analytics_client).to receive(:retryable_request)
|
57
|
+
analytics_client.email_marketing
|
58
|
+
end
|
59
|
+
|
60
|
+
context 'when the request is successful' do
|
61
|
+
before do
|
62
|
+
stub_request(:get, analytics_endpoint)
|
63
|
+
.with(headers: headers)
|
64
|
+
.to_return(status: 200, body: analytics_list.to_json)
|
65
|
+
end
|
66
|
+
|
67
|
+
it 'returns all email marketing analytics data' do
|
68
|
+
response = analytics_client.email_marketing
|
69
|
+
expect(response).to eq(analytics_list)
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
context 'when the request contains query params' do
|
74
|
+
let(:query_params) do
|
75
|
+
{
|
76
|
+
start_date:'2022-11-2',
|
77
|
+
end_date:'2022-11-8',
|
78
|
+
campaign_id: '6061281'
|
79
|
+
}
|
80
|
+
end
|
81
|
+
|
82
|
+
before do
|
83
|
+
stub_request(:get, analytics_endpoint)
|
84
|
+
.with(headers: headers, query: query_params)
|
85
|
+
.to_return(status: 200, body: analytics_list.to_json)
|
86
|
+
end
|
87
|
+
|
88
|
+
it 'returns email marketing analytics data filtered by the query params' do
|
89
|
+
response = analytics_client.email_marketing(query_params)
|
90
|
+
expect(response).to eq(analytics_list)
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
context 'when the response contains errors' do
|
95
|
+
before do
|
96
|
+
stub_request(:get, analytics_endpoint)
|
97
|
+
.with(headers: headers)
|
98
|
+
.to_return(status: 400, body: { 'errors' => ['all errors'] }.to_json)
|
99
|
+
end
|
100
|
+
|
101
|
+
it 'calls raise_error on error handler' do
|
102
|
+
analytics_client.email_marketing
|
103
|
+
expect(error_handler).to have_received(:raise_error)
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
@@ -9,6 +9,12 @@ RSpec.describe RDStation::Fields do
|
|
9
9
|
end
|
10
10
|
end
|
11
11
|
|
12
|
+
after do
|
13
|
+
RDStation.configure do |config|
|
14
|
+
config.base_host = 'https://api.rd.services'
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
12
18
|
let(:valid_access_token) { 'valid_access_token' }
|
13
19
|
let(:rdstation_fields_with_valid_token) do
|
14
20
|
described_class.new(authorization: RDStation::Authorization.new(access_token: valid_access_token))
|
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.7.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: 2022-
|
11
|
+
date: 2022-11-09 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/analytics.rb
|
144
145
|
- lib/rdstation/api_response.rb
|
145
146
|
- lib/rdstation/authentication.rb
|
146
147
|
- lib/rdstation/authorization.rb
|
@@ -168,6 +169,7 @@ files:
|
|
168
169
|
- lib/rdstation/webhooks.rb
|
169
170
|
- rdstation-ruby-client.gemspec
|
170
171
|
- spec/lib/rdstation-ruby-client_spec.rb
|
172
|
+
- spec/lib/rdstation/analytics_spec.rb
|
171
173
|
- spec/lib/rdstation/api_response_spec.rb
|
172
174
|
- spec/lib/rdstation/authentication_spec.rb
|
173
175
|
- spec/lib/rdstation/authorization_spec.rb
|
@@ -218,6 +220,7 @@ specification_version: 4
|
|
218
220
|
summary: Ruby API wrapper for RD Station
|
219
221
|
test_files:
|
220
222
|
- spec/lib/rdstation-ruby-client_spec.rb
|
223
|
+
- spec/lib/rdstation/analytics_spec.rb
|
221
224
|
- spec/lib/rdstation/api_response_spec.rb
|
222
225
|
- spec/lib/rdstation/authentication_spec.rb
|
223
226
|
- spec/lib/rdstation/authorization_spec.rb
|