mrkt 0.9.0 → 0.10.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,183 @@
1
+ describe Mrkt::CrudAssetStaticLists do
2
+ include_context 'initialized client'
3
+
4
+ let(:response_static_list_result) do
5
+ {
6
+ id: 1001,
7
+ name: 'Test Static List Name',
8
+ description: 'Provided description',
9
+ createdAt: '2019-03-15T21:41:46Z+0000',
10
+ updatedAt: '2019-03-15T21:41:46Z+0000',
11
+ folder: {
12
+ id: 14,
13
+ type: 'Folder'
14
+ },
15
+ computedUrl: 'https://app-devlocal1.marketo.com/#ST1001A1'
16
+ }
17
+ end
18
+
19
+ describe '#create_static_list' do
20
+ subject { client.create_static_list(name, folder, description: description) }
21
+
22
+ let(:name) { 'Test Static List Name' }
23
+ let(:folder) do
24
+ { id: 14, type: 'Folder' }
25
+ end
26
+ let(:description) { 'Provided description' }
27
+ let(:response_stub) do
28
+ {
29
+ requestId: 'eba#16982091b99',
30
+ result: [
31
+ response_static_list_result
32
+ ],
33
+ success: true,
34
+ errors: [],
35
+ warnings: []
36
+ }
37
+ end
38
+
39
+ let(:json_folder) { JSON.generate(folder) }
40
+ let(:request_body) do
41
+ {
42
+ name: name,
43
+ folder: json_folder,
44
+ description: description
45
+ }
46
+ end
47
+
48
+ before do
49
+ stub_request(:post, "https://#{host}/rest/asset/v1/staticLists.json")
50
+ .with(body: request_body)
51
+ .to_return(json_stub(response_stub))
52
+ end
53
+
54
+ it { is_expected.to eq(response_stub) }
55
+ end
56
+
57
+ describe '#get_static_list_by_id' do
58
+ subject { client.get_static_list_by_id(id) }
59
+
60
+ let(:id) { response_static_list_result[:id] }
61
+ let(:response_stub) do
62
+ {
63
+ requestId: '378a#16983419fff',
64
+ result: [
65
+ response_static_list_result
66
+ ],
67
+ success: true,
68
+ errors: [],
69
+ warnings: []
70
+ }
71
+ end
72
+
73
+ before do
74
+ stub_request(:get, "https://#{host}/rest/asset/v1/staticList/#{id}.json")
75
+ .to_return(json_stub(response_stub))
76
+ end
77
+
78
+ context 'when a static list with the given id exists' do
79
+ let(:response_stub) do
80
+ {
81
+ requestId: '378a#16983419fff',
82
+ result: [
83
+ response_static_list_result
84
+ ],
85
+ success: true,
86
+ errors: [],
87
+ warnings: []
88
+ }
89
+ end
90
+
91
+ it { is_expected.to eq(response_stub) }
92
+ end
93
+
94
+ context 'when a static list with the given id does not exist' do
95
+ let(:response_stub) do
96
+ {
97
+ requestId: 'a8d#1698369857b',
98
+ success: false,
99
+ warnings: [],
100
+ errors: [
101
+ {
102
+ code: '702',
103
+ message: 'Static List not found or it has been deleted'
104
+ }
105
+ ]
106
+ }
107
+ end
108
+
109
+ it 'should raise an Error' do
110
+ expect { subject }.to raise_error(Mrkt::Errors::RecordNotFound)
111
+ end
112
+ end
113
+ end
114
+
115
+ describe '#get_static_list_by_name' do
116
+ subject { client.get_static_list_by_name(name) }
117
+
118
+ let(:name) { 'Test Static List Name' }
119
+ let(:request_query) { "name=#{name}" }
120
+
121
+ before do
122
+ stub_request(:get, "https://#{host}/rest/asset/v1/staticList/byName.json?#{request_query}")
123
+ .to_return(json_stub(response_stub))
124
+ end
125
+
126
+ context 'when a static list with the given name exists' do
127
+ let(:response_stub) do
128
+ {
129
+ requestId: '13a74#169834522b9',
130
+ result: [
131
+ response_static_list_result
132
+ ],
133
+ success: true,
134
+ errors: [],
135
+ warnings: []
136
+ }
137
+ end
138
+
139
+ it { is_expected.to eq(response_stub) }
140
+ end
141
+
142
+ context 'when a static list with the given name does not exist' do
143
+ let(:response_stub) do
144
+ {
145
+ requestId: '4ec2#1698384ae02',
146
+ success: true,
147
+ errors: [],
148
+ warnings: [
149
+ 'No assets found for the given search criteria.'
150
+ ]
151
+ }
152
+ end
153
+
154
+ it { is_expected.to eq(response_stub) }
155
+ end
156
+ end
157
+
158
+ describe '#delete_static_list' do
159
+ subject { client.delete_static_list(id) }
160
+
161
+ let(:id) { 1001 }
162
+ let(:response_stub) do
163
+ {
164
+ requestId: '94c3#169833275df',
165
+ result: [
166
+ {
167
+ id: 1001
168
+ }
169
+ ],
170
+ success: true,
171
+ errors: [],
172
+ warnings: []
173
+ }
174
+ end
175
+
176
+ before do
177
+ stub_request(:post, "https://#{host}/rest/asset/v1/staticList/#{id}/delete.json")
178
+ .to_return(json_stub(response_stub))
179
+ end
180
+
181
+ it { is_expected.to eq(response_stub) }
182
+ end
183
+ end
@@ -162,7 +162,9 @@ describe Mrkt::CrudCustomObjects do
162
162
  }
163
163
  end
164
164
 
165
- subject { client.create_custom_activity(lead_id, activity_type_id, primary_attribute_value, attributes: attributes, date: date) }
165
+ subject do
166
+ client.create_custom_activity(lead_id, activity_type_id, primary_attribute_value, attributes: attributes, date: date)
167
+ end
166
168
 
167
169
  it { is_expected.to eq(response_stub) }
168
170
  end
@@ -55,7 +55,7 @@ describe Mrkt::CrudCustomObjects do
55
55
  end
56
56
 
57
57
  context 'with object names' do
58
- let(:object_names) { %w(device_c manufacturer_c) }
58
+ let(:object_names) { %w[device_c manufacturer_c] }
59
59
 
60
60
  before do
61
61
  stub_request(:get, "https://#{host}/rest/v1/customobjects.json")
@@ -1,9 +1,63 @@
1
1
  describe Mrkt::CrudLeads do
2
2
  include_context 'initialized client'
3
3
 
4
+ describe 'get_lead_by_id' do
5
+ subject { client.get_lead_by_id(id, fields: fields) }
6
+
7
+ let(:id) { 200 }
8
+
9
+ let(:fields_query) { fields ? "fields=#{fields.join(',')}" : nil }
10
+
11
+ before do
12
+ stub_request(:get, "https://#{host}/rest/v1/lead/#{id}.json?#{fields_query}")
13
+ .to_return(json_stub(response_stub))
14
+ end
15
+
16
+ context 'when no fields are given' do
17
+ let(:fields) { nil }
18
+ let(:response_stub) do
19
+ {
20
+ requestId: '1134#169a69aae86',
21
+ result: [
22
+ {
23
+ id: id,
24
+ firstName: 'John',
25
+ lastName: 'Snow',
26
+ email: 'jfrost@mrkt.com',
27
+ updatedAt: '2019-03-19T20:39:23Z',
28
+ createdAt: '2019-03-14T13:41:37Z'
29
+ }
30
+ ],
31
+ success: true
32
+ }
33
+ end
34
+
35
+ it { is_expected.to eq(response_stub) }
36
+ end
37
+
38
+ context 'when an array of fields is given' do
39
+ let(:fields) { %w[email dateOfBirth] }
40
+ let(:response_stub) do
41
+ {
42
+ requestId: '33dd#169a6b5ba65',
43
+ result: [
44
+ {
45
+ id: id,
46
+ email: 'jfrost@mrkt.com',
47
+ dateOfBirth: '1813-03-15'
48
+ }
49
+ ],
50
+ success: true
51
+ }
52
+ end
53
+
54
+ it { is_expected.to eq(response_stub) }
55
+ end
56
+ end
57
+
4
58
  describe '#get_leads' do
5
59
  let(:filter_type) { 'email' }
6
- let(:filter_values) { %w(user@example.com) }
60
+ let(:filter_values) { %w[user@example.com] }
7
61
  let(:response_stub) do
8
62
  {
9
63
  requestId: 'c245#14cd6830ae2',
@@ -196,4 +250,52 @@ describe Mrkt::CrudLeads do
196
250
  end
197
251
  end
198
252
  end
253
+
254
+ describe '#describe_lead' do
255
+ let(:response_stub) do
256
+ {
257
+ requestId: '5c9e#169a68fa806',
258
+ result: [
259
+ {
260
+ id: 4,
261
+ displayName: 'Company Name',
262
+ dataType: 'string',
263
+ length: 255,
264
+ rest: {
265
+ name: 'company',
266
+ readOnly: false
267
+ },
268
+ soap: {
269
+ name: 'Company',
270
+ readOnly: false
271
+ }
272
+ },
273
+ {
274
+ id: 56,
275
+ displayName: 'Email Address',
276
+ dataType: 'email',
277
+ length: 255,
278
+ rest: {
279
+ name: 'email',
280
+ readOnly: false
281
+ },
282
+ soap: {
283
+ name: 'Email',
284
+ readOnly: false
285
+ }
286
+ }
287
+ ],
288
+ success: true
289
+ }
290
+ end
291
+
292
+ subject { client.describe_lead }
293
+
294
+ before do
295
+ stub_request(:get, "https://#{host}/rest/v1/leads/describe.json")
296
+ .to_return(json_stub(response_stub))
297
+ end
298
+
299
+ it { is_expected.to eq(response_stub) }
300
+ end
199
301
  end
@@ -63,4 +63,37 @@ describe Mrkt::CrudLists do
63
63
 
64
64
  it { is_expected.to eq(response_stub) }
65
65
  end
66
+
67
+ describe '#remove_leads_from_list' do
68
+ let(:list_id) { '1001' }
69
+ let(:lead_ids) { ['1'] }
70
+ let(:request_body) do
71
+ {
72
+ input: [
73
+ { id: '1' }
74
+ ]
75
+ }
76
+ end
77
+ let(:response_stub) do
78
+ {
79
+ requestId: '10de4#1697e81c821',
80
+ result: [
81
+ {
82
+ id: 1,
83
+ status: 'removed'
84
+ }
85
+ ],
86
+ success: true
87
+ }
88
+ end
89
+ subject { client.remove_leads_from_list(list_id, lead_ids) }
90
+
91
+ before do
92
+ stub_request(:delete, "https://#{host}/rest/v1/lists/#{list_id}/leads.json")
93
+ .with(json_stub(request_body))
94
+ .to_return(json_stub(response_stub))
95
+ end
96
+
97
+ it { is_expected.to eq(response_stub) }
98
+ end
66
99
  end
@@ -22,8 +22,8 @@ describe Mrkt::ImportLeads do
22
22
 
23
23
  before do
24
24
  CSV.open(tempfile, 'wb') do |csv|
25
- csv << %w(email firstName lastName)
26
- csv << %w(sample@example.com John Snow)
25
+ csv << %w[email firstName lastName]
26
+ csv << %w[sample@example.com John Snow]
27
27
  end
28
28
 
29
29
  stub_request(:post, "https://#{host}/bulk/v1/leads.json")
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mrkt
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 0.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - KARASZI István
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2017-12-19 00:00:00.000000000 Z
12
+ date: 2019-03-23 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: faraday
@@ -20,7 +20,7 @@ dependencies:
20
20
  version: 0.9.0
21
21
  - - "<"
22
22
  - !ruby/object:Gem::Version
23
- version: 0.14.0
23
+ version: 0.16.0
24
24
  type: :runtime
25
25
  prerelease: false
26
26
  version_requirements: !ruby/object:Gem::Requirement
@@ -30,7 +30,7 @@ dependencies:
30
30
  version: 0.9.0
31
31
  - - "<"
32
32
  - !ruby/object:Gem::Version
33
- version: 0.14.0
33
+ version: 0.16.0
34
34
  - !ruby/object:Gem::Dependency
35
35
  name: faraday_middleware
36
36
  requirement: !ruby/object:Gem::Requirement
@@ -40,7 +40,7 @@ dependencies:
40
40
  version: 0.9.0
41
41
  - - "<"
42
42
  - !ruby/object:Gem::Version
43
- version: 0.13.0
43
+ version: 0.16.0
44
44
  type: :runtime
45
45
  prerelease: false
46
46
  version_requirements: !ruby/object:Gem::Requirement
@@ -50,7 +50,7 @@ dependencies:
50
50
  version: 0.9.0
51
51
  - - "<"
52
52
  - !ruby/object:Gem::Version
53
- version: 0.13.0
53
+ version: 0.16.0
54
54
  - !ruby/object:Gem::Dependency
55
55
  name: bundler
56
56
  requirement: !ruby/object:Gem::Requirement
@@ -66,103 +66,89 @@ dependencies:
66
66
  - !ruby/object:Gem::Version
67
67
  version: '1.3'
68
68
  - !ruby/object:Gem::Dependency
69
- name: rake
69
+ name: codeclimate-test-reporter
70
70
  requirement: !ruby/object:Gem::Requirement
71
71
  requirements:
72
72
  - - "~>"
73
73
  - !ruby/object:Gem::Version
74
- version: '10.0'
74
+ version: '1.0'
75
75
  type: :development
76
76
  prerelease: false
77
77
  version_requirements: !ruby/object:Gem::Requirement
78
78
  requirements:
79
79
  - - "~>"
80
80
  - !ruby/object:Gem::Version
81
- version: '10.0'
81
+ version: '1.0'
82
82
  - !ruby/object:Gem::Dependency
83
- name: rspec
84
- requirement: !ruby/object:Gem::Requirement
85
- requirements:
86
- - - "~>"
87
- - !ruby/object:Gem::Version
88
- version: '3.2'
89
- type: :development
90
- prerelease: false
91
- version_requirements: !ruby/object:Gem::Requirement
92
- requirements:
93
- - - "~>"
94
- - !ruby/object:Gem::Version
95
- version: '3.2'
96
- - !ruby/object:Gem::Dependency
97
- name: webmock
83
+ name: pry-byebug
98
84
  requirement: !ruby/object:Gem::Requirement
99
85
  requirements:
100
86
  - - "~>"
101
87
  - !ruby/object:Gem::Version
102
- version: 1.21.0
88
+ version: '3.7'
103
89
  type: :development
104
90
  prerelease: false
105
91
  version_requirements: !ruby/object:Gem::Requirement
106
92
  requirements:
107
93
  - - "~>"
108
94
  - !ruby/object:Gem::Version
109
- version: 1.21.0
95
+ version: '3.7'
110
96
  - !ruby/object:Gem::Dependency
111
- name: simplecov
97
+ name: rake
112
98
  requirement: !ruby/object:Gem::Requirement
113
99
  requirements:
114
100
  - - "~>"
115
101
  - !ruby/object:Gem::Version
116
- version: 0.14.1
102
+ version: '12.3'
117
103
  type: :development
118
104
  prerelease: false
119
105
  version_requirements: !ruby/object:Gem::Requirement
120
106
  requirements:
121
107
  - - "~>"
122
108
  - !ruby/object:Gem::Version
123
- version: 0.14.1
109
+ version: '12.3'
124
110
  - !ruby/object:Gem::Dependency
125
- name: pry-byebug
111
+ name: rspec
126
112
  requirement: !ruby/object:Gem::Requirement
127
113
  requirements:
128
114
  - - "~>"
129
115
  - !ruby/object:Gem::Version
130
- version: 3.4.0
116
+ version: '3.2'
131
117
  type: :development
132
118
  prerelease: false
133
119
  version_requirements: !ruby/object:Gem::Requirement
134
120
  requirements:
135
121
  - - "~>"
136
122
  - !ruby/object:Gem::Version
137
- version: 3.4.0
123
+ version: '3.2'
138
124
  - !ruby/object:Gem::Dependency
139
- name: codeclimate-test-reporter
125
+ name: rubocop
140
126
  requirement: !ruby/object:Gem::Requirement
141
127
  requirements:
142
128
  - - "~>"
143
129
  - !ruby/object:Gem::Version
144
- version: 1.0.0
130
+ version: 0.66.0
145
131
  type: :development
146
132
  prerelease: false
147
133
  version_requirements: !ruby/object:Gem::Requirement
148
134
  requirements:
149
135
  - - "~>"
150
136
  - !ruby/object:Gem::Version
151
- version: 1.0.0
137
+ version: 0.66.0
152
138
  - !ruby/object:Gem::Dependency
153
- name: rubocop
139
+ name: webmock
154
140
  requirement: !ruby/object:Gem::Requirement
155
141
  requirements:
156
142
  - - "~>"
157
143
  - !ruby/object:Gem::Version
158
- version: 0.45.0
144
+ version: '3.1'
159
145
  type: :development
160
146
  prerelease: false
161
147
  version_requirements: !ruby/object:Gem::Requirement
162
148
  requirements:
163
149
  - - "~>"
164
150
  - !ruby/object:Gem::Version
165
- version: 0.45.0
151
+ version: '3.1'
166
152
  description: This gem helps you to use the Marketo REST API
167
153
  email:
168
154
  - github@spam.raszi.hu
@@ -177,6 +163,7 @@ files:
177
163
  - ".travis.yml"
178
164
  - Gemfile
179
165
  - Gemfile.lock
166
+ - LICENSE
180
167
  - LICENSE.txt
181
168
  - README.md
182
169
  - Rakefile
@@ -184,6 +171,8 @@ files:
184
171
  - lib/mrkt/concerns/authentication.rb
185
172
  - lib/mrkt/concerns/connection.rb
186
173
  - lib/mrkt/concerns/crud_activities.rb
174
+ - lib/mrkt/concerns/crud_asset_folders.rb
175
+ - lib/mrkt/concerns/crud_asset_static_lists.rb
187
176
  - lib/mrkt/concerns/crud_campaigns.rb
188
177
  - lib/mrkt/concerns/crud_custom_activities.rb
189
178
  - lib/mrkt/concerns/crud_custom_objects.rb
@@ -200,6 +189,8 @@ files:
200
189
  - mrkt.gemspec
201
190
  - spec/concerns/authentication_spec.rb
202
191
  - spec/concerns/crud_activities_spec.rb
192
+ - spec/concerns/crud_asset_folders_spec.rb
193
+ - spec/concerns/crud_asset_static_lists_spec.rb
203
194
  - spec/concerns/crud_campaigns_spec.rb
204
195
  - spec/concerns/crud_custom_activities_spec.rb
205
196
  - spec/concerns/crud_custom_objects_spec.rb
@@ -225,21 +216,22 @@ required_ruby_version: !ruby/object:Gem::Requirement
225
216
  requirements:
226
217
  - - "~>"
227
218
  - !ruby/object:Gem::Version
228
- version: '2.0'
219
+ version: '2.3'
229
220
  required_rubygems_version: !ruby/object:Gem::Requirement
230
221
  requirements:
231
222
  - - ">="
232
223
  - !ruby/object:Gem::Version
233
224
  version: '0'
234
225
  requirements: []
235
- rubyforge_project:
236
- rubygems_version: 2.6.12
226
+ rubygems_version: 3.0.3
237
227
  signing_key:
238
228
  specification_version: 4
239
229
  summary: Marketo REST API Facade
240
230
  test_files:
241
231
  - spec/concerns/authentication_spec.rb
242
232
  - spec/concerns/crud_activities_spec.rb
233
+ - spec/concerns/crud_asset_folders_spec.rb
234
+ - spec/concerns/crud_asset_static_lists_spec.rb
243
235
  - spec/concerns/crud_campaigns_spec.rb
244
236
  - spec/concerns/crud_custom_activities_spec.rb
245
237
  - spec/concerns/crud_custom_objects_spec.rb