mrkt 1.2.0 → 1.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/dependabot.yml +8 -0
- data/.github/workflows/ruby.yml +2 -2
- data/.rubocop.yml +14 -1
- data/Gemfile.lock +16 -13
- data/lib/mrkt/concerns/crud_program_members.rb +31 -0
- data/lib/mrkt/version.rb +1 -1
- data/lib/mrkt.rb +2 -0
- data/mrkt.gemspec +4 -1
- data/spec/concerns/authentication_spec.rb +31 -34
- data/spec/concerns/crud_activities_spec.rb +20 -13
- data/spec/concerns/crud_asset_folders_spec.rb +12 -12
- data/spec/concerns/crud_asset_static_lists_spec.rb +4 -4
- data/spec/concerns/crud_campaigns_spec.rb +18 -17
- data/spec/concerns/crud_custom_activities_spec.rb +14 -15
- data/spec/concerns/crud_custom_objects_spec.rb +15 -15
- data/spec/concerns/crud_leads_spec.rb +17 -14
- data/spec/concerns/crud_lists_spec.rb +7 -5
- data/spec/concerns/crud_program_members_spec.rb +141 -0
- data/spec/concerns/crud_programs_spec.rb +5 -5
- data/spec/concerns/import_custom_objects_spec.rb +9 -5
- data/spec/concerns/import_leads_spec.rb +9 -5
- data/spec/errors_spec.rb +9 -11
- data/spec/faraday/params_encoder_spec.rb +4 -4
- data/spec/mkto_rest_spec.rb +1 -1
- data/spec/support/initialized_client.rb +3 -3
- metadata +23 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 850ac5a692b131df87d8bc0a86d0bbd0c82fb38b382a41cc201e427caaba18f6
|
4
|
+
data.tar.gz: 4eb5399bad28b69658a2a7699d87e691a6d18c273061985aa4b558001e79d37a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6cc5334a1161bf7fe032e5b5919e9a7b0721124965a1a2e2b6cefed6d9305550eedd0a8370f401d85d884a6b08f5fcb1c3eadb60d4ba3bba05be457f09c4e8cc
|
7
|
+
data.tar.gz: b325752b6d9cec194cc9cab4cea09744a63d9a48ebe80c774aca9d3233b8e6c07f60d644fe41d49fb0059ebf9bd625cdf2a191353c390d970ddb1e0311412533
|
data/.github/dependabot.yml
CHANGED
@@ -4,8 +4,16 @@ updates:
|
|
4
4
|
directory: "/"
|
5
5
|
schedule:
|
6
6
|
interval: "weekly"
|
7
|
+
commit-message:
|
8
|
+
prefix: "chore"
|
9
|
+
include: "scope"
|
10
|
+
rebase-strategy: "disabled"
|
7
11
|
|
8
12
|
- package-ecosystem: "github-actions"
|
9
13
|
directory: "/"
|
10
14
|
schedule:
|
11
15
|
interval: "daily"
|
16
|
+
commit-message:
|
17
|
+
prefix: "chore"
|
18
|
+
include: "scope"
|
19
|
+
rebase-strategy: "disabled"
|
data/.github/workflows/ruby.yml
CHANGED
@@ -15,7 +15,7 @@ jobs:
|
|
15
15
|
ruby: [2.5, 2.6, 2.7, 3.0]
|
16
16
|
|
17
17
|
steps:
|
18
|
-
- uses: actions/checkout@v2.
|
18
|
+
- uses: actions/checkout@v2.4.0
|
19
19
|
|
20
20
|
- name: Set up Ruby
|
21
21
|
uses: ruby/setup-ruby@v1
|
@@ -33,7 +33,7 @@ jobs:
|
|
33
33
|
run: bundle install
|
34
34
|
|
35
35
|
- name: Run tests and publish coverage
|
36
|
-
uses: paambaati/codeclimate-action@
|
36
|
+
uses: paambaati/codeclimate-action@v3.0.0
|
37
37
|
env:
|
38
38
|
COVERAGE: on
|
39
39
|
CC_TEST_REPORTER_ID: 45cd2174f49b570406e294ff393d456c4ae8532cf16dd6430abb06d8a0722a28
|
data/.rubocop.yml
CHANGED
@@ -1,4 +1,6 @@
|
|
1
|
-
require:
|
1
|
+
require:
|
2
|
+
- rubocop-rake
|
3
|
+
- rubocop-rspec
|
2
4
|
|
3
5
|
AllCops:
|
4
6
|
TargetRubyVersion: 2.5
|
@@ -24,6 +26,7 @@ Metrics/AbcSize:
|
|
24
26
|
Metrics/BlockLength:
|
25
27
|
Exclude:
|
26
28
|
- 'spec/**/*'
|
29
|
+
- '**/*.gemspec'
|
27
30
|
Metrics/MethodLength:
|
28
31
|
Max: 20
|
29
32
|
Metrics/ParameterLists:
|
@@ -32,6 +35,16 @@ Metrics/ParameterLists:
|
|
32
35
|
Naming/AccessorMethodName:
|
33
36
|
Enabled: false
|
34
37
|
|
38
|
+
RSpec/FilePath:
|
39
|
+
Enabled: false
|
40
|
+
RSpec/NestedGroups:
|
41
|
+
Enabled: false
|
42
|
+
RSpec/MultipleMemoizedHelpers:
|
43
|
+
Enabled: false
|
44
|
+
RSpec/MultipleExpectations:
|
45
|
+
Exclude:
|
46
|
+
- 'spec/concerns/authentication_spec.rb'
|
47
|
+
|
35
48
|
Style/ClassAndModuleChildren:
|
36
49
|
Enabled: false
|
37
50
|
Style/Documentation:
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
mrkt (1.2.
|
4
|
+
mrkt (1.2.1)
|
5
5
|
faraday (~> 1.0)
|
6
6
|
faraday_middleware (~> 1.0)
|
7
7
|
|
@@ -16,8 +16,8 @@ GEM
|
|
16
16
|
crack (0.4.5)
|
17
17
|
rexml
|
18
18
|
diff-lcs (1.4.4)
|
19
|
-
docile (1.
|
20
|
-
faraday (1.
|
19
|
+
docile (1.4.0)
|
20
|
+
faraday (1.8.0)
|
21
21
|
faraday-em_http (~> 1.0)
|
22
22
|
faraday-em_synchrony (~> 1.0)
|
23
23
|
faraday-excon (~> 1.1)
|
@@ -36,14 +36,14 @@ GEM
|
|
36
36
|
faraday-net_http_persistent (1.2.0)
|
37
37
|
faraday-patron (1.0.0)
|
38
38
|
faraday-rack (1.0.0)
|
39
|
-
faraday_middleware (1.
|
39
|
+
faraday_middleware (1.2.0)
|
40
40
|
faraday (~> 1.0)
|
41
41
|
gem-release (2.2.2)
|
42
42
|
hashdiff (1.0.1)
|
43
43
|
method_source (1.0.0)
|
44
44
|
multipart-post (2.1.1)
|
45
|
-
parallel (1.
|
46
|
-
parser (3.0.2
|
45
|
+
parallel (1.21.0)
|
46
|
+
parser (3.0.3.2)
|
47
47
|
ast (~> 2.4.1)
|
48
48
|
pry (0.13.1)
|
49
49
|
coderay (~> 1.1)
|
@@ -54,7 +54,7 @@ GEM
|
|
54
54
|
public_suffix (4.0.6)
|
55
55
|
rainbow (3.0.0)
|
56
56
|
rake (13.0.6)
|
57
|
-
regexp_parser (2.
|
57
|
+
regexp_parser (2.2.0)
|
58
58
|
rexml (3.2.5)
|
59
59
|
rspec (3.10.0)
|
60
60
|
rspec-core (~> 3.10.0)
|
@@ -68,20 +68,22 @@ GEM
|
|
68
68
|
rspec-mocks (3.10.2)
|
69
69
|
diff-lcs (>= 1.2.0, < 2.0)
|
70
70
|
rspec-support (~> 3.10.0)
|
71
|
-
rspec-support (3.10.
|
72
|
-
rubocop (1.
|
71
|
+
rspec-support (3.10.3)
|
72
|
+
rubocop (1.23.0)
|
73
73
|
parallel (~> 1.10)
|
74
74
|
parser (>= 3.0.0.0)
|
75
75
|
rainbow (>= 2.2.2, < 4.0)
|
76
76
|
regexp_parser (>= 1.8, < 3.0)
|
77
77
|
rexml
|
78
|
-
rubocop-ast (>= 1.
|
78
|
+
rubocop-ast (>= 1.12.0, < 2.0)
|
79
79
|
ruby-progressbar (~> 1.7)
|
80
80
|
unicode-display_width (>= 1.4.0, < 3.0)
|
81
|
-
rubocop-ast (1.
|
81
|
+
rubocop-ast (1.15.0)
|
82
82
|
parser (>= 3.0.1.1)
|
83
83
|
rubocop-rake (0.6.0)
|
84
84
|
rubocop (~> 1.0)
|
85
|
+
rubocop-rspec (2.6.0)
|
86
|
+
rubocop (~> 1.19)
|
85
87
|
ruby-progressbar (1.11.0)
|
86
88
|
ruby2_keywords (0.0.5)
|
87
89
|
simplecov (0.21.2)
|
@@ -90,7 +92,7 @@ GEM
|
|
90
92
|
simplecov_json_formatter (~> 0.1)
|
91
93
|
simplecov-html (0.12.3)
|
92
94
|
simplecov_json_formatter (0.1.3)
|
93
|
-
unicode-display_width (2.
|
95
|
+
unicode-display_width (2.1.0)
|
94
96
|
webmock (3.14.0)
|
95
97
|
addressable (>= 2.8.0)
|
96
98
|
crack (>= 0.3.2)
|
@@ -106,8 +108,9 @@ DEPENDENCIES
|
|
106
108
|
pry-byebug (~> 3.7)
|
107
109
|
rake (~> 13.0)
|
108
110
|
rspec (~> 3.2)
|
109
|
-
rubocop (~> 1.
|
111
|
+
rubocop (~> 1.23.0)
|
110
112
|
rubocop-rake (~> 0.6.0)
|
113
|
+
rubocop-rspec (~> 2.6)
|
111
114
|
simplecov (~> 0.21.2)
|
112
115
|
webmock (~> 3.1)
|
113
116
|
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module Mrkt
|
2
|
+
module CrudProgramMembers
|
3
|
+
def describe_program_members
|
4
|
+
get('/rest/v1/programs/members/describe.json')
|
5
|
+
end
|
6
|
+
|
7
|
+
def createupdate_program_members(program_id, lead_ids, status)
|
8
|
+
post_json("/rest/v1/programs/#{program_id}/members/status.json") do
|
9
|
+
{
|
10
|
+
statusName: status,
|
11
|
+
input: lead_ids.map { |lead_id| { leadId: lead_id } }
|
12
|
+
}
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def get_program_members(program_id, filter_type, filter_values, fields: nil, batch_size: nil, next_page_token: nil)
|
17
|
+
params = {
|
18
|
+
filterType: filter_type,
|
19
|
+
filterValues: filter_values
|
20
|
+
}
|
21
|
+
|
22
|
+
optional = {
|
23
|
+
fields: fields,
|
24
|
+
batchSize: batch_size,
|
25
|
+
nextPageToken: next_page_token
|
26
|
+
}
|
27
|
+
|
28
|
+
get("/rest/v1/programs/#{program_id}/members.json", params, optional)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
data/lib/mrkt/version.rb
CHANGED
data/lib/mrkt.rb
CHANGED
@@ -13,6 +13,7 @@ require 'mrkt/concerns/import_custom_objects'
|
|
13
13
|
require 'mrkt/concerns/crud_custom_objects'
|
14
14
|
require 'mrkt/concerns/crud_custom_activities'
|
15
15
|
require 'mrkt/concerns/crud_programs'
|
16
|
+
require 'mrkt/concerns/crud_program_members'
|
16
17
|
require 'mrkt/concerns/crud_asset_static_lists'
|
17
18
|
require 'mrkt/concerns/crud_asset_folders'
|
18
19
|
|
@@ -30,6 +31,7 @@ module Mrkt
|
|
30
31
|
include CrudCustomObjects
|
31
32
|
include CrudCustomActivities
|
32
33
|
include CrudPrograms
|
34
|
+
include CrudProgramMembers
|
33
35
|
include CrudAssetStaticLists
|
34
36
|
include CrudAssetFolders
|
35
37
|
|
data/mrkt.gemspec
CHANGED
@@ -17,6 +17,8 @@ Gem::Specification.new do |spec|
|
|
17
17
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
18
18
|
spec.require_paths = %w[lib]
|
19
19
|
|
20
|
+
spec.metadata['rubygems_mfa_required'] = 'true'
|
21
|
+
|
20
22
|
spec.required_ruby_version = '>= 2.5'
|
21
23
|
|
22
24
|
spec.add_dependency 'faraday', '~> 1.0'
|
@@ -27,8 +29,9 @@ Gem::Specification.new do |spec|
|
|
27
29
|
spec.add_development_dependency 'pry-byebug', '~> 3.7'
|
28
30
|
spec.add_development_dependency 'rake', '~> 13.0'
|
29
31
|
spec.add_development_dependency 'rspec', '~> 3.2'
|
30
|
-
spec.add_development_dependency 'rubocop', '~> 1.
|
32
|
+
spec.add_development_dependency 'rubocop', '~> 1.23.0'
|
31
33
|
spec.add_development_dependency 'rubocop-rake', '~> 0.6.0'
|
34
|
+
spec.add_development_dependency 'rubocop-rspec', '~> 2.6'
|
32
35
|
spec.add_development_dependency 'simplecov', '~> 0.21.2'
|
33
36
|
spec.add_development_dependency 'webmock', '~> 3.1'
|
34
37
|
end
|
@@ -1,10 +1,10 @@
|
|
1
1
|
describe Mrkt::Authentication do
|
2
|
-
include_context 'initialized client'
|
2
|
+
include_context 'with an initialized client'
|
3
3
|
|
4
4
|
describe '#authenticate' do
|
5
|
-
subject { client.authenticate }
|
5
|
+
subject(:action) { client.authenticate }
|
6
6
|
|
7
|
-
context 'on a successful response' do
|
7
|
+
context 'with on a successful response' do
|
8
8
|
it { is_expected.to be_success }
|
9
9
|
end
|
10
10
|
|
@@ -16,21 +16,28 @@ describe Mrkt::Authentication do
|
|
16
16
|
}
|
17
17
|
end
|
18
18
|
|
19
|
-
it '
|
20
|
-
expect {
|
19
|
+
it 'raises an Error' do
|
20
|
+
expect { action }.to raise_error(Mrkt::Errors::Error, 'Bad client credentials')
|
21
21
|
end
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
25
25
|
describe '#authenticate!' do
|
26
|
-
it '
|
27
|
-
expect(client.authenticated?).
|
26
|
+
it 'authenticates the client' do
|
27
|
+
expect(client.authenticated?).not_to be true
|
28
|
+
|
28
29
|
client.authenticate!
|
29
30
|
expect(client.authenticated?).to be true
|
30
31
|
end
|
31
32
|
|
32
33
|
context 'with optional partner_id client option' do
|
33
|
-
|
34
|
+
subject(:client) { Mrkt::Client.new(client_options) }
|
35
|
+
|
36
|
+
before do
|
37
|
+
stub_request(:get, "https://#{host}/identity/oauth/token")
|
38
|
+
.with(query: query)
|
39
|
+
.to_return(json_stub(authentication_stub))
|
40
|
+
end
|
34
41
|
|
35
42
|
let(:partner_id) { SecureRandom.uuid }
|
36
43
|
|
@@ -52,23 +59,22 @@ describe Mrkt::Authentication do
|
|
52
59
|
}
|
53
60
|
end
|
54
61
|
|
55
|
-
|
56
|
-
|
57
|
-
before do
|
58
|
-
stub_request(:get, "https://#{host}/identity/oauth/token")
|
59
|
-
.with(query: query)
|
60
|
-
.to_return(json_stub(authentication_stub))
|
61
|
-
end
|
62
|
-
|
63
|
-
it 'should authenticate and then be authenticated?' do
|
64
|
-
expect(client.authenticated?).to_not be true
|
62
|
+
it 'authenticates the client' do
|
63
|
+
expect(client.authenticated?).not_to be true
|
65
64
|
client.authenticate!
|
66
65
|
expect(client.authenticated?).to be true
|
67
66
|
end
|
68
67
|
end
|
69
68
|
|
70
69
|
context 'when the token has expired and @retry_authentication = true' do
|
71
|
-
|
70
|
+
subject(:client) { Mrkt::Client.new(client_options) }
|
71
|
+
|
72
|
+
before do
|
73
|
+
stub_request(:get, "https://#{host}/identity/oauth/token")
|
74
|
+
.with(query: { client_id: client_id, client_secret: client_secret, grant_type: 'client_credentials' })
|
75
|
+
.to_return(json_stub(expired_authentication_stub)).times(3).then
|
76
|
+
.to_return(json_stub(valid_authentication_stub))
|
77
|
+
end
|
72
78
|
|
73
79
|
let(:retry_count) { 3 }
|
74
80
|
|
@@ -90,17 +96,8 @@ describe Mrkt::Authentication do
|
|
90
96
|
}
|
91
97
|
end
|
92
98
|
|
93
|
-
|
94
|
-
|
95
|
-
before do
|
96
|
-
stub_request(:get, "https://#{host}/identity/oauth/token")
|
97
|
-
.with(query: { client_id: client_id, client_secret: client_secret, grant_type: 'client_credentials' })
|
98
|
-
.to_return(json_stub(expired_authentication_stub)).times(3).then
|
99
|
-
.to_return(json_stub(valid_authentication_stub))
|
100
|
-
end
|
101
|
-
|
102
|
-
it 'should retry until getting valid token and then be authenticated?' do
|
103
|
-
expect(client.authenticated?).to_not be true
|
99
|
+
it 'retries until it gets a valid token' do
|
100
|
+
expect(client.authenticated?).not_to be true
|
104
101
|
client.authenticate!
|
105
102
|
expect(client.authenticated?).to be true
|
106
103
|
end
|
@@ -108,8 +105,8 @@ describe Mrkt::Authentication do
|
|
108
105
|
context 'when retry_authentication_count is low' do
|
109
106
|
let(:retry_count) { 2 }
|
110
107
|
|
111
|
-
it '
|
112
|
-
expect(client.authenticated?).
|
108
|
+
it 'stops retrying after a while' do
|
109
|
+
expect(client.authenticated?).not_to be true
|
113
110
|
|
114
111
|
expect { client.authenticate! }.to raise_error(Mrkt::Errors::Error, 'Client not authenticated')
|
115
112
|
end
|
@@ -120,11 +117,11 @@ describe Mrkt::Authentication do
|
|
120
117
|
describe '#authenticated?' do
|
121
118
|
subject { client.authenticated? }
|
122
119
|
|
123
|
-
context '
|
120
|
+
context 'when authentication has not been done' do
|
124
121
|
it { is_expected.to be_falsey }
|
125
122
|
end
|
126
123
|
|
127
|
-
context '
|
124
|
+
context 'when authentication has been done' do
|
128
125
|
before { client.authenticate }
|
129
126
|
|
130
127
|
it { is_expected.to be_truthy }
|
@@ -1,7 +1,9 @@
|
|
1
1
|
describe Mrkt::CrudActivities do
|
2
|
-
include_context 'initialized client'
|
2
|
+
include_context 'with an initialized client'
|
3
3
|
|
4
4
|
describe '#get_activity_types' do
|
5
|
+
subject { client.get_activity_types }
|
6
|
+
|
5
7
|
let(:response_stub) do
|
6
8
|
{
|
7
9
|
requestId: 'c245#14cd6830ae2',
|
@@ -29,7 +31,6 @@ describe Mrkt::CrudActivities do
|
|
29
31
|
success: true
|
30
32
|
}
|
31
33
|
end
|
32
|
-
subject { client.get_activity_types }
|
33
34
|
|
34
35
|
before do
|
35
36
|
stub_request(:get, "https://#{host}/rest/v1/activities/types.json")
|
@@ -40,6 +41,8 @@ describe Mrkt::CrudActivities do
|
|
40
41
|
end
|
41
42
|
|
42
43
|
describe '#get_paging_token' do
|
44
|
+
subject { client.get_paging_token(since_datetime) }
|
45
|
+
|
43
46
|
let(:since_datetime) { Time.utc(2017, 1, 1, 4, 30) }
|
44
47
|
let(:response_stub) do
|
45
48
|
{
|
@@ -48,7 +51,6 @@ describe Mrkt::CrudActivities do
|
|
48
51
|
nextPageToken: '4GAX7YNCIJKO2VAED5LH5PQIYPUM7WCVKTQWEDMP2L24AXZT54LA===='
|
49
52
|
}
|
50
53
|
end
|
51
|
-
subject { client.get_paging_token(since_datetime) }
|
52
54
|
|
53
55
|
before do
|
54
56
|
stub_request(:get, "https://#{host}/rest/v1/activities/pagingtoken.json")
|
@@ -60,6 +62,8 @@ describe Mrkt::CrudActivities do
|
|
60
62
|
end
|
61
63
|
|
62
64
|
describe '#get_activities' do
|
65
|
+
subject { client.get_activities(token) }
|
66
|
+
|
63
67
|
let(:activity_type_ids) { [1, 2] }
|
64
68
|
let(:lead_ids) { [100, 102] }
|
65
69
|
let(:token) { '4GAX7YNCIJKO2VAED5LH5PQIYPUM7WCVKTQWEDMP2L24AXZT54LA====' }
|
@@ -106,7 +110,6 @@ describe Mrkt::CrudActivities do
|
|
106
110
|
moreResult: false
|
107
111
|
}
|
108
112
|
end
|
109
|
-
subject { client.get_activities(token) }
|
110
113
|
|
111
114
|
before do
|
112
115
|
stub_request(:get, "https://#{host}/rest/v1/activities.json")
|
@@ -116,7 +119,9 @@ describe Mrkt::CrudActivities do
|
|
116
119
|
|
117
120
|
it { is_expected.to eq(response_stub) }
|
118
121
|
|
119
|
-
context 'specifying activity type ids' do
|
122
|
+
context 'when specifying activity type ids' do
|
123
|
+
subject { client.get_activities(token, activity_type_ids: activity_type_ids) }
|
124
|
+
|
120
125
|
let(:response_stub) do
|
121
126
|
{
|
122
127
|
data: {
|
@@ -147,7 +152,6 @@ describe Mrkt::CrudActivities do
|
|
147
152
|
moreResult: false
|
148
153
|
}
|
149
154
|
end
|
150
|
-
subject { client.get_activities(token, activity_type_ids: activity_type_ids) }
|
151
155
|
|
152
156
|
before do
|
153
157
|
stub_request(:get, "https://#{host}/rest/v1/activities.json")
|
@@ -161,7 +165,9 @@ describe Mrkt::CrudActivities do
|
|
161
165
|
it { is_expected.to eq(response_stub) }
|
162
166
|
end
|
163
167
|
|
164
|
-
context 'specifying lead ids' do
|
168
|
+
context 'when specifying lead ids' do
|
169
|
+
subject { client.get_activities(token, lead_ids: lead_ids) }
|
170
|
+
|
165
171
|
let(:response_stub) do
|
166
172
|
{
|
167
173
|
data: {
|
@@ -192,7 +198,6 @@ describe Mrkt::CrudActivities do
|
|
192
198
|
moreResult: false
|
193
199
|
}
|
194
200
|
end
|
195
|
-
subject { client.get_activities(token, lead_ids: lead_ids) }
|
196
201
|
|
197
202
|
before do
|
198
203
|
stub_request(:get, "https://#{host}/rest/v1/activities.json")
|
@@ -203,13 +208,14 @@ describe Mrkt::CrudActivities do
|
|
203
208
|
it { is_expected.to eq(response_stub) }
|
204
209
|
end
|
205
210
|
|
206
|
-
context 'specifying arrays values as empty strings' do
|
207
|
-
let(:activity_type_ids) { '' }
|
208
|
-
let(:lead_ids) { '' }
|
211
|
+
context 'when specifying arrays values as empty strings' do
|
209
212
|
subject do
|
210
213
|
client.get_activities(token, activity_type_ids: activity_type_ids, lead_ids: lead_ids)
|
211
214
|
end
|
212
215
|
|
216
|
+
let(:activity_type_ids) { '' }
|
217
|
+
let(:lead_ids) { '' }
|
218
|
+
|
213
219
|
before do
|
214
220
|
stub_request(:get, "https://#{host}/rest/v1/activities.json")
|
215
221
|
.with(query: { nextPageToken: token })
|
@@ -219,7 +225,7 @@ describe Mrkt::CrudActivities do
|
|
219
225
|
it { is_expected.to eq(response_stub) }
|
220
226
|
end
|
221
227
|
|
222
|
-
context 'specifying all options' do
|
228
|
+
context 'when specifying all options' do
|
223
229
|
subject do
|
224
230
|
client.get_activities(token, activity_type_ids: activity_type_ids, lead_ids: lead_ids)
|
225
231
|
end
|
@@ -239,6 +245,8 @@ describe Mrkt::CrudActivities do
|
|
239
245
|
end
|
240
246
|
|
241
247
|
describe '#get_deleted_leads' do
|
248
|
+
subject { client.get_deleted_leads(token) }
|
249
|
+
|
242
250
|
let(:token) { '4GAX7YNCIJKO2VAED5LH5PQIYPUM7WCVKTQWEDMP2L24AXZT54LA====' }
|
243
251
|
let(:response_stub) do
|
244
252
|
{
|
@@ -266,7 +274,6 @@ describe Mrkt::CrudActivities do
|
|
266
274
|
moreResult: false
|
267
275
|
}
|
268
276
|
end
|
269
|
-
subject { client.get_deleted_leads(token) }
|
270
277
|
|
271
278
|
before do
|
272
279
|
stub_request(:get, "https://#{host}/rest/v1/activities/deletedleads.json")
|
@@ -1,5 +1,5 @@
|
|
1
1
|
describe Mrkt::CrudAssetFolders do
|
2
|
-
include_context 'initialized client'
|
2
|
+
include_context 'with an initialized client'
|
3
3
|
|
4
4
|
let(:response_folder_result) do
|
5
5
|
{
|
@@ -65,7 +65,7 @@ describe Mrkt::CrudAssetFolders do
|
|
65
65
|
end
|
66
66
|
|
67
67
|
describe '#get_folder_by_id' do
|
68
|
-
subject { client.get_folder_by_id(id, type: type) }
|
68
|
+
subject(:action) { client.get_folder_by_id(id, type: type) }
|
69
69
|
|
70
70
|
let(:id) { 77 }
|
71
71
|
|
@@ -123,14 +123,14 @@ describe Mrkt::CrudAssetFolders do
|
|
123
123
|
}
|
124
124
|
end
|
125
125
|
|
126
|
-
it '
|
127
|
-
expect {
|
126
|
+
it 'raises an Error' do
|
127
|
+
expect { action }.to raise_error(Mrkt::Errors::TypeMismatch)
|
128
128
|
end
|
129
129
|
end
|
130
130
|
end
|
131
131
|
|
132
132
|
describe '#get_folder_by_name' do
|
133
|
-
subject { client.get_folder_by_name(name, type: type, root: root, work_space: work_space) }
|
133
|
+
subject(:action) { client.get_folder_by_name(name, type: type, root: root, work_space: work_space) }
|
134
134
|
|
135
135
|
let(:name) { 'Test Folder Name' }
|
136
136
|
let(:type) { 'Folder' }
|
@@ -196,8 +196,8 @@ describe Mrkt::CrudAssetFolders do
|
|
196
196
|
}
|
197
197
|
end
|
198
198
|
|
199
|
-
it '
|
200
|
-
expect {
|
199
|
+
it 'raises an Error' do
|
200
|
+
expect { action }.to raise_error(Mrkt::Errors::System)
|
201
201
|
end
|
202
202
|
end
|
203
203
|
|
@@ -216,14 +216,14 @@ describe Mrkt::CrudAssetFolders do
|
|
216
216
|
}
|
217
217
|
end
|
218
218
|
|
219
|
-
it '
|
220
|
-
expect {
|
219
|
+
it 'raises an Error' do
|
220
|
+
expect { action }.to raise_error(Mrkt::Errors::UnspecifiedAction)
|
221
221
|
end
|
222
222
|
end
|
223
223
|
end
|
224
224
|
|
225
225
|
describe '#delete_folder' do
|
226
|
-
subject { client.delete_folder(id) }
|
226
|
+
subject(:action) { client.delete_folder(id) }
|
227
227
|
|
228
228
|
let(:id) { 75 }
|
229
229
|
|
@@ -265,8 +265,8 @@ describe Mrkt::CrudAssetFolders do
|
|
265
265
|
}
|
266
266
|
end
|
267
267
|
|
268
|
-
it '
|
269
|
-
expect {
|
268
|
+
it 'raises an Error' do
|
269
|
+
expect { action }.to raise_error(Mrkt::Errors::RecordNotFound)
|
270
270
|
end
|
271
271
|
end
|
272
272
|
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
describe Mrkt::CrudAssetStaticLists do
|
2
|
-
include_context 'initialized client'
|
2
|
+
include_context 'with an initialized client'
|
3
3
|
|
4
4
|
let(:response_static_list_result) do
|
5
5
|
{
|
@@ -55,7 +55,7 @@ describe Mrkt::CrudAssetStaticLists do
|
|
55
55
|
end
|
56
56
|
|
57
57
|
describe '#get_static_list_by_id' do
|
58
|
-
subject { client.get_static_list_by_id(id) }
|
58
|
+
subject(:action) { client.get_static_list_by_id(id) }
|
59
59
|
|
60
60
|
let(:id) { response_static_list_result[:id] }
|
61
61
|
let(:response_stub) do
|
@@ -106,8 +106,8 @@ describe Mrkt::CrudAssetStaticLists do
|
|
106
106
|
}
|
107
107
|
end
|
108
108
|
|
109
|
-
it '
|
110
|
-
expect {
|
109
|
+
it 'raises an Error' do
|
110
|
+
expect { action }.to raise_error(Mrkt::Errors::RecordNotFound)
|
111
111
|
end
|
112
112
|
end
|
113
113
|
end
|
@@ -1,7 +1,9 @@
|
|
1
1
|
describe Mrkt::CrudCampaigns do
|
2
|
-
include_context 'initialized client'
|
2
|
+
include_context 'with an initialized client'
|
3
3
|
|
4
4
|
describe '#request_campaign' do
|
5
|
+
subject(:action) { client.request_campaign(id, lead_ids, tokens) }
|
6
|
+
|
5
7
|
let(:id) { 42 }
|
6
8
|
let(:lead_ids) { [1234, 5678] }
|
7
9
|
let(:tokens) do
|
@@ -13,7 +15,6 @@ describe Mrkt::CrudCampaigns do
|
|
13
15
|
value: 'Value for other token'
|
14
16
|
}]
|
15
17
|
end
|
16
|
-
subject { client.request_campaign(id, lead_ids, tokens) }
|
17
18
|
|
18
19
|
before do
|
19
20
|
stub_request(:post, "https://#{host}/rest/v1/campaigns/#{id}/trigger.json")
|
@@ -25,16 +26,16 @@ describe Mrkt::CrudCampaigns do
|
|
25
26
|
let(:response_stub) do
|
26
27
|
{
|
27
28
|
requestId: 'a9b#14eb6771358',
|
28
|
-
success:
|
29
|
-
errors:
|
30
|
-
|
31
|
-
|
32
|
-
|
29
|
+
success: false,
|
30
|
+
errors: [{
|
31
|
+
code: '1013',
|
32
|
+
message: 'Campaign not found'
|
33
|
+
}]
|
33
34
|
}
|
34
35
|
end
|
35
36
|
|
36
|
-
it '
|
37
|
-
expect {
|
37
|
+
it 'raises an Error' do
|
38
|
+
expect { action }.to raise_error(Mrkt::Errors::ObjectNotFound)
|
38
39
|
end
|
39
40
|
end
|
40
41
|
|
@@ -43,20 +44,20 @@ describe Mrkt::CrudCampaigns do
|
|
43
44
|
let(:response_stub) do
|
44
45
|
{
|
45
46
|
requestId: '7cdc#14eb6ae8a86',
|
46
|
-
success:
|
47
|
-
errors:
|
48
|
-
|
49
|
-
|
50
|
-
|
47
|
+
success: false,
|
48
|
+
errors: [{
|
49
|
+
code: '1004',
|
50
|
+
message: 'Lead [1234] not found'
|
51
|
+
}]
|
51
52
|
}
|
52
53
|
end
|
53
54
|
|
54
|
-
it '
|
55
|
-
expect {
|
55
|
+
it 'raises an Error' do
|
56
|
+
expect { action }.to raise_error(Mrkt::Errors::LeadNotFound)
|
56
57
|
end
|
57
58
|
end
|
58
59
|
|
59
|
-
context '
|
60
|
+
context 'with valid lead ids' do
|
60
61
|
let(:response_stub) do
|
61
62
|
{
|
62
63
|
requestId: 'e42b#14272d07d78',
|