mrkt 0.7.0 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +2 -0
- data/.travis.yml +8 -4
- data/Gemfile.lock +49 -49
- data/lib/mrkt.rb +2 -0
- data/lib/mrkt/concerns/crud_activities.rb +29 -0
- data/lib/mrkt/concerns/crud_custom_activities.rb +2 -1
- data/lib/mrkt/concerns/crud_leads.rb +11 -0
- data/lib/mrkt/faraday_middleware/response.rb +4 -4
- data/lib/mrkt/version.rb +1 -1
- data/mrkt.gemspec +6 -6
- data/spec/concerns/crud_activities_spec.rb +240 -0
- data/spec/concerns/crud_leads_spec.rb +48 -0
- data/spec/spec_helper.rb +0 -5
- metadata +18 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9c4c184b895beed1d39507db68cd1826fd709588
|
4
|
+
data.tar.gz: f2fcf806aa0f17d07ee67034eeabe09159ef1b60
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eb54c671fa877899ab5161db7446d0b142684a0fed8ed05cf7b3e533827a229a32603e40e6500b971196e91dab13864bd79ef0147d9a523e3eaf2122548ba9d5
|
7
|
+
data.tar.gz: bfb9caab6508464ecc878d9e0b17a3c69b0f72f75f84d3e611f60aa2e3384d2ef961dd25e4d81f904f81685791e173dac5b809cf16df763e6dfb9a631e5281b9
|
data/.rubocop.yml
CHANGED
data/.travis.yml
CHANGED
@@ -1,8 +1,12 @@
|
|
1
1
|
language: ruby
|
2
2
|
rvm:
|
3
3
|
- 2.0.0
|
4
|
-
- 2.1.
|
5
|
-
- 2.2.
|
6
|
-
- 2.3.
|
4
|
+
- 2.1.10
|
5
|
+
- 2.2.8
|
6
|
+
- 2.3.5
|
7
|
+
- 2.4.2
|
7
8
|
addons:
|
8
|
-
code_climate:
|
9
|
+
code_climate:
|
10
|
+
repo_token: 45cd2174f49b570406e294ff393d456c4ae8532cf16dd6430abb06d8a0722a28
|
11
|
+
after_success:
|
12
|
+
- bundle exec codeclimate-test-reporter
|
data/Gemfile.lock
CHANGED
@@ -1,73 +1,73 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
mrkt (0.
|
5
|
-
faraday (> 0.9.0, < 0.
|
6
|
-
faraday_middleware (> 0.9.0, < 0.
|
4
|
+
mrkt (0.8.0)
|
5
|
+
faraday (> 0.9.0, < 0.14.0)
|
6
|
+
faraday_middleware (> 0.9.0, < 0.13.0)
|
7
7
|
|
8
8
|
GEM
|
9
9
|
remote: https://rubygems.org/
|
10
10
|
specs:
|
11
|
-
addressable (2.
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
coderay (1.1.0)
|
20
|
-
columnize (0.9.0)
|
21
|
-
crack (0.4.2)
|
11
|
+
addressable (2.5.1)
|
12
|
+
public_suffix (~> 2.0, >= 2.0.2)
|
13
|
+
ast (2.3.0)
|
14
|
+
byebug (9.0.6)
|
15
|
+
codeclimate-test-reporter (1.0.7)
|
16
|
+
simplecov
|
17
|
+
coderay (1.1.1)
|
18
|
+
crack (0.4.3)
|
22
19
|
safe_yaml (~> 1.0.0)
|
23
|
-
diff-lcs (1.
|
20
|
+
diff-lcs (1.3)
|
24
21
|
docile (1.1.5)
|
25
|
-
faraday (0.
|
22
|
+
faraday (0.10.1)
|
26
23
|
multipart-post (>= 1.2, < 3)
|
27
|
-
faraday_middleware (0.10.
|
28
|
-
faraday (>= 0.7.4, < 0
|
29
|
-
json (1.
|
24
|
+
faraday_middleware (0.10.1)
|
25
|
+
faraday (>= 0.7.4, < 1.0)
|
26
|
+
json (2.1.0)
|
30
27
|
method_source (0.8.2)
|
31
28
|
multipart-post (2.0.0)
|
32
|
-
parser (2.
|
33
|
-
ast (
|
29
|
+
parser (2.4.0.0)
|
30
|
+
ast (~> 2.2)
|
34
31
|
powerpack (0.1.1)
|
35
|
-
pry (0.10.
|
32
|
+
pry (0.10.4)
|
36
33
|
coderay (~> 1.1.0)
|
37
34
|
method_source (~> 0.8.1)
|
38
35
|
slop (~> 3.4)
|
39
|
-
pry-byebug (3.
|
40
|
-
byebug (~>
|
36
|
+
pry-byebug (3.4.2)
|
37
|
+
byebug (~> 9.0)
|
41
38
|
pry (~> 0.10)
|
42
|
-
|
39
|
+
public_suffix (2.0.5)
|
40
|
+
rainbow (2.2.2)
|
41
|
+
rake
|
43
42
|
rake (10.5.0)
|
44
|
-
rspec (3.
|
45
|
-
rspec-core (~> 3.
|
46
|
-
rspec-expectations (~> 3.
|
47
|
-
rspec-mocks (~> 3.
|
48
|
-
rspec-core (3.
|
49
|
-
rspec-support (~> 3.
|
50
|
-
rspec-expectations (3.
|
43
|
+
rspec (3.6.0)
|
44
|
+
rspec-core (~> 3.6.0)
|
45
|
+
rspec-expectations (~> 3.6.0)
|
46
|
+
rspec-mocks (~> 3.6.0)
|
47
|
+
rspec-core (3.6.0)
|
48
|
+
rspec-support (~> 3.6.0)
|
49
|
+
rspec-expectations (3.6.0)
|
51
50
|
diff-lcs (>= 1.2.0, < 2.0)
|
52
|
-
rspec-support (~> 3.
|
53
|
-
rspec-mocks (3.
|
51
|
+
rspec-support (~> 3.6.0)
|
52
|
+
rspec-mocks (3.6.0)
|
54
53
|
diff-lcs (>= 1.2.0, < 2.0)
|
55
|
-
rspec-support (~> 3.
|
56
|
-
rspec-support (3.
|
57
|
-
rubocop (0.
|
58
|
-
|
59
|
-
parser (>= 2.2.2.5, < 3.0)
|
54
|
+
rspec-support (~> 3.6.0)
|
55
|
+
rspec-support (3.6.0)
|
56
|
+
rubocop (0.45.0)
|
57
|
+
parser (>= 2.3.1.1, < 3.0)
|
60
58
|
powerpack (~> 0.1)
|
61
59
|
rainbow (>= 1.99.1, < 3.0)
|
62
|
-
ruby-progressbar (~> 1.
|
63
|
-
|
60
|
+
ruby-progressbar (~> 1.7)
|
61
|
+
unicode-display_width (~> 1.0, >= 1.0.1)
|
62
|
+
ruby-progressbar (1.8.1)
|
64
63
|
safe_yaml (1.0.4)
|
65
|
-
simplecov (0.
|
64
|
+
simplecov (0.14.1)
|
66
65
|
docile (~> 1.1.0)
|
67
|
-
json (
|
66
|
+
json (>= 1.8, < 3)
|
68
67
|
simplecov-html (~> 0.10.0)
|
69
|
-
simplecov-html (0.10.
|
68
|
+
simplecov-html (0.10.1)
|
70
69
|
slop (3.6.0)
|
70
|
+
unicode-display_width (1.3.0)
|
71
71
|
webmock (1.21.0)
|
72
72
|
addressable (>= 2.3.6)
|
73
73
|
crack (>= 0.3.2)
|
@@ -77,14 +77,14 @@ PLATFORMS
|
|
77
77
|
|
78
78
|
DEPENDENCIES
|
79
79
|
bundler (~> 1.3)
|
80
|
-
codeclimate-test-reporter (~> 0.
|
80
|
+
codeclimate-test-reporter (~> 1.0.0)
|
81
81
|
mrkt!
|
82
|
-
pry-byebug (~> 3.
|
82
|
+
pry-byebug (~> 3.4.0)
|
83
83
|
rake (~> 10.0)
|
84
84
|
rspec (~> 3.2)
|
85
|
-
rubocop (~> 0.
|
86
|
-
simplecov (~> 0.
|
85
|
+
rubocop (~> 0.45.0)
|
86
|
+
simplecov (~> 0.14.1)
|
87
87
|
webmock (~> 1.21.0)
|
88
88
|
|
89
89
|
BUNDLED WITH
|
90
|
-
1.
|
90
|
+
1.15.4
|
data/lib/mrkt.rb
CHANGED
@@ -4,6 +4,7 @@ require 'mrkt/errors'
|
|
4
4
|
require 'mrkt/concerns/connection'
|
5
5
|
require 'mrkt/concerns/authentication'
|
6
6
|
require 'mrkt/concerns/crud_helpers'
|
7
|
+
require 'mrkt/concerns/crud_activities'
|
7
8
|
require 'mrkt/concerns/crud_campaigns'
|
8
9
|
require 'mrkt/concerns/crud_leads'
|
9
10
|
require 'mrkt/concerns/crud_lists'
|
@@ -17,6 +18,7 @@ module Mrkt
|
|
17
18
|
include Connection
|
18
19
|
include Authentication
|
19
20
|
include CrudHelpers
|
21
|
+
include CrudActivities
|
20
22
|
include CrudCampaigns
|
21
23
|
include CrudLeads
|
22
24
|
include CrudLists
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module Mrkt
|
2
|
+
module CrudActivities
|
3
|
+
def get_activity_types
|
4
|
+
get("/rest/v1/activities/types.json")
|
5
|
+
end
|
6
|
+
|
7
|
+
def get_paging_token(since_datetime)
|
8
|
+
params = {
|
9
|
+
sinceDatetime: since_datetime.iso8601
|
10
|
+
}
|
11
|
+
get("/rest/v1/activities/pagingtoken.json", params)
|
12
|
+
end
|
13
|
+
|
14
|
+
def get_activities(next_page_token, activity_type_ids: [], lead_ids: [])
|
15
|
+
params = {
|
16
|
+
nextPageToken: next_page_token
|
17
|
+
}
|
18
|
+
params[:activityTypeIds] = activity_type_ids.join(',') unless blank?(activity_type_ids)
|
19
|
+
params[:leadIds] = lead_ids.join(',') unless blank?(lead_ids)
|
20
|
+
get("/rest/v1/activities.json", params)
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def blank?(value)
|
26
|
+
!value || value == "" || value.empty?
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -3,7 +3,8 @@ require 'time'
|
|
3
3
|
module Mrkt
|
4
4
|
module CrudCustomActivities
|
5
5
|
def get_list_of_custom_activity_types
|
6
|
-
|
6
|
+
warn 'DEPRECATED: Use #get_activity_types instead of #get_list_of_custom_activity_types!'
|
7
|
+
get_activity_types
|
7
8
|
end
|
8
9
|
|
9
10
|
def create_custom_activity(lead_id, activity_type_id, primary_attribute_value, attributes: {}, date: nil)
|
@@ -40,5 +40,16 @@ module Mrkt
|
|
40
40
|
json_payload(req, {})
|
41
41
|
end
|
42
42
|
end
|
43
|
+
|
44
|
+
def merge_leads(winning_lead_id, losing_lead_ids, merge_in_crm: false)
|
45
|
+
params = Faraday::Utils::ParamsHash.new
|
46
|
+
params[:mergeInCRM] = merge_in_crm
|
47
|
+
params[:leadIds] = losing_lead_ids.join(',') if losing_lead_ids
|
48
|
+
|
49
|
+
post("/rest/v1/leads/#{winning_lead_id}/merge.json?#{params.to_query}") do |req|
|
50
|
+
json_payload(req,{})
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
43
54
|
end
|
44
55
|
end
|
@@ -12,8 +12,8 @@ module Mrkt
|
|
12
12
|
|
13
13
|
data = env[:body]
|
14
14
|
|
15
|
-
|
16
|
-
|
15
|
+
raise Mrkt::Errors::EmptyResponse if data.nil?
|
16
|
+
raise Mrkt::Errors::Error, data[:error_description] if data.key?(:error)
|
17
17
|
|
18
18
|
handle_errors!(data[:errors]) unless data.fetch(:success, true)
|
19
19
|
end
|
@@ -21,8 +21,8 @@ module Mrkt
|
|
21
21
|
def handle_errors!(errors)
|
22
22
|
error = errors.first
|
23
23
|
|
24
|
-
|
25
|
-
|
24
|
+
raise Mrkt::Errors::Unknown if error.nil?
|
25
|
+
raise Mrkt::Errors.find_by_response_code(error[:code].to_i), error[:message]
|
26
26
|
end
|
27
27
|
end
|
28
28
|
end
|
data/lib/mrkt/version.rb
CHANGED
data/mrkt.gemspec
CHANGED
@@ -20,15 +20,15 @@ Gem::Specification.new do |spec|
|
|
20
20
|
|
21
21
|
spec.required_ruby_version = '~> 2.0'
|
22
22
|
|
23
|
-
spec.add_dependency 'faraday', '> 0.9.0', '< 0.
|
24
|
-
spec.add_dependency 'faraday_middleware', '> 0.9.0', '< 0.
|
23
|
+
spec.add_dependency 'faraday', '> 0.9.0', '< 0.14.0'
|
24
|
+
spec.add_dependency 'faraday_middleware', '> 0.9.0', '< 0.13.0'
|
25
25
|
|
26
26
|
spec.add_development_dependency 'bundler', '~> 1.3'
|
27
27
|
spec.add_development_dependency 'rake', '~> 10.0'
|
28
28
|
spec.add_development_dependency 'rspec', '~> 3.2'
|
29
29
|
spec.add_development_dependency 'webmock', '~> 1.21.0'
|
30
|
-
spec.add_development_dependency 'simplecov', '~> 0.
|
31
|
-
spec.add_development_dependency 'pry-byebug', '~> 3.
|
32
|
-
spec.add_development_dependency 'codeclimate-test-reporter', '~> 0.
|
33
|
-
spec.add_development_dependency 'rubocop', '~> 0.
|
30
|
+
spec.add_development_dependency 'simplecov', '~> 0.14.1'
|
31
|
+
spec.add_development_dependency 'pry-byebug', '~> 3.4.0'
|
32
|
+
spec.add_development_dependency 'codeclimate-test-reporter', '~> 1.0.0'
|
33
|
+
spec.add_development_dependency 'rubocop', '~> 0.45.0'
|
34
34
|
end
|
@@ -0,0 +1,240 @@
|
|
1
|
+
describe Mrkt::CrudActivities do
|
2
|
+
include_context 'initialized client'
|
3
|
+
|
4
|
+
describe '#get_activity_types' do
|
5
|
+
let(:response_stub) do
|
6
|
+
{
|
7
|
+
requestId: 'c245#14cd6830ae2',
|
8
|
+
result: [
|
9
|
+
{
|
10
|
+
id: 1,
|
11
|
+
name: 'Visit Webpage',
|
12
|
+
description: 'User visits a web page',
|
13
|
+
primareAttributes: {
|
14
|
+
name: 'Webpage ID',
|
15
|
+
dataType: 'integer'
|
16
|
+
},
|
17
|
+
attributes: [
|
18
|
+
{
|
19
|
+
name: 'Query Parameters',
|
20
|
+
dataType: 'string'
|
21
|
+
},
|
22
|
+
{
|
23
|
+
name: 'Webpage URL',
|
24
|
+
dataType: 'string'
|
25
|
+
}
|
26
|
+
]
|
27
|
+
}
|
28
|
+
],
|
29
|
+
success: true
|
30
|
+
}
|
31
|
+
end
|
32
|
+
subject { client.get_activity_types }
|
33
|
+
|
34
|
+
before do
|
35
|
+
stub_request(:get, "https://#{host}/rest/v1/activities/types.json")
|
36
|
+
.to_return(json_stub(response_stub))
|
37
|
+
end
|
38
|
+
|
39
|
+
it { is_expected.to eq(response_stub) }
|
40
|
+
end
|
41
|
+
|
42
|
+
describe '#get_paging_token' do
|
43
|
+
let(:since_datetime) { Time.utc(2017, 1, 1, 4, 30) }
|
44
|
+
let(:response_stub) do
|
45
|
+
{
|
46
|
+
requestId: '12eb3#1599b371c62',
|
47
|
+
success: true,
|
48
|
+
nextPageToken: '4GAX7YNCIJKO2VAED5LH5PQIYPUM7WCVKTQWEDMP2L24AXZT54LA===='
|
49
|
+
}
|
50
|
+
end
|
51
|
+
subject { client.get_paging_token(since_datetime) }
|
52
|
+
|
53
|
+
before do
|
54
|
+
stub_request(:get, "https://#{host}/rest/v1/activities/pagingtoken.json")
|
55
|
+
.with(query: { sinceDatetime: '2017-01-01T04:30:00Z' })
|
56
|
+
.to_return(json_stub(response_stub))
|
57
|
+
end
|
58
|
+
|
59
|
+
it { is_expected.to eq(response_stub) }
|
60
|
+
end
|
61
|
+
|
62
|
+
describe '#get_activities' do
|
63
|
+
let(:activity_type_ids) { [1, 2] }
|
64
|
+
let(:lead_ids) { [100, 102] }
|
65
|
+
let(:token) { '4GAX7YNCIJKO2VAED5LH5PQIYPUM7WCVKTQWEDMP2L24AXZT54LA====' }
|
66
|
+
let(:response_stub) do
|
67
|
+
{
|
68
|
+
data: {
|
69
|
+
requestId: '417b#1599b3bca62',
|
70
|
+
result: [
|
71
|
+
{
|
72
|
+
id: 500,
|
73
|
+
leadId: 100,
|
74
|
+
activityDate: '2017-01-01T07:53:29Z',
|
75
|
+
activityTypeId: 1,
|
76
|
+
primaryAttributeValueId: 29,
|
77
|
+
primaryAttributeValue: 'test',
|
78
|
+
attributes: [
|
79
|
+
{
|
80
|
+
name: 'Query Parameters',
|
81
|
+
value: ''
|
82
|
+
},
|
83
|
+
{
|
84
|
+
name: 'Webpage URL',
|
85
|
+
value: '/test.html'
|
86
|
+
}
|
87
|
+
]
|
88
|
+
},
|
89
|
+
{
|
90
|
+
id: 456,
|
91
|
+
leadId: 101,
|
92
|
+
activityDate: '2017-01-01T08:13:36Z',
|
93
|
+
activityTypeId: 12,
|
94
|
+
primaryAttributeValueId: 101,
|
95
|
+
attributes: [
|
96
|
+
{
|
97
|
+
name: 'Form Name',
|
98
|
+
value: 'Sign Up'
|
99
|
+
}
|
100
|
+
]
|
101
|
+
}
|
102
|
+
]
|
103
|
+
},
|
104
|
+
success: true,
|
105
|
+
nextPageToken: 'WQV2VQVPPCKHC6AQYVK7JDSA3I5PBAJNUNY3CR563KMVM7F43OIQ====',
|
106
|
+
moreResult: false
|
107
|
+
}
|
108
|
+
end
|
109
|
+
subject { client.get_activities(token) }
|
110
|
+
|
111
|
+
before do
|
112
|
+
stub_request(:get, "https://#{host}/rest/v1/activities.json")
|
113
|
+
.with(query: { nextPageToken: URI.encode(token) })
|
114
|
+
.to_return(json_stub(response_stub))
|
115
|
+
end
|
116
|
+
|
117
|
+
it { is_expected.to eq(response_stub) }
|
118
|
+
|
119
|
+
context 'specifying activity type ids' do
|
120
|
+
let(:response_stub) do
|
121
|
+
{
|
122
|
+
data: {
|
123
|
+
requestId: '417b#1599b3bca62',
|
124
|
+
result: [
|
125
|
+
{
|
126
|
+
id: 500,
|
127
|
+
leadId: 100,
|
128
|
+
activityDate: '2017-01-01T07:53:29Z',
|
129
|
+
activityTypeId: 1,
|
130
|
+
primaryAttributeValueId: 29,
|
131
|
+
primaryAttributeValue: 'test',
|
132
|
+
attributes: [
|
133
|
+
{
|
134
|
+
name: 'Query Parameters',
|
135
|
+
value: ''
|
136
|
+
},
|
137
|
+
{
|
138
|
+
name: 'Webpage URL',
|
139
|
+
value: '/test.html'
|
140
|
+
}
|
141
|
+
]
|
142
|
+
}
|
143
|
+
]
|
144
|
+
},
|
145
|
+
success: true,
|
146
|
+
nextPageToken: 'WQV2VQVPPCKHC6AQYVK7JDSA3I5PBAJNUNY3CR563KMVM7F43OIQ====',
|
147
|
+
moreResult: false
|
148
|
+
}
|
149
|
+
end
|
150
|
+
subject { client.get_activities(token, activity_type_ids: activity_type_ids) }
|
151
|
+
|
152
|
+
before do
|
153
|
+
stub_request(:get, "https://#{host}/rest/v1/activities.json")
|
154
|
+
.with(query: {
|
155
|
+
nextPageToken: URI.encode(token),
|
156
|
+
activityTypeIds: activity_type_ids.join(',')
|
157
|
+
})
|
158
|
+
.to_return(json_stub(response_stub))
|
159
|
+
end
|
160
|
+
|
161
|
+
it { is_expected.to eq(response_stub) }
|
162
|
+
end
|
163
|
+
|
164
|
+
context 'specifying lead ids' do
|
165
|
+
let(:response_stub) do
|
166
|
+
{
|
167
|
+
data: {
|
168
|
+
requestId: '417b#1599b3bca62',
|
169
|
+
result: [
|
170
|
+
{
|
171
|
+
id: 500,
|
172
|
+
leadId: 100,
|
173
|
+
activityDate: '2017-01-01T07:53:29Z',
|
174
|
+
activityTypeId: 1,
|
175
|
+
primaryAttributeValueId: 29,
|
176
|
+
primaryAttributeValue: 'test',
|
177
|
+
attributes: [
|
178
|
+
{
|
179
|
+
name: 'Query Parameters',
|
180
|
+
value: ''
|
181
|
+
},
|
182
|
+
{
|
183
|
+
name: 'Webpage URL',
|
184
|
+
value: '/test.html'
|
185
|
+
}
|
186
|
+
]
|
187
|
+
}
|
188
|
+
]
|
189
|
+
},
|
190
|
+
success: true,
|
191
|
+
nextPageToken: 'WQV2VQVPPCKHC6AQYVK7JDSA3I5PBAJNUNY3CR563KMVM7F43OIQ====',
|
192
|
+
moreResult: false
|
193
|
+
}
|
194
|
+
end
|
195
|
+
subject { client.get_activities(token, lead_ids: lead_ids) }
|
196
|
+
|
197
|
+
before do
|
198
|
+
stub_request(:get, "https://#{host}/rest/v1/activities.json")
|
199
|
+
.with(query: { nextPageToken: URI.encode(token), leadIds: lead_ids.join(',') })
|
200
|
+
.to_return(json_stub(response_stub))
|
201
|
+
end
|
202
|
+
|
203
|
+
it { is_expected.to eq(response_stub) }
|
204
|
+
end
|
205
|
+
|
206
|
+
context 'specifying arrays values as empty strings' do
|
207
|
+
let(:activity_type_ids) { "" }
|
208
|
+
let(:lead_ids) { "" }
|
209
|
+
subject do
|
210
|
+
client.get_activities(token, activity_type_ids: activity_type_ids, lead_ids: lead_ids)
|
211
|
+
end
|
212
|
+
|
213
|
+
before do
|
214
|
+
stub_request(:get, "https://#{host}/rest/v1/activities.json")
|
215
|
+
.with(query: { nextPageToken: URI.encode(token) })
|
216
|
+
.to_return(json_stub(response_stub))
|
217
|
+
end
|
218
|
+
|
219
|
+
it { is_expected.to eq(response_stub) }
|
220
|
+
end
|
221
|
+
|
222
|
+
context 'specifying all options' do
|
223
|
+
subject do
|
224
|
+
client.get_activities(token, activity_type_ids: activity_type_ids, lead_ids: lead_ids)
|
225
|
+
end
|
226
|
+
|
227
|
+
before do
|
228
|
+
stub_request(:get, "https://#{host}/rest/v1/activities.json")
|
229
|
+
.with(query: {
|
230
|
+
nextPageToken: URI.encode(token),
|
231
|
+
activityTypeIds: activity_type_ids.join(','),
|
232
|
+
leadIds: lead_ids.join(',')
|
233
|
+
})
|
234
|
+
.to_return(json_stub(response_stub))
|
235
|
+
end
|
236
|
+
|
237
|
+
it { is_expected.to eq(response_stub) }
|
238
|
+
end
|
239
|
+
end
|
240
|
+
end
|
@@ -148,4 +148,52 @@ describe Mrkt::CrudLeads do
|
|
148
148
|
end
|
149
149
|
end
|
150
150
|
end
|
151
|
+
|
152
|
+
describe '#merge_leads' do
|
153
|
+
let(:id) { 1 }
|
154
|
+
let(:losing_lead_ids) { [2, 3, 4] }
|
155
|
+
let(:request_stub) { {} }
|
156
|
+
|
157
|
+
subject { client.merge_leads(id, losing_lead_ids) }
|
158
|
+
|
159
|
+
before do
|
160
|
+
params = Faraday::Utils::ParamsHash.new
|
161
|
+
params[:mergeInCRM] = false
|
162
|
+
params[:leadIds] = losing_lead_ids.join(',') if losing_lead_ids
|
163
|
+
|
164
|
+
stub_request(:post, "https://#{host}/rest/v1/leads/#{id}/merge.json?#{params.to_query}")
|
165
|
+
.with(json_stub(request_stub))
|
166
|
+
.to_return(json_stub(response_stub))
|
167
|
+
end
|
168
|
+
|
169
|
+
context 'with existing leads' do
|
170
|
+
let(:response_stub) do
|
171
|
+
{
|
172
|
+
requestId: 'c245#14cd6830ae2',
|
173
|
+
success: true
|
174
|
+
}
|
175
|
+
end
|
176
|
+
|
177
|
+
it { is_expected.to eq(response_stub) }
|
178
|
+
end
|
179
|
+
|
180
|
+
context 'with a non-existing lead id' do
|
181
|
+
let(:response_stub) do
|
182
|
+
{
|
183
|
+
requestId: 'c245#14cd6830ae2',
|
184
|
+
success: false,
|
185
|
+
errors: [
|
186
|
+
{
|
187
|
+
code: '1004',
|
188
|
+
message: "Lead '1' not found"
|
189
|
+
}
|
190
|
+
]
|
191
|
+
}
|
192
|
+
end
|
193
|
+
|
194
|
+
it 'should raise an Error' do
|
195
|
+
expect { subject }.to raise_error(Mrkt::Errors::LeadNotFound)
|
196
|
+
end
|
197
|
+
end
|
198
|
+
end
|
151
199
|
end
|
data/spec/spec_helper.rb
CHANGED
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.
|
4
|
+
version: 0.8.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:
|
12
|
+
date: 2017-10-03 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.
|
23
|
+
version: 0.14.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.
|
33
|
+
version: 0.14.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.
|
43
|
+
version: 0.13.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.
|
53
|
+
version: 0.13.0
|
54
54
|
- !ruby/object:Gem::Dependency
|
55
55
|
name: bundler
|
56
56
|
requirement: !ruby/object:Gem::Requirement
|
@@ -113,56 +113,56 @@ dependencies:
|
|
113
113
|
requirements:
|
114
114
|
- - "~>"
|
115
115
|
- !ruby/object:Gem::Version
|
116
|
-
version: 0.
|
116
|
+
version: 0.14.1
|
117
117
|
type: :development
|
118
118
|
prerelease: false
|
119
119
|
version_requirements: !ruby/object:Gem::Requirement
|
120
120
|
requirements:
|
121
121
|
- - "~>"
|
122
122
|
- !ruby/object:Gem::Version
|
123
|
-
version: 0.
|
123
|
+
version: 0.14.1
|
124
124
|
- !ruby/object:Gem::Dependency
|
125
125
|
name: pry-byebug
|
126
126
|
requirement: !ruby/object:Gem::Requirement
|
127
127
|
requirements:
|
128
128
|
- - "~>"
|
129
129
|
- !ruby/object:Gem::Version
|
130
|
-
version: 3.
|
130
|
+
version: 3.4.0
|
131
131
|
type: :development
|
132
132
|
prerelease: false
|
133
133
|
version_requirements: !ruby/object:Gem::Requirement
|
134
134
|
requirements:
|
135
135
|
- - "~>"
|
136
136
|
- !ruby/object:Gem::Version
|
137
|
-
version: 3.
|
137
|
+
version: 3.4.0
|
138
138
|
- !ruby/object:Gem::Dependency
|
139
139
|
name: codeclimate-test-reporter
|
140
140
|
requirement: !ruby/object:Gem::Requirement
|
141
141
|
requirements:
|
142
142
|
- - "~>"
|
143
143
|
- !ruby/object:Gem::Version
|
144
|
-
version: 0.
|
144
|
+
version: 1.0.0
|
145
145
|
type: :development
|
146
146
|
prerelease: false
|
147
147
|
version_requirements: !ruby/object:Gem::Requirement
|
148
148
|
requirements:
|
149
149
|
- - "~>"
|
150
150
|
- !ruby/object:Gem::Version
|
151
|
-
version: 0.
|
151
|
+
version: 1.0.0
|
152
152
|
- !ruby/object:Gem::Dependency
|
153
153
|
name: rubocop
|
154
154
|
requirement: !ruby/object:Gem::Requirement
|
155
155
|
requirements:
|
156
156
|
- - "~>"
|
157
157
|
- !ruby/object:Gem::Version
|
158
|
-
version: 0.
|
158
|
+
version: 0.45.0
|
159
159
|
type: :development
|
160
160
|
prerelease: false
|
161
161
|
version_requirements: !ruby/object:Gem::Requirement
|
162
162
|
requirements:
|
163
163
|
- - "~>"
|
164
164
|
- !ruby/object:Gem::Version
|
165
|
-
version: 0.
|
165
|
+
version: 0.45.0
|
166
166
|
description: This gem helps you to use the Marketo REST API
|
167
167
|
email:
|
168
168
|
- github@spam.raszi.hu
|
@@ -183,6 +183,7 @@ files:
|
|
183
183
|
- lib/mrkt.rb
|
184
184
|
- lib/mrkt/concerns/authentication.rb
|
185
185
|
- lib/mrkt/concerns/connection.rb
|
186
|
+
- lib/mrkt/concerns/crud_activities.rb
|
186
187
|
- lib/mrkt/concerns/crud_campaigns.rb
|
187
188
|
- lib/mrkt/concerns/crud_custom_activities.rb
|
188
189
|
- lib/mrkt/concerns/crud_custom_objects.rb
|
@@ -197,6 +198,7 @@ files:
|
|
197
198
|
- lib/mrkt/version.rb
|
198
199
|
- mrkt.gemspec
|
199
200
|
- spec/concerns/authentication_spec.rb
|
201
|
+
- spec/concerns/crud_activities_spec.rb
|
200
202
|
- spec/concerns/crud_campaigns_spec.rb
|
201
203
|
- spec/concerns/crud_custom_activities_spec.rb
|
202
204
|
- spec/concerns/crud_custom_objects_spec.rb
|
@@ -229,12 +231,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
229
231
|
version: '0'
|
230
232
|
requirements: []
|
231
233
|
rubyforge_project:
|
232
|
-
rubygems_version: 2.
|
234
|
+
rubygems_version: 2.6.12
|
233
235
|
signing_key:
|
234
236
|
specification_version: 4
|
235
237
|
summary: Marketo REST API Facade
|
236
238
|
test_files:
|
237
239
|
- spec/concerns/authentication_spec.rb
|
240
|
+
- spec/concerns/crud_activities_spec.rb
|
238
241
|
- spec/concerns/crud_campaigns_spec.rb
|
239
242
|
- spec/concerns/crud_custom_activities_spec.rb
|
240
243
|
- spec/concerns/crud_custom_objects_spec.rb
|