marketo-api-ruby 0.8 → 0.9

Sign up to get free protection for your applications and to get access to all the features.
data.tar.gz.sig CHANGED
@@ -1,2 +1,2 @@
1
- ^ �޼p��'*h⻖�2xX��"8��Qb���a� �ܑa�mٺ�$�s���OfB�~�.q_�`Ԗ=���!�$b�bGރ��n,l BndDO��E��������Gz]}��P@��LM���n��rO�e�j�3�)��^'���2o�ɤmra
2
- �׆����C��>�Cnc*3C~qs�j��7�平��TXg�!)B��Hbb��������a_ڌI�[� ��8��s��iG����.�c<t����
1
+ ���q��p+�����n�IU|њ�����IR–%�-�NiM��xnD�]�c��=A���fgCa�rQ*��MF'Yf�*�T�� iRh�k0>IJ��
2
+ ?����Y����1Ib����@LOkr���P�����/�[P/���j�ʙ���cļŠ@T+��i .���xŊ���#� 6ktϧ�28{���<�wR'���U^��0�O}��K�~�%�[��}�p±P�<��
@@ -0,0 +1,2 @@
1
+ ---
2
+ service_name: travis-ci
data/.hoerc ADDED
@@ -0,0 +1,2 @@
1
+ ---
2
+ exclude: !ruby/regexp /(tmp|swp)$|CVS|TAGS|\.(svn|git|hg|DS_Store|idea)|Gemfile\.lock|type-lists\/|\.gemspec/
@@ -0,0 +1,33 @@
1
+ ---
2
+ language: ruby
3
+ rvm:
4
+ - 2.1.0
5
+ - 2.0.0
6
+ - 1.9.3
7
+ - ruby-head
8
+ - jruby-19mode
9
+ - jruby-head
10
+ - rbx-2
11
+ matrix:
12
+ allow_failures:
13
+ - rvm:
14
+ - rbx-2
15
+ gemfile:
16
+ - Gemfile
17
+ before_script:
18
+ - |
19
+ case "${TRAVIS_RUBY_VERSION}" in
20
+ rbx*)
21
+ gem install psych
22
+ ;;
23
+ esac
24
+ - rake travis:before -t
25
+ script: rake travis
26
+ after_script:
27
+ - rake travis:after -t
28
+ notifications:
29
+ recipients:
30
+ - austin@clearfit.com
31
+ email:
32
+ - on_success: change
33
+ - on_failure: always
@@ -1,3 +1,14 @@
1
+ === 0.9 / 2014-MM-DD
2
+
3
+ * Bug Fixes:
4
+ * Fix #15, where Marketo uses inconsistent camelcasing.
5
+
6
+ * Infrastructure:
7
+ * While marketo-api-ruby may work on 1.9.2, it's being removed from Travis
8
+ due to ongoing test failures that I can't replicate (I can't get a 1.9.2
9
+ Ruby built, and it's no longer a supported Ruby in any case).
10
+ * Fixed rbx tests.
11
+
1
12
  === 0.8 / 2014-04-08
2
13
 
3
14
  * First release as marketo-api-ruby. Features a substantially restructured API.
@@ -1,4 +1,7 @@
1
+ .coveralls.yml
1
2
  .gemtest
3
+ .hoerc
4
+ .travis.yml
2
5
  Contributing.rdoc
3
6
  Gemfile
4
7
  History.rdoc
@@ -16,11 +19,6 @@ lib/marketo_api/leads.rb
16
19
  lib/marketo_api/lists.rb
17
20
  lib/marketo_api/mobject.rb
18
21
  lib/marketo_api/mobjects.rb
19
- spec/marketo/authentication_header_spec.rb
20
- spec/marketo/client_spec.rb
21
- spec/marketo/lead_key_spec.rb
22
- spec/marketo/lead_record_spec.rb
23
- spec/spec_helper.rb
24
22
  test/marketo_api/test_campaigns.rb
25
23
  test/marketo_api/test_client.rb
26
24
  test/marketo_api/test_lead.rb
@@ -15,8 +15,13 @@ MarketoAPI (marketo-api-ruby) provides a native Ruby interface to the
15
15
  API is necessary for using marketo-api-ruby, it is an explicit goal that
16
16
  working with MarketoAPI not feel like working with a hinky Java port.
17
17
 
18
- This is release 0.8, targeting Marketo API version
19
- {2.3}[http://app.marketo.com/soap/mktows/2_3?WSDL].
18
+ This is release 0.9, targeting Marketo API version
19
+ {2.3}[http://app.marketo.com/soap/mktows/2_3?WSDL], fixing a +syncLead+ problem
20
+ where +Id+, +Email+, and +ForeignSysPersonId+ are inconsistent with other
21
+ +syncLead+ parameters.
22
+
23
+ Please note that Ruby 1.9.2 is not officially supported, but MarketoAPI will
24
+ install on any version of Ruby 1.9.2 or later.
20
25
 
21
26
  === Features/Problems
22
27
 
@@ -6,7 +6,7 @@
6
6
  #
7
7
  # require 'marketo_api'
8
8
  module MarketoAPI
9
- VERSION = "0.8"
9
+ VERSION = "0.9"
10
10
 
11
11
  MINIMIZE_HASH = ->(k, v) { #:nodoc:
12
12
  v.nil? or (v.respond_to?(:empty?) and v.empty?)
@@ -18,6 +18,13 @@ class MarketoAPI::Campaigns < MarketoAPI::ClientProxy
18
18
  ENUMS = MarketoAPI.freeze(*SOURCES.values) #:nodoc:
19
19
  private_constant :ENUMS
20
20
 
21
+ REQUEST_PARAM_XF = { #:nodoc:
22
+ campaign_id: :campaignId,
23
+ campaign_name: :campaignName,
24
+ program_name: :programName,
25
+ }
26
+ private_constant :REQUEST_PARAM_XF
27
+
21
28
  # Implements
22
29
  # {+getCampaignsForSource+}[http://developers.marketo.com/documentation/soap/getcampaignsforsource/].
23
30
  #
@@ -33,7 +40,7 @@ class MarketoAPI::Campaigns < MarketoAPI::ClientProxy
33
40
  {
34
41
  source: resolve_source(source),
35
42
  name: name,
36
- exact_name: exact_name
43
+ exactName: exact_name
37
44
  }.delete_if(&MarketoAPI::MINIMIZE_HASH)
38
45
  )
39
46
  end
@@ -115,12 +122,14 @@ class MarketoAPI::Campaigns < MarketoAPI::ClientProxy
115
122
  end
116
123
  end
117
124
 
125
+ REQUEST_PARAM_XF.each { |o, n| options[n] = options.delete(o) }
126
+
118
127
  call(
119
- :request_campaign,
128
+ :RequestCampaign,
120
129
  options.merge(
121
- source: resolve_source(source),
122
- lead_list: transform_param_list(:get, leads),
123
- program_token_list: tokens
130
+ source: resolve_source(source),
131
+ leadList: transform_param_list(:get, leads),
132
+ programTokenList: tokens
124
133
  ).delete_if(&MarketoAPI::MINIMIZE_HASH)
125
134
  )
126
135
  end
@@ -160,12 +169,12 @@ class MarketoAPI::Campaigns < MarketoAPI::ClientProxy
160
169
  # schedule(program_name, campaign_name, options = {})
161
170
  def schedule(program_name, campaign_name, options = {})
162
171
  call(
163
- :schedule_campaign,
172
+ :ScheduleCampaign,
164
173
  {
165
- program_name: program_name,
166
- campaign_name: campaign_name,
167
- campaign_run_at: options[:run_at],
168
- program_token_list: options[:program_tokens]
174
+ programName: program_name,
175
+ campaignName: campaign_name,
176
+ campaignRunAt: options[:run_at],
177
+ programTokenList: options[:program_tokens]
169
178
  }.delete_if(&MarketoAPI::MINIMIZE_HASH)
170
179
  )
171
180
  end
@@ -5,17 +5,18 @@ require 'openssl'
5
5
  # The client to the Marketo SOAP API.
6
6
  class MarketoAPI::Client
7
7
  DEFAULT_CONFIG = {
8
- api_subdomain: '123-ABC-456',
9
- api_version: '2_3',
10
- user_id: nil,
11
- encryption_key: nil,
12
- read_timeout: 90,
13
- open_timeout: 90,
14
- headers: { 'Connection' => 'Keep-Alive' },
15
- env_namespace: 'SOAP-ENV',
16
- namespaces: { 'xmlns:ns1' => 'http://www.marketo.com/mktows/' },
17
- pretty_print_xml: true,
18
- ssl_verify_mode: :none,
8
+ api_subdomain: '123-ABC-456',
9
+ api_version: '2_3',
10
+ user_id: nil,
11
+ encryption_key: nil,
12
+ read_timeout: 90,
13
+ open_timeout: 90,
14
+ headers: { 'Connection' => 'Keep-Alive' },
15
+ env_namespace: 'SOAP-ENV',
16
+ namespaces: { 'xmlns:ns1' => 'http://www.marketo.com/mktows/' },
17
+ pretty_print_xml: true,
18
+ ssl_verify_mode: :none,
19
+ convert_request_keys_to: :none,
19
20
  }.freeze
20
21
  DEFAULT_CONFIG.values.each(&:freeze)
21
22
  private_constant :DEFAULT_CONFIG
@@ -192,19 +192,19 @@ class MarketoAPI::Lead
192
192
  # Returns the parameters required for use with MarketoAPI::Leads#sync.
193
193
  def params_for_sync
194
194
  {
195
- return_lead: true,
196
- marketo_cookie: cookie,
197
- lead_record: {
198
- email: email,
199
- id: id,
200
- foreign_sys_person_id: foreign[:id],
201
- foreign_sys_type: foreign[:type],
202
- lead_attribute_list: {
195
+ returnLead: true,
196
+ marketoCookie: cookie,
197
+ leadRecord: {
198
+ Email: email,
199
+ Id: id,
200
+ ForeignSysPersonId: foreign[:id],
201
+ ForeignSysType: foreign[:type],
202
+ leadAttributeList: {
203
203
  attribute: attributes.map { |key, value|
204
204
  {
205
- attr_name: key.to_s,
206
- attr_type: types[key],
207
- attr_value: value
205
+ attrName: key.to_s,
206
+ attrType: types[key],
207
+ attrValue: value
208
208
  }
209
209
  }
210
210
  }
@@ -234,9 +234,9 @@ class MarketoAPI::Lead
234
234
  # API calls.
235
235
  def key(key, value)
236
236
  {
237
- lead_key: {
238
- key_type: key_type(key),
239
- key_value: value
237
+ leadKey: {
238
+ keyType: key_type(key),
239
+ keyValue: value
240
240
  }
241
241
  }
242
242
  end
@@ -13,8 +13,8 @@ class MarketoAPI::Leads < MarketoAPI::ClientProxy
13
13
  def get(type_or_key, value = nil)
14
14
  key = case type_or_key
15
15
  when Hash
16
- if lk = type_or_key[:lead_key]
17
- if MarketoAPI::Lead.send(:key_type, lk[:key_type])
16
+ if lk = type_or_key[:leadKey]
17
+ if MarketoAPI::Lead.send(:key_type, lk[:keyType])
18
18
  type_or_key
19
19
  end
20
20
  end
@@ -25,7 +25,7 @@ class MarketoAPI::Leads < MarketoAPI::ClientProxy
25
25
  end
26
26
 
27
27
  unless key
28
- raise ArgumentError, ':type_or_key is not a valid lead key'
28
+ raise ArgumentError, "#{type_or_key} is not a valid lead key"
29
29
  end
30
30
  extract_from_response(call(:get_lead, key), :lead_record_list) { |record|
31
31
  MarketoAPI::Lead.from_soap_hash(record[:lead_record]) do |lead|
@@ -64,8 +64,8 @@ class MarketoAPI::Leads < MarketoAPI::ClientProxy
64
64
  def sync_multiple(leads, options = { dedup_enabled: true })
65
65
  response = call(
66
66
  :sync_multiple_leads,
67
- dedup_enabled: options[:dedup_enabled],
68
- lead_record_list: transform_param_list(:sync, leads)
67
+ dedupEnabled: options[:dedup_enabled],
68
+ leadRecordList: transform_param_list(:sync, leads)
69
69
  )
70
70
  extract_from_response(response, :lead_record_list) do |list|
71
71
  list.each do |record|
@@ -71,9 +71,9 @@ class MarketoAPI::Lists < MarketoAPI::ClientProxy
71
71
  class << self
72
72
  def key(type, value)
73
73
  {
74
- list_key: {
75
- key_type: key_type(type),
76
- key_value: value
74
+ listKey: {
75
+ keyType: key_type(type),
76
+ keyValue: value
77
77
  }
78
78
  }
79
79
  end
@@ -100,10 +100,10 @@ class MarketoAPI::Lists < MarketoAPI::ClientProxy
100
100
 
101
101
  call(
102
102
  :list_operation,
103
- list_operation: operation,
104
- list_key: list_key,
105
- strict: false,
106
- list_member_list: transform_param_list(:get, leads)
103
+ listOperation: operation,
104
+ listKey: list_key,
105
+ strict: false,
106
+ listMemberList: transform_param_list(:get, leads)
107
107
  )
108
108
  end
109
109
  end
@@ -121,12 +121,13 @@ class MarketoAPI::MObject
121
121
  def params_for_get #:nodoc:
122
122
  ensure_valid_type!(type, GET_TYPES)
123
123
  {
124
- type: type,
125
- id: id,
126
- include_details: include_details,
127
- m_obj_criteria_list: criteria.compact.uniq.map(&:to_h),
128
- m_obj_association_list: associations.compact.uniq.map(&:to_h),
129
- stream_position: stream_position
124
+ type: type,
125
+ id: id,
126
+ includeDetails: include_details,
127
+ mObjCriteriaList: criteria.compact.uniq.map(&:to_h),
128
+ mObjAssociationList: associations.compact.uniq.map(&:to_h),
129
+ streamPosition: stream_position,
130
+ externalKey: nil
130
131
  }.delete_if(&MarketoAPI::MINIMIZE_HASH)
131
132
  end
132
133
 
@@ -214,9 +215,9 @@ class MarketoAPI::MObject
214
215
 
215
216
  def to_h
216
217
  {
217
- attr_name: name,
218
- attr_value: value,
219
- comparison: comparison
218
+ attrName: name,
219
+ attrValue: value,
220
+ comparison: comparison
220
221
  }
221
222
  end
222
223
  end
@@ -255,9 +256,9 @@ class MarketoAPI::MObject
255
256
 
256
257
  def to_h
257
258
  {
258
- m_obj_type: type,
259
- id: id,
260
- external_key: external_key,
259
+ mObjType: type,
260
+ id: id,
261
+ externalKey: external_key,
261
262
  }
262
263
  end
263
264
  end
@@ -22,7 +22,7 @@ class MarketoAPI::MObjects < MarketoAPI::ClientProxy
22
22
  end
23
23
  response = call(
24
24
  :delete_m_objects,
25
- m_object_list: transform_param_list(__method__, mobjects)
25
+ mObjectList: transform_param_list(__method__, mobjects)
26
26
  )
27
27
  extract_mobject_status_list(response)
28
28
  end
@@ -47,7 +47,7 @@ class MarketoAPI::MObjects < MarketoAPI::ClientProxy
47
47
  end
48
48
 
49
49
  extract_from_response(
50
- call(:describe_m_object, object_name: name),
50
+ call(:describe_m_object, objectName: name),
51
51
  :metadata
52
52
  )
53
53
  end
@@ -69,7 +69,7 @@ class MarketoAPI::MObjects < MarketoAPI::ClientProxy
69
69
  def sync(operation, *mobjects) #:nodoc:
70
70
  # http://developers.marketo.com/documentation/soap/sync-mobjects/
71
71
  raise NotImplementedError,
72
- ":sync_m_objects is not implemented in this version."
72
+ ":syncMObjects is not implemented in this version."
73
73
  response = call(
74
74
  :sync_m_objects,
75
75
  transform_param_list(__method__, mobjects)
@@ -48,7 +48,7 @@ class TestMarketoAPICampaigns < Minitest::Test
48
48
  stub_soap_call do
49
49
  method, options = subject.for_source :marketo, 'John', true
50
50
  assert_equal :get_campaigns_for_source, method
51
- assert_equal({ source: :MKTOWS, name: 'John', exact_name: true },
51
+ assert_equal({ source: :MKTOWS, name: 'John', exactName: true },
52
52
  options)
53
53
  end
54
54
  end
@@ -70,31 +70,34 @@ class TestMarketoAPICampaigns < Minitest::Test
70
70
  end
71
71
 
72
72
  def test_request_missing_leads
73
- assert_raises(ArgumentError) {
73
+ assert_raises_with_message(ArgumentError, ':lead or :leads must be provided') {
74
74
  subject.request
75
75
  }
76
76
  end
77
77
 
78
78
  def test_request_missing_campaign_or_program
79
- assert_raises(ArgumentError) {
79
+ assert_raises(ArgumentError,
80
+ ':campaignId, :campaignName, or :programName must be provided') {
80
81
  subject.request(lead: :foo)
81
82
  }
82
83
  end
83
84
 
84
- def test_request_program_token_with_no_program_name
85
- assert_raises(KeyError) {
85
+ def test_request_program_tokens_with_no_program_name
86
+ assert_raises_with_message(KeyError,
87
+ ':program_name must be provided when using :program_tokens') {
86
88
  subject.request(lead: :foo, campaign_id: 5, program_tokens: [ 3 ])
87
89
  }
88
90
  end
89
91
 
90
92
  def test_request_with_campaign_id_and_name
91
- assert_raises(ArgumentError) {
93
+ assert_raises_with_message(ArgumentError,
94
+ ':campaign_id and :campaign_name are mutually exclusive') {
92
95
  subject.request(lead: :foo, campaign_id: 5, campaign_name: 'Five')
93
96
  }
94
97
  end
95
98
 
96
99
  def test_request_bad_source
97
- assert_raises(ArgumentError) {
100
+ assert_raises_with_message(ArgumentError, 'Invalid source bad_source') {
98
101
  subject.request(lead: :foo, campaign_id: 5, source: :bad_source)
99
102
  }
100
103
  end
@@ -104,12 +107,13 @@ class TestMarketoAPICampaigns < Minitest::Test
104
107
  method, options = subject.request(lead: lead_key(3),
105
108
  leads: lead_keys(4, 5),
106
109
  campaign_id: 3)
107
- assert_equal :request_campaign, method
110
+ assert_equal :RequestCampaign, method
111
+ refute_missing_keys options, :source, :leadList, :campaignId
108
112
  assert_equal :MKTOWS, options[:source]
109
- assert_equal lead_keys(4, 5, 3), options[:lead_list]
110
- assert_equal 3, options[:campaign_id]
111
- assert_missing_keys options, :campaign_name, :program_name,
112
- :program_tokens
113
+ assert_equal lead_keys(4, 5, 3), options[:leadList]
114
+ assert_equal 3, options[:campaignId]
115
+ assert_missing_keys options, :campaignName, :programName,
116
+ :programTokens
113
117
  end
114
118
  end
115
119
 
@@ -117,12 +121,12 @@ class TestMarketoAPICampaigns < Minitest::Test
117
121
  stub_soap_call do
118
122
  method, options = subject.request(lead: lead_key(3),
119
123
  campaign_name: 'earthday')
120
- assert_equal :request_campaign, method
124
+ assert_equal :RequestCampaign, method
121
125
  assert_equal :MKTOWS, options[:source]
122
- assert_equal [ lead_key(3) ], options[:lead_list]
123
- assert_equal 'earthday', options[:campaign_name]
124
- assert_missing_keys options, :campaign_id, :program_name,
125
- :program_tokens
126
+ assert_equal [ lead_key(3) ], options[:leadList]
127
+ assert_equal 'earthday', options[:campaignName]
128
+ assert_missing_keys options, :campaignId, :programName,
129
+ :programTokens
126
130
  end
127
131
  end
128
132
 
@@ -130,31 +134,32 @@ class TestMarketoAPICampaigns < Minitest::Test
130
134
  stub_soap_call do
131
135
  method, options = subject.request(lead: lead_key(3),
132
136
  program_name: 'earthday')
133
- assert_equal :request_campaign, method
137
+ assert_equal :RequestCampaign, method
138
+ refute_missing_keys options, :source, :leadList, :programName
134
139
  assert_equal :MKTOWS, options[:source]
135
- assert_equal [ lead_key(3) ], options[:lead_list]
136
- assert_equal 'earthday', options[:program_name]
137
- assert_missing_keys options, :campaign_name, :campaign_id,
138
- :program_tokens
140
+ assert_equal [ lead_key(3) ], options[:leadList]
141
+ assert_equal 'earthday', options[:programName]
142
+ assert_missing_keys options, :campaignName, :campaignId,
143
+ :programTokens
139
144
  end
140
145
  end
141
146
 
142
147
  def test_schedule
143
148
  stub_soap_call do
144
149
  method, options = subject.schedule('program', 'campaign')
145
- assert_equal :schedule_campaign, method
146
- assert_equal({ program_name: 'program', campaign_name: 'campaign' }, options)
150
+ assert_equal :ScheduleCampaign, method
151
+ assert_equal({ programName: 'program', campaignName: 'campaign' }, options)
147
152
  end
148
153
  end
149
154
 
150
155
  def test_schedule_with_run_at
151
156
  stub_soap_call do
152
157
  method, options = subject.schedule('program', 'campaign', run_at: 3)
153
- assert_equal :schedule_campaign, method
158
+ assert_equal :ScheduleCampaign, method
154
159
  assert_equal({
155
- program_name: 'program',
156
- campaign_name: 'campaign',
157
- campaign_run_at: 3
160
+ programName: 'program',
161
+ campaignName: 'campaign',
162
+ campaignRunAt: 3
158
163
  }, options)
159
164
  end
160
165
  end
@@ -162,11 +167,11 @@ class TestMarketoAPICampaigns < Minitest::Test
162
167
  def test_schedule_with_program_tokens
163
168
  stub_soap_call do
164
169
  method, options = subject.schedule('program', 'campaign', program_tokens: [ :x ])
165
- assert_equal :schedule_campaign, method
170
+ assert_equal :ScheduleCampaign, method
166
171
  assert_equal({
167
- program_name: 'program',
168
- campaign_name: 'campaign',
169
- program_token_list: [ :x ]
172
+ programName: 'program',
173
+ campaignName: 'campaign',
174
+ programTokenList: [ :x ]
170
175
  }, options)
171
176
  end
172
177
  end