mrkt 1.0.1 → 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 +19 -0
- data/.github/workflows/ruby.yml +41 -0
- data/.rubocop.yml +18 -36
- data/Gemfile.lock +71 -48
- data/README.md +1 -0
- data/lib/mrkt/concerns/crud_program_members.rb +31 -0
- data/lib/mrkt/errors.rb +20 -1
- data/lib/mrkt/version.rb +1 -1
- data/lib/mrkt.rb +2 -0
- data/mrkt.gemspec +9 -5
- 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 +47 -14
- data/.travis.yml +0 -21
@@ -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',
|
@@ -1,5 +1,5 @@
|
|
1
1
|
describe Mrkt::CrudCustomObjects do
|
2
|
-
include_context 'initialized client'
|
2
|
+
include_context 'with an initialized client'
|
3
3
|
|
4
4
|
describe '#get_list_of_custom_activity_types' do
|
5
5
|
let(:response_stub) do
|
@@ -49,14 +49,14 @@ describe Mrkt::CrudCustomObjects do
|
|
49
49
|
}
|
50
50
|
end
|
51
51
|
|
52
|
-
context 'all activities' do
|
52
|
+
context 'with all activities' do
|
53
|
+
subject { client.get_list_of_custom_activity_types }
|
54
|
+
|
53
55
|
before do
|
54
56
|
stub_request(:get, "https://#{host}/rest/v1/activities/types.json")
|
55
57
|
.to_return(json_stub(response_stub))
|
56
58
|
end
|
57
59
|
|
58
|
-
subject { client.get_list_of_custom_activity_types }
|
59
|
-
|
60
60
|
it { is_expected.to eq(response_stub) }
|
61
61
|
end
|
62
62
|
end
|
@@ -104,6 +104,8 @@ describe Mrkt::CrudCustomObjects do
|
|
104
104
|
end
|
105
105
|
|
106
106
|
context 'with no additional attributes' do
|
107
|
+
subject { client.create_custom_activity(lead_id, activity_type_id, primary_attribute_value, date: date) }
|
108
|
+
|
107
109
|
let(:request_body) do
|
108
110
|
{
|
109
111
|
input: [{
|
@@ -122,12 +124,14 @@ describe Mrkt::CrudCustomObjects do
|
|
122
124
|
.to_return(json_stub(response_stub))
|
123
125
|
end
|
124
126
|
|
125
|
-
subject { client.create_custom_activity(lead_id, activity_type_id, primary_attribute_value, date: date) }
|
126
|
-
|
127
127
|
it { is_expected.to eq(response_stub) }
|
128
128
|
end
|
129
129
|
|
130
130
|
context 'with additional attributes' do
|
131
|
+
subject do
|
132
|
+
client.create_custom_activity(lead_id, activity_type_id, primary_attribute_value, attributes: attributes, date: date)
|
133
|
+
end
|
134
|
+
|
131
135
|
let(:request_body) do
|
132
136
|
{
|
133
137
|
input: [{
|
@@ -148,13 +152,6 @@ describe Mrkt::CrudCustomObjects do
|
|
148
152
|
}]
|
149
153
|
}
|
150
154
|
end
|
151
|
-
|
152
|
-
before do
|
153
|
-
stub_request(:post, "https://#{host}/rest/v1/activities/external.json")
|
154
|
-
.with(json_stub(request_body))
|
155
|
-
.to_return(json_stub(response_stub))
|
156
|
-
end
|
157
|
-
|
158
155
|
let(:attributes) do
|
159
156
|
{
|
160
157
|
percent: '0.20',
|
@@ -162,8 +159,10 @@ describe Mrkt::CrudCustomObjects do
|
|
162
159
|
}
|
163
160
|
end
|
164
161
|
|
165
|
-
|
166
|
-
|
162
|
+
before do
|
163
|
+
stub_request(:post, "https://#{host}/rest/v1/activities/external.json")
|
164
|
+
.with(json_stub(request_body))
|
165
|
+
.to_return(json_stub(response_stub))
|
167
166
|
end
|
168
167
|
|
169
168
|
it { is_expected.to eq(response_stub) }
|
@@ -1,5 +1,5 @@
|
|
1
1
|
describe Mrkt::CrudCustomObjects do
|
2
|
-
include_context 'initialized client'
|
2
|
+
include_context 'with an initialized client'
|
3
3
|
|
4
4
|
describe '#get_list_of_custom_objects' do
|
5
5
|
let(:response_stub) do
|
@@ -44,17 +44,19 @@ describe Mrkt::CrudCustomObjects do
|
|
44
44
|
end
|
45
45
|
|
46
46
|
context 'with no object names' do
|
47
|
+
subject { client.get_list_of_custom_objects }
|
48
|
+
|
47
49
|
before do
|
48
50
|
stub_request(:get, "https://#{host}/rest/v1/customobjects.json")
|
49
51
|
.to_return(json_stub(response_stub))
|
50
52
|
end
|
51
53
|
|
52
|
-
subject { client.get_list_of_custom_objects }
|
53
|
-
|
54
54
|
it { is_expected.to eq(response_stub) }
|
55
55
|
end
|
56
56
|
|
57
57
|
context 'with object names' do
|
58
|
+
subject { client.get_list_of_custom_objects(object_names) }
|
59
|
+
|
58
60
|
let(:object_names) { %w[device_c manufacturer_c] }
|
59
61
|
|
60
62
|
before do
|
@@ -63,13 +65,13 @@ describe Mrkt::CrudCustomObjects do
|
|
63
65
|
.to_return(json_stub(response_stub))
|
64
66
|
end
|
65
67
|
|
66
|
-
subject { client.get_list_of_custom_objects(object_names) }
|
67
|
-
|
68
68
|
it { is_expected.to eq(response_stub) }
|
69
69
|
end
|
70
70
|
end
|
71
71
|
|
72
72
|
describe '#describe_custom_object' do
|
73
|
+
subject(:action) { client.describe_custom_object(object_name) }
|
74
|
+
|
73
75
|
let(:response_stub) do
|
74
76
|
{
|
75
77
|
requestId: 'eeef#152858b17d2',
|
@@ -129,8 +131,6 @@ describe Mrkt::CrudCustomObjects do
|
|
129
131
|
.to_return(json_stub(response_stub))
|
130
132
|
end
|
131
133
|
|
132
|
-
subject { client.describe_custom_object(object_name) }
|
133
|
-
|
134
134
|
context 'when the object name is valid' do
|
135
135
|
let(:object_name) { :device_c }
|
136
136
|
|
@@ -140,13 +140,15 @@ describe Mrkt::CrudCustomObjects do
|
|
140
140
|
context 'when the object name is invalid' do
|
141
141
|
let(:object_name) { nil }
|
142
142
|
|
143
|
-
it '
|
144
|
-
expect {
|
143
|
+
it 'raises an Error' do
|
144
|
+
expect { action }.to raise_error(Mrkt::Errors::Unknown)
|
145
145
|
end
|
146
146
|
end
|
147
147
|
end
|
148
148
|
|
149
149
|
describe '#createupdate_custom_objects' do
|
150
|
+
subject { client.createupdate_custom_objects(object_name, devices) }
|
151
|
+
|
150
152
|
let(:object_name) { 'device' }
|
151
153
|
|
152
154
|
let(:devices) do
|
@@ -178,8 +180,6 @@ describe Mrkt::CrudCustomObjects do
|
|
178
180
|
}
|
179
181
|
end
|
180
182
|
|
181
|
-
subject { client.createupdate_custom_objects(object_name, devices) }
|
182
|
-
|
183
183
|
before do
|
184
184
|
stub_request(:post, "https://#{host}/rest/v1/customobjects/#{object_name}.json")
|
185
185
|
.with(json_stub(request_body))
|
@@ -190,6 +190,8 @@ describe Mrkt::CrudCustomObjects do
|
|
190
190
|
end
|
191
191
|
|
192
192
|
describe '#delete_custom_objects' do
|
193
|
+
subject { client.delete_custom_objects(object_name, search_fields) }
|
194
|
+
|
193
195
|
let(:object_name) { 'device' }
|
194
196
|
|
195
197
|
let(:search_fields) do
|
@@ -215,8 +217,6 @@ describe Mrkt::CrudCustomObjects do
|
|
215
217
|
}
|
216
218
|
end
|
217
219
|
|
218
|
-
subject { client.delete_custom_objects(object_name, search_fields) }
|
219
|
-
|
220
220
|
before do
|
221
221
|
stub_request(:post, "https://#{host}/rest/v1/customobjects/#{object_name}/delete.json")
|
222
222
|
.with(json_stub(request_body))
|
@@ -227,6 +227,8 @@ describe Mrkt::CrudCustomObjects do
|
|
227
227
|
end
|
228
228
|
|
229
229
|
describe '#get_custom_objects' do
|
230
|
+
subject { client.get_custom_objects(object_name, filter_values) }
|
231
|
+
|
230
232
|
let(:object_name) { 'device' }
|
231
233
|
|
232
234
|
let(:filter_values) do
|
@@ -256,8 +258,6 @@ describe Mrkt::CrudCustomObjects do
|
|
256
258
|
}
|
257
259
|
end
|
258
260
|
|
259
|
-
subject { client.get_custom_objects(object_name, filter_values) }
|
260
|
-
|
261
261
|
before do
|
262
262
|
stub_request(:post, "https://#{host}/rest/v1/customobjects/#{object_name}.json?_method=GET")
|
263
263
|
.with(json_stub(request_body))
|
@@ -1,5 +1,5 @@
|
|
1
1
|
describe Mrkt::CrudLeads do
|
2
|
-
include_context 'initialized client'
|
2
|
+
include_context 'with an initialized client'
|
3
3
|
|
4
4
|
describe 'get_lead_by_id' do
|
5
5
|
subject { client.get_lead_by_id(id, fields: fields) }
|
@@ -56,6 +56,8 @@ describe Mrkt::CrudLeads do
|
|
56
56
|
end
|
57
57
|
|
58
58
|
describe '#get_leads' do
|
59
|
+
subject { client.get_leads(filter_type, filter_values) }
|
60
|
+
|
59
61
|
let(:filter_type) { 'email' }
|
60
62
|
let(:filter_values) { %w[user@example.com] }
|
61
63
|
let(:response_stub) do
|
@@ -74,7 +76,6 @@ describe Mrkt::CrudLeads do
|
|
74
76
|
success: true
|
75
77
|
}
|
76
78
|
end
|
77
|
-
subject { client.get_leads(filter_type, filter_values) }
|
78
79
|
|
79
80
|
before do
|
80
81
|
stub_request(:get, "https://#{host}/rest/v1/leads.json")
|
@@ -86,6 +87,8 @@ describe Mrkt::CrudLeads do
|
|
86
87
|
end
|
87
88
|
|
88
89
|
describe '#createupdate_leads' do
|
90
|
+
subject { client.createupdate_leads(leads, lookup_field: :email) }
|
91
|
+
|
89
92
|
let(:leads) do
|
90
93
|
[
|
91
94
|
firstName: 'John',
|
@@ -118,7 +121,6 @@ describe Mrkt::CrudLeads do
|
|
118
121
|
]
|
119
122
|
}
|
120
123
|
end
|
121
|
-
subject { client.createupdate_leads(leads, lookup_field: :email) }
|
122
124
|
|
123
125
|
before do
|
124
126
|
stub_request(:post, "https://#{host}/rest/v1/leads.json")
|
@@ -130,6 +132,8 @@ describe Mrkt::CrudLeads do
|
|
130
132
|
end
|
131
133
|
|
132
134
|
describe '#delete_leads' do
|
135
|
+
subject { client.delete_leads(leads) }
|
136
|
+
|
133
137
|
let(:leads) { [1] }
|
134
138
|
let(:request_body) do
|
135
139
|
{
|
@@ -147,7 +151,6 @@ describe Mrkt::CrudLeads do
|
|
147
151
|
success: true
|
148
152
|
}
|
149
153
|
end
|
150
|
-
subject { client.delete_leads(leads) }
|
151
154
|
|
152
155
|
before do
|
153
156
|
stub_request(:delete, "https://#{host}/rest/v1/leads.json")
|
@@ -159,12 +162,12 @@ describe Mrkt::CrudLeads do
|
|
159
162
|
end
|
160
163
|
|
161
164
|
describe '#associate_lead' do
|
165
|
+
subject(:action) { client.associate_lead(id, cookie) }
|
166
|
+
|
162
167
|
let(:id) { 1 }
|
163
168
|
let(:cookie) { 'id:561-HYG-937&token:_mch-marketo.com-1427205775289-40768' }
|
164
169
|
let(:request_stub) { {} }
|
165
170
|
|
166
|
-
subject { client.associate_lead(id, cookie) }
|
167
|
-
|
168
171
|
before do
|
169
172
|
stub_request(:post, "https://#{host}/rest/v1/leads/#{id}/associate.json?#{URI.encode_www_form(cookie: cookie)}")
|
170
173
|
.with(json_stub(request_stub))
|
@@ -197,19 +200,19 @@ describe Mrkt::CrudLeads do
|
|
197
200
|
}
|
198
201
|
end
|
199
202
|
|
200
|
-
it '
|
201
|
-
expect {
|
203
|
+
it 'raises an Error' do
|
204
|
+
expect { action }.to raise_error(Mrkt::Errors::LeadNotFound)
|
202
205
|
end
|
203
206
|
end
|
204
207
|
end
|
205
208
|
|
206
209
|
describe '#merge_leads' do
|
210
|
+
subject(:action) { client.merge_leads(id, losing_lead_ids) }
|
211
|
+
|
207
212
|
let(:id) { 1 }
|
208
213
|
let(:losing_lead_ids) { [2, 3, 4] }
|
209
214
|
let(:request_stub) { {} }
|
210
215
|
|
211
|
-
subject { client.merge_leads(id, losing_lead_ids) }
|
212
|
-
|
213
216
|
before do
|
214
217
|
params = ::Faraday::Utils::ParamsHash.new
|
215
218
|
params[:mergeInCRM] = false
|
@@ -245,13 +248,15 @@ describe Mrkt::CrudLeads do
|
|
245
248
|
}
|
246
249
|
end
|
247
250
|
|
248
|
-
it '
|
249
|
-
expect {
|
251
|
+
it 'raises an Error' do
|
252
|
+
expect { action }.to raise_error(Mrkt::Errors::LeadNotFound)
|
250
253
|
end
|
251
254
|
end
|
252
255
|
end
|
253
256
|
|
254
257
|
describe '#describe_lead' do
|
258
|
+
subject { client.describe_lead }
|
259
|
+
|
255
260
|
let(:response_stub) do
|
256
261
|
{
|
257
262
|
requestId: '5c9e#169a68fa806',
|
@@ -289,8 +294,6 @@ describe Mrkt::CrudLeads do
|
|
289
294
|
}
|
290
295
|
end
|
291
296
|
|
292
|
-
subject { client.describe_lead }
|
293
|
-
|
294
297
|
before do
|
295
298
|
stub_request(:get, "https://#{host}/rest/v1/leads/describe.json")
|
296
299
|
.to_return(json_stub(response_stub))
|
@@ -1,7 +1,9 @@
|
|
1
1
|
describe Mrkt::CrudLists do
|
2
|
-
include_context 'initialized client'
|
2
|
+
include_context 'with an initialized client'
|
3
3
|
|
4
4
|
describe '#get_leads_by_list' do
|
5
|
+
subject { client.get_leads_by_list(list_id) }
|
6
|
+
|
5
7
|
let(:list_id) { '1001' }
|
6
8
|
let(:response_stub) do
|
7
9
|
{
|
@@ -20,8 +22,6 @@ describe Mrkt::CrudLists do
|
|
20
22
|
}
|
21
23
|
end
|
22
24
|
|
23
|
-
subject { client.get_leads_by_list(list_id) }
|
24
|
-
|
25
25
|
before do
|
26
26
|
stub_request(:get, "https://#{host}/rest/v1/list/#{list_id}/leads.json")
|
27
27
|
.with(query: {})
|
@@ -32,6 +32,8 @@ describe Mrkt::CrudLists do
|
|
32
32
|
end
|
33
33
|
|
34
34
|
describe '#add_leads_to_list' do
|
35
|
+
subject { client.add_leads_to_list(list_id, lead_ids) }
|
36
|
+
|
35
37
|
let(:list_id) { '1001' }
|
36
38
|
let(:lead_ids) { ['1'] }
|
37
39
|
let(:request_body) do
|
@@ -53,7 +55,6 @@ describe Mrkt::CrudLists do
|
|
53
55
|
success: true
|
54
56
|
}
|
55
57
|
end
|
56
|
-
subject { client.add_leads_to_list(list_id, lead_ids) }
|
57
58
|
|
58
59
|
before do
|
59
60
|
stub_request(:post, "https://#{host}/rest/v1/lists/#{list_id}/leads.json")
|
@@ -65,6 +66,8 @@ describe Mrkt::CrudLists do
|
|
65
66
|
end
|
66
67
|
|
67
68
|
describe '#remove_leads_from_list' do
|
69
|
+
subject { client.remove_leads_from_list(list_id, lead_ids) }
|
70
|
+
|
68
71
|
let(:list_id) { '1001' }
|
69
72
|
let(:lead_ids) { ['1'] }
|
70
73
|
let(:request_body) do
|
@@ -86,7 +89,6 @@ describe Mrkt::CrudLists do
|
|
86
89
|
success: true
|
87
90
|
}
|
88
91
|
end
|
89
|
-
subject { client.remove_leads_from_list(list_id, lead_ids) }
|
90
92
|
|
91
93
|
before do
|
92
94
|
stub_request(:delete, "https://#{host}/rest/v1/lists/#{list_id}/leads.json")
|