mrkt 1.0.1 → 1.2.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,141 @@
1
+ describe Mrkt::CrudProgramMembers do
2
+ include_context 'with an initialized client'
3
+
4
+ describe '#describe_program_members' do
5
+ subject { client.describe_program_members }
6
+
7
+ let(:response_stub) do
8
+ {
9
+ requestId: 'c245#14cd6830ae2',
10
+ result: [
11
+ {
12
+ name: 'API Program Membership',
13
+ description: 'Map for API program membership fields',
14
+ dedupeFields: %w[
15
+ leadId
16
+ programId
17
+ ],
18
+ searchableFields: [
19
+ ['leadId'],
20
+ ['livestormregistrationurl']
21
+ ],
22
+ fields: [
23
+ {
24
+ name: 'acquiredBy',
25
+ displayName: 'acquiredBy',
26
+ dataType: 'boolean',
27
+ updateable: false,
28
+ crmManaged: false
29
+ },
30
+ {
31
+ name: 'attendanceLikelihood',
32
+ displayName: 'attendanceLikelihood',
33
+ dataType: 'integer',
34
+ updateable: false,
35
+ crmManaged: false
36
+ }
37
+ ]
38
+ }
39
+ ],
40
+ success: true
41
+ }
42
+ end
43
+
44
+ before do
45
+ stub_request(:get, "https://#{host}/rest/v1/programs/members/describe.json")
46
+ .to_return(json_stub(response_stub))
47
+ end
48
+
49
+ it { is_expected.to eq(response_stub) }
50
+ end
51
+
52
+ describe '#createupdate_program_members' do
53
+ subject { client.createupdate_program_members(program_id, lead_ids, status) }
54
+
55
+ let(:program_id) { 123 }
56
+ let(:lead_ids) { [1, 2, 3] }
57
+ let(:status) { 'Registered' }
58
+ let(:request_body) do
59
+ {
60
+ statusName: 'Registered',
61
+ input: [
62
+ { leadId: 1 },
63
+ { leadId: 2 },
64
+ { leadId: 3 }
65
+ ]
66
+ }
67
+ end
68
+ let(:response_stub) do
69
+ {
70
+ requestId: 'c00c#17d7bf40f15',
71
+ result: [
72
+ {
73
+ seq: 0,
74
+ status: 'created',
75
+ leadId: 1
76
+ },
77
+ {
78
+ seq: 1,
79
+ status: 'created',
80
+ leadId: 2
81
+ },
82
+ {
83
+ seq: 2,
84
+ status: 'created',
85
+ leadId: 3
86
+ }
87
+ ],
88
+ success: true
89
+ }
90
+ end
91
+
92
+ before do
93
+ stub_request(:post, "https://#{host}/rest/v1/programs/#{program_id}/members/status.json")
94
+ .with(json_stub(request_body))
95
+ .to_return(json_stub(response_stub))
96
+ end
97
+
98
+ it { is_expected.to eq(response_stub) }
99
+ end
100
+
101
+ describe '#get_program_members' do
102
+ subject { client.get_program_members(program_id, filter_type, filter_values) }
103
+
104
+ let(:filter_type) { 'leadId' }
105
+ let(:filter_values) { [1, 2] }
106
+ let(:program_id) { 1014 }
107
+ let(:response_stub) do
108
+ {
109
+ requestId: '4b6d#17d7c0530de',
110
+ result: [
111
+ {
112
+ seq: 0,
113
+ leadId: 1,
114
+ reachedSuccess: true,
115
+ programId: 1014,
116
+ acquiredBy: false,
117
+ membershipDate: '2021-12-02T16:22:12Z'
118
+ },
119
+ {
120
+ seq: 1,
121
+ leadId: 2,
122
+ reachedSuccess: true,
123
+ programId: 1014,
124
+ acquiredBy: false,
125
+ membershipDate: '2021-12-02T16:22:12Z'
126
+ }
127
+ ],
128
+ success: true,
129
+ moreResult: false
130
+ }
131
+ end
132
+
133
+ before do
134
+ stub_request(:get, "https://#{host}/rest/v1/programs/#{program_id}/members.json")
135
+ .with(query: { filterType: filter_type, filterValues: filter_values.join(',') })
136
+ .to_return(json_stub(response_stub))
137
+ end
138
+
139
+ it { is_expected.to eq(response_stub) }
140
+ end
141
+ end
@@ -1,7 +1,9 @@
1
1
  describe Mrkt::CrudPrograms do
2
- include_context 'initialized client'
2
+ include_context 'with an initialized client'
3
3
 
4
4
  describe '#browse_programs' do
5
+ subject { client.browse_programs }
6
+
5
7
  let(:response_stub) do
6
8
  {
7
9
  success: true,
@@ -30,8 +32,6 @@ describe Mrkt::CrudPrograms do
30
32
  }
31
33
  end
32
34
 
33
- subject { client.browse_programs }
34
-
35
35
  before do
36
36
  stub_request(:get, "https://#{host}/rest/asset/v1/programs.json")
37
37
  .to_return(json_stub(response_stub))
@@ -41,6 +41,8 @@ describe Mrkt::CrudPrograms do
41
41
  end
42
42
 
43
43
  describe '#get_program_by_id' do
44
+ subject { client.get_program_by_id(1107) }
45
+
44
46
  let(:response_stub) do
45
47
  {
46
48
  success: true,
@@ -76,8 +78,6 @@ describe Mrkt::CrudPrograms do
76
78
  }
77
79
  end
78
80
 
79
- subject { client.get_program_by_id(1107) }
80
-
81
81
  before do
82
82
  stub_request(:get, "https://#{host}/rest/asset/v1/program/1107.json")
83
83
  .to_return(json_stub(response_stub))
@@ -1,10 +1,12 @@
1
1
  require 'tempfile'
2
2
 
3
3
  describe Mrkt::ImportCustomObjects do
4
- include_context 'initialized client'
4
+ include_context 'with an initialized client'
5
5
  let(:custom_object) { 'car_c' }
6
6
 
7
7
  describe '#import_custom_object' do
8
+ subject { client.import_custom_object(file, custom_object) }
9
+
8
10
  let(:file) { StringIO.new }
9
11
  let(:response_stub) do
10
12
  {
@@ -19,7 +21,6 @@ describe Mrkt::ImportCustomObjects do
19
21
  ]
20
22
  }
21
23
  end
22
- subject { client.import_custom_object(file, custom_object) }
23
24
 
24
25
  before do
25
26
  stub_request(:post, "https://#{host}/bulk/v1/customobjects/#{custom_object}/import.json")
@@ -31,6 +32,8 @@ describe Mrkt::ImportCustomObjects do
31
32
  end
32
33
 
33
34
  describe '#import_custom_object_status' do
35
+ subject { client.import_custom_object_status(1, custom_object) }
36
+
34
37
  let(:id) { 1 }
35
38
  let(:response_stub) do
36
39
  {
@@ -51,7 +54,6 @@ describe Mrkt::ImportCustomObjects do
51
54
  success: true
52
55
  }
53
56
  end
54
- subject { client.import_custom_object_status(1, custom_object) }
55
57
 
56
58
  before do
57
59
  stub_request(:get, "https://#{host}/bulk/v1/customobjects/#{custom_object}/import/#{id}/status.json")
@@ -62,9 +64,10 @@ describe Mrkt::ImportCustomObjects do
62
64
  end
63
65
 
64
66
  describe '#import_custom_object_failures' do
67
+ subject { client.import_custom_object_failures(1, custom_object) }
68
+
65
69
  let(:id) { 1 }
66
70
  let(:response_stub) { '' }
67
- subject { client.import_custom_object_failures(1, custom_object) }
68
71
 
69
72
  before do
70
73
  stub_request(:get, "https://#{host}/bulk/v1/customobjects/#{custom_object}/import/#{id}/failures.json")
@@ -75,9 +78,10 @@ describe Mrkt::ImportCustomObjects do
75
78
  end
76
79
 
77
80
  describe '#import_custom_object_warnings' do
81
+ subject { client.import_custom_object_warnings(1, custom_object) }
82
+
78
83
  let(:id) { 1 }
79
84
  let(:response_stub) { '' }
80
- subject { client.import_custom_object_warnings(1, custom_object) }
81
85
 
82
86
  before do
83
87
  stub_request(:get, "https://#{host}/bulk/v1/customobjects/#{custom_object}/import/#{id}/warnings.json")
@@ -2,9 +2,11 @@ require 'csv'
2
2
  require 'tempfile'
3
3
 
4
4
  describe Mrkt::ImportLeads do
5
- include_context 'initialized client'
5
+ include_context 'with an initialized client'
6
6
 
7
7
  describe '#import_lead' do
8
+ subject { client.import_lead(tempfile) }
9
+
8
10
  let(:tempfile) { Tempfile.new(%w[import-leads csv]) }
9
11
  let(:response_stub) do
10
12
  {
@@ -18,7 +20,6 @@ describe Mrkt::ImportLeads do
18
20
  ]
19
21
  }
20
22
  end
21
- subject { client.import_lead(tempfile) }
22
23
 
23
24
  before do
24
25
  CSV.open(tempfile, 'wb') do |csv|
@@ -39,6 +40,8 @@ describe Mrkt::ImportLeads do
39
40
  end
40
41
 
41
42
  describe '#import_lead_status' do
43
+ subject { client.import_lead_status(1) }
44
+
42
45
  let(:id) { 1 }
43
46
  let(:response_stub) do
44
47
  {
@@ -56,7 +59,6 @@ describe Mrkt::ImportLeads do
56
59
  success: true
57
60
  }
58
61
  end
59
- subject { client.import_lead_status(1) }
60
62
 
61
63
  before do
62
64
  stub_request(:get, "https://#{host}/bulk/v1/leads/batch/#{id}.json")
@@ -67,9 +69,10 @@ describe Mrkt::ImportLeads do
67
69
  end
68
70
 
69
71
  describe '#import_lead_failures' do
72
+ subject { client.import_lead_failures(1) }
73
+
70
74
  let(:id) { 1 }
71
75
  let(:response_stub) { '' }
72
- subject { client.import_lead_failures(1) }
73
76
 
74
77
  before do
75
78
  stub_request(:get, "https://#{host}/bulk/v1/leads/batch/#{id}/failures.json")
@@ -80,9 +83,10 @@ describe Mrkt::ImportLeads do
80
83
  end
81
84
 
82
85
  describe '#import_lead_warnings' do
86
+ subject { client.import_lead_warnings(1) }
87
+
83
88
  let(:id) { 1 }
84
89
  let(:response_stub) { '' }
85
- subject { client.import_lead_warnings(1) }
86
90
 
87
91
  before do
88
92
  stub_request(:get, "https://#{host}/bulk/v1/leads/batch/#{id}/warnings.json")
data/spec/errors_spec.rb CHANGED
@@ -1,21 +1,19 @@
1
1
  describe Mrkt::Errors do
2
2
  describe '.find_by_response_code' do
3
- subject { described_class.find_by_response_code(code) }
3
+ subject(:actual) { described_class.find_by_response_code(code) }
4
4
 
5
- context 'when the code is' do
6
- context 'known' do
7
- let(:code) { 413 }
5
+ context 'when the code is known' do
6
+ let(:code) { 413 }
8
7
 
9
- it 'should return the mapped error class' do
10
- is_expected.to eq(Mrkt::Errors::RequestEntityTooLarge)
11
- end
8
+ it 'returns the mapped error class' do
9
+ expect(actual).to eq(Mrkt::Errors::RequestEntityTooLarge)
12
10
  end
11
+ end
13
12
 
14
- context 'unknown' do
15
- let(:code) { 7331 }
13
+ context 'when the code is unknown' do
14
+ let(:code) { 7331 }
16
15
 
17
- it { is_expected.to eq(Mrkt::Errors::Error) }
18
- end
16
+ it { is_expected.to eq(Mrkt::Errors::Error) }
19
17
  end
20
18
  end
21
19
  end
@@ -1,5 +1,7 @@
1
1
  describe Mrkt::Faraday::ParamsEncoder do
2
2
  describe '.encode' do
3
+ subject { described_class.encode(params) }
4
+
3
5
  let(:params) do
4
6
  {
5
7
  string: 'foobar',
@@ -9,16 +11,14 @@ describe Mrkt::Faraday::ParamsEncoder do
9
11
  }
10
12
  end
11
13
 
12
- subject { described_class.encode(params) }
13
-
14
14
  it { is_expected.to eq(Faraday::Utils::ParamsHash.new.merge(params.merge(array: '1,2,3')).to_query) }
15
15
  end
16
16
 
17
17
  describe '.decode' do
18
- let(:value) { 'foo=foo&bar=bar' }
19
-
20
18
  subject { described_class.decode(value) }
21
19
 
20
+ let(:value) { 'foo=foo&bar=bar' }
21
+
22
22
  it { is_expected.to eq('foo' => 'foo', 'bar' => 'bar') }
23
23
  end
24
24
  end
@@ -1,5 +1,5 @@
1
1
  describe Mrkt do
2
- include_context 'initialized client'
2
+ include_context 'with an initialized client'
3
3
 
4
4
  it { is_expected.to respond_to(:get, :post, :delete) }
5
5
  end
@@ -1,7 +1,9 @@
1
1
  require 'securerandom'
2
2
  require 'json'
3
3
 
4
- shared_context 'initialized client' do
4
+ shared_context 'with an initialized client' do
5
+ subject(:client) { Mrkt::Client.new(host: host, client_id: client_id, client_secret: client_secret) }
6
+
5
7
  let(:host) { '0-KBZ-0.mktorest.com' }
6
8
  let(:client_id) { SecureRandom.uuid }
7
9
  let(:client_secret) { SecureRandom.hex }
@@ -9,8 +11,6 @@ shared_context 'initialized client' do
9
11
  { access_token: SecureRandom.uuid, token_type: 'bearer', expires_in: 2241, scope: 'RestClient' }
10
12
  end
11
13
 
12
- subject(:client) { Mrkt::Client.new(host: host, client_id: client_id, client_secret: client_secret) }
13
-
14
14
  before do
15
15
  @authentication_request_stub = stub_request(:get, "https://#{host}/identity/oauth/token")
16
16
  .with(query: { client_id: client_id, client_secret: client_secret, grant_type: 'client_credentials' })
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: 1.0.1
4
+ version: 1.2.1
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: 2020-07-08 00:00:00.000000000 Z
12
+ date: 2021-12-14 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: faraday
@@ -45,14 +45,14 @@ dependencies:
45
45
  requirements:
46
46
  - - "~>"
47
47
  - !ruby/object:Gem::Version
48
- version: '1.3'
48
+ version: '2.0'
49
49
  type: :development
50
50
  prerelease: false
51
51
  version_requirements: !ruby/object:Gem::Requirement
52
52
  requirements:
53
53
  - - "~>"
54
54
  - !ruby/object:Gem::Version
55
- version: '1.3'
55
+ version: '2.0'
56
56
  - !ruby/object:Gem::Dependency
57
57
  name: gem-release
58
58
  requirement: !ruby/object:Gem::Requirement
@@ -87,14 +87,14 @@ dependencies:
87
87
  requirements:
88
88
  - - "~>"
89
89
  - !ruby/object:Gem::Version
90
- version: '12.3'
90
+ version: '13.0'
91
91
  type: :development
92
92
  prerelease: false
93
93
  version_requirements: !ruby/object:Gem::Requirement
94
94
  requirements:
95
95
  - - "~>"
96
96
  - !ruby/object:Gem::Version
97
- version: '12.3'
97
+ version: '13.0'
98
98
  - !ruby/object:Gem::Dependency
99
99
  name: rspec
100
100
  requirement: !ruby/object:Gem::Requirement
@@ -115,28 +115,56 @@ dependencies:
115
115
  requirements:
116
116
  - - "~>"
117
117
  - !ruby/object:Gem::Version
118
- version: 0.87.1
118
+ version: 1.23.0
119
119
  type: :development
120
120
  prerelease: false
121
121
  version_requirements: !ruby/object:Gem::Requirement
122
122
  requirements:
123
123
  - - "~>"
124
124
  - !ruby/object:Gem::Version
125
- version: 0.87.1
125
+ version: 1.23.0
126
+ - !ruby/object:Gem::Dependency
127
+ name: rubocop-rake
128
+ requirement: !ruby/object:Gem::Requirement
129
+ requirements:
130
+ - - "~>"
131
+ - !ruby/object:Gem::Version
132
+ version: 0.6.0
133
+ type: :development
134
+ prerelease: false
135
+ version_requirements: !ruby/object:Gem::Requirement
136
+ requirements:
137
+ - - "~>"
138
+ - !ruby/object:Gem::Version
139
+ version: 0.6.0
140
+ - !ruby/object:Gem::Dependency
141
+ name: rubocop-rspec
142
+ requirement: !ruby/object:Gem::Requirement
143
+ requirements:
144
+ - - "~>"
145
+ - !ruby/object:Gem::Version
146
+ version: '2.6'
147
+ type: :development
148
+ prerelease: false
149
+ version_requirements: !ruby/object:Gem::Requirement
150
+ requirements:
151
+ - - "~>"
152
+ - !ruby/object:Gem::Version
153
+ version: '2.6'
126
154
  - !ruby/object:Gem::Dependency
127
155
  name: simplecov
128
156
  requirement: !ruby/object:Gem::Requirement
129
157
  requirements:
130
158
  - - "~>"
131
159
  - !ruby/object:Gem::Version
132
- version: 0.17.1
160
+ version: 0.21.2
133
161
  type: :development
134
162
  prerelease: false
135
163
  version_requirements: !ruby/object:Gem::Requirement
136
164
  requirements:
137
165
  - - "~>"
138
166
  - !ruby/object:Gem::Version
139
- version: 0.17.1
167
+ version: 0.21.2
140
168
  - !ruby/object:Gem::Dependency
141
169
  name: webmock
142
170
  requirement: !ruby/object:Gem::Requirement
@@ -159,10 +187,11 @@ executables: []
159
187
  extensions: []
160
188
  extra_rdoc_files: []
161
189
  files:
190
+ - ".github/dependabot.yml"
191
+ - ".github/workflows/ruby.yml"
162
192
  - ".gitignore"
163
193
  - ".rspec"
164
194
  - ".rubocop.yml"
165
- - ".travis.yml"
166
195
  - Gemfile
167
196
  - Gemfile.lock
168
197
  - LICENSE
@@ -181,6 +210,7 @@ files:
181
210
  - lib/mrkt/concerns/crud_helpers.rb
182
211
  - lib/mrkt/concerns/crud_leads.rb
183
212
  - lib/mrkt/concerns/crud_lists.rb
213
+ - lib/mrkt/concerns/crud_program_members.rb
184
214
  - lib/mrkt/concerns/crud_programs.rb
185
215
  - lib/mrkt/concerns/import_custom_objects.rb
186
216
  - lib/mrkt/concerns/import_leads.rb
@@ -200,6 +230,7 @@ files:
200
230
  - spec/concerns/crud_custom_objects_spec.rb
201
231
  - spec/concerns/crud_leads_spec.rb
202
232
  - spec/concerns/crud_lists_spec.rb
233
+ - spec/concerns/crud_program_members_spec.rb
203
234
  - spec/concerns/crud_programs_spec.rb
204
235
  - spec/concerns/import_custom_objects_spec.rb
205
236
  - spec/concerns/import_leads_spec.rb
@@ -212,14 +243,15 @@ files:
212
243
  homepage: https://github.com/raszi/mrkt
213
244
  licenses:
214
245
  - MIT
215
- metadata: {}
246
+ metadata:
247
+ rubygems_mfa_required: 'true'
216
248
  post_install_message:
217
249
  rdoc_options: []
218
250
  require_paths:
219
251
  - lib
220
252
  required_ruby_version: !ruby/object:Gem::Requirement
221
253
  requirements:
222
- - - "~>"
254
+ - - ">="
223
255
  - !ruby/object:Gem::Version
224
256
  version: '2.5'
225
257
  required_rubygems_version: !ruby/object:Gem::Requirement
@@ -228,7 +260,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
228
260
  - !ruby/object:Gem::Version
229
261
  version: '0'
230
262
  requirements: []
231
- rubygems_version: 3.0.3
263
+ rubygems_version: 3.1.4
232
264
  signing_key:
233
265
  specification_version: 4
234
266
  summary: Marketo REST API Facade
@@ -242,6 +274,7 @@ test_files:
242
274
  - spec/concerns/crud_custom_objects_spec.rb
243
275
  - spec/concerns/crud_leads_spec.rb
244
276
  - spec/concerns/crud_lists_spec.rb
277
+ - spec/concerns/crud_program_members_spec.rb
245
278
  - spec/concerns/crud_programs_spec.rb
246
279
  - spec/concerns/import_custom_objects_spec.rb
247
280
  - spec/concerns/import_leads_spec.rb
data/.travis.yml DELETED
@@ -1,21 +0,0 @@
1
- env:
2
- global:
3
- - CC_TEST_REPORTER_ID=45cd2174f49b570406e294ff393d456c4ae8532cf16dd6430abb06d8a0722a28
4
- - COVERAGE=on
5
- language: ruby
6
- rvm:
7
- - 2.5
8
- - 2.6
9
- - 2.7
10
- before_install:
11
- - gem update --system
12
- - bundle update --bundler
13
- before_script:
14
- - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
15
- - chmod +x ./cc-test-reporter
16
- - ./cc-test-reporter before-build
17
- script:
18
- - bundle exec rspec
19
- - bundle exec rubocop
20
- after_script:
21
- - ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT