marketo 1.2.5 → 1.3.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/marketo/client.rb +26 -0
- data/lib/marketo/lead_record.rb +3 -5
- data/spec/marketo/client_spec.rb +16 -25
- metadata +13 -14
data/lib/marketo/client.rb
CHANGED
@@ -111,6 +111,32 @@ module Rapleaf
|
|
111
111
|
end
|
112
112
|
end
|
113
113
|
|
114
|
+
def sync_lead_record_on_id(lead_record)
|
115
|
+
idnum = lead_record.idnum
|
116
|
+
raise 'lead record id not set' if idnum.nil?
|
117
|
+
|
118
|
+
begin
|
119
|
+
attributes = []
|
120
|
+
lead_record.each_attribute_pair do |name, value|
|
121
|
+
attributes << {:attr_name => name, :attr_type => 'string', :attr_value => value}
|
122
|
+
end
|
123
|
+
|
124
|
+
attributes << {:attr_name => 'Id', :attr_type => 'string', :attr_value => idnum.to_s}
|
125
|
+
|
126
|
+
response = send_request("ns1:paramsSyncLead", {
|
127
|
+
:return_lead => true,
|
128
|
+
:lead_record =>
|
129
|
+
{
|
130
|
+
:lead_attribute_list => { :attribute => attributes},
|
131
|
+
:id => idnum
|
132
|
+
}})
|
133
|
+
return LeadRecord.from_hash(response[:success_sync_lead][:result][:lead_record])
|
134
|
+
rescue Exception => e
|
135
|
+
@logger.log(e) if @logger
|
136
|
+
return nil
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|
114
140
|
def add_to_list(list_key, email)
|
115
141
|
list_operation(list_key, ListOperationType::ADD_TO, email)
|
116
142
|
end
|
data/lib/marketo/lead_record.rb
CHANGED
@@ -3,10 +3,9 @@ module Rapleaf
|
|
3
3
|
# Represents a record of the data known about a lead within marketo
|
4
4
|
class LeadRecord
|
5
5
|
def initialize(email, idnum = nil)
|
6
|
-
@email = email
|
7
6
|
@idnum = idnum
|
8
7
|
@attributes = {}
|
9
|
-
set_attribute('Email',
|
8
|
+
set_attribute('Email', email)
|
10
9
|
end
|
11
10
|
|
12
11
|
# hydrates an instance from a savon hash returned form the marketo API
|
@@ -25,7 +24,7 @@ module Rapleaf
|
|
25
24
|
|
26
25
|
# get the record email
|
27
26
|
def email
|
28
|
-
|
27
|
+
get_attribute('Email')
|
29
28
|
end
|
30
29
|
|
31
30
|
def attributes
|
@@ -51,8 +50,7 @@ module Rapleaf
|
|
51
50
|
|
52
51
|
def ==(other)
|
53
52
|
@attributes == other.attributes &&
|
54
|
-
@idnum == other.idnum
|
55
|
-
@email == other.email
|
53
|
+
@idnum == other.idnum
|
56
54
|
end
|
57
55
|
end
|
58
56
|
end
|
data/spec/marketo/client_spec.rb
CHANGED
@@ -148,36 +148,27 @@ module Rapleaf
|
|
148
148
|
}
|
149
149
|
expect_request(savon_client,
|
150
150
|
authentication_header,
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
:attr_type => "string"},
|
164
|
-
{:attr_value => EMAIL,
|
165
|
-
:attr_name => "Email",
|
166
|
-
:attr_type => "string"}
|
167
|
-
]}}}),
|
151
|
+
(Proc.new do |actual|
|
152
|
+
retval = true
|
153
|
+
retval = false unless actual[:return_lead]
|
154
|
+
retval = false unless actual[:lead_record][:email].equal?(EMAIL)
|
155
|
+
retval = false unless actual[:lead_record][:lead_attribute_list][:attribute].size == 5
|
156
|
+
retval = false unless actual[:lead_record][:lead_attribute_list][:attribute].include?({:attr_value => EMAIL, :attr_name => "Email", :attr_type => "string"})
|
157
|
+
retval = false unless actual[:lead_record][:lead_attribute_list][:attribute].include?({:attr_value => "val1", :attr_name => "name1", :attr_type => "string"})
|
158
|
+
retval = false unless actual[:lead_record][:lead_attribute_list][:attribute].include?({:attr_value => "val2", :attr_name => "name2", :attr_type => "string"})
|
159
|
+
retval = false unless actual[:lead_record][:lead_attribute_list][:attribute].include?({:attr_value => "val3", :attr_name => "name3", :attr_type => "string"})
|
160
|
+
retval = false unless actual[:lead_record][:lead_attribute_list][:attribute].include?({:attr_value => "val4", :attr_name => "name4", :attr_type => "string"})
|
161
|
+
retval.should == true
|
162
|
+
end),
|
168
163
|
'ns1:paramsSyncLead',
|
169
164
|
response_hash)
|
170
|
-
lead_record = LeadRecord.new(EMAIL)
|
165
|
+
lead_record = LeadRecord.new(EMAIL, IDNUM)
|
171
166
|
lead_record.set_attribute('name1', 'val1')
|
172
167
|
lead_record.set_attribute('name2', 'val2')
|
168
|
+
lead_record.set_attribute('name3', 'val3')
|
169
|
+
lead_record.set_attribute('name4', 'val4')
|
173
170
|
|
174
|
-
|
175
|
-
expected_lead_record.set_attribute('Email', EMAIL)
|
176
|
-
expected_lead_record.set_attribute('name1', 'val1')
|
177
|
-
expected_lead_record.set_attribute('name2', 'val2')
|
178
|
-
expected_lead_record.set_attribute('name3', 'val3')
|
179
|
-
expected_lead_record.set_attribute('name4', 'val4')
|
180
|
-
client.sync_lead_record(lead_record).should == expected_lead_record
|
171
|
+
client.sync_lead_record(lead_record).should == lead_record
|
181
172
|
end
|
182
173
|
|
183
174
|
it "should have the correct body format on sync_lead" do
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: marketo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
5
|
-
prerelease:
|
4
|
+
hash: 25
|
5
|
+
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
|
-
-
|
9
|
-
-
|
10
|
-
version: 1.
|
8
|
+
- 3
|
9
|
+
- 1
|
10
|
+
version: 1.3.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- James O'Brien
|
@@ -15,8 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date:
|
19
|
-
default_executable:
|
18
|
+
date: 2012-04-03 00:00:00 Z
|
20
19
|
dependencies:
|
21
20
|
- !ruby/object:Gem::Dependency
|
22
21
|
name: rspec
|
@@ -59,17 +58,16 @@ extensions: []
|
|
59
58
|
extra_rdoc_files: []
|
60
59
|
|
61
60
|
files:
|
62
|
-
- lib/marketo
|
63
|
-
- lib/marketo/client.rb
|
61
|
+
- lib/marketo.rb
|
64
62
|
- lib/marketo/enums.rb
|
63
|
+
- lib/marketo/client.rb
|
65
64
|
- lib/marketo/lead_key.rb
|
65
|
+
- lib/marketo/authentication_header.rb
|
66
66
|
- lib/marketo/lead_record.rb
|
67
|
-
- lib/marketo.rb
|
68
|
-
- spec/marketo/authentication_header_spec.rb
|
69
67
|
- spec/marketo/client_spec.rb
|
68
|
+
- spec/marketo/authentication_header_spec.rb
|
70
69
|
- spec/marketo/lead_key_spec.rb
|
71
70
|
- spec/marketo/lead_record_spec.rb
|
72
|
-
has_rdoc: true
|
73
71
|
homepage: https://www.rapleaf.com/developers/marketo
|
74
72
|
licenses: []
|
75
73
|
|
@@ -102,12 +100,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
102
100
|
requirements: []
|
103
101
|
|
104
102
|
rubyforge_project:
|
105
|
-
rubygems_version: 1.
|
103
|
+
rubygems_version: 1.8.11
|
106
104
|
signing_key:
|
107
105
|
specification_version: 3
|
108
106
|
summary: A client for using the marketo API
|
109
107
|
test_files:
|
110
|
-
- spec/marketo/authentication_header_spec.rb
|
111
108
|
- spec/marketo/client_spec.rb
|
109
|
+
- spec/marketo/authentication_header_spec.rb
|
112
110
|
- spec/marketo/lead_key_spec.rb
|
113
111
|
- spec/marketo/lead_record_spec.rb
|
112
|
+
has_rdoc: true
|