markety 2.2.0 → 2.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 579d0ef7b9f8d678e9e8b1d8933f75bb5766a84a
4
- data.tar.gz: 2b5f5c737cd5337783c8c57942c105bfcb75bc3f
3
+ metadata.gz: a79839fea206fe31310530563f8d22a2db6fa7c1
4
+ data.tar.gz: 3a293a9a3ae68ef163d92e8992787053c38451d3
5
5
  SHA512:
6
- metadata.gz: f751d4ffc7fe0d458f6bcecd4b849300fa29ede30c168a156c3cff634c8d84c1aa77307655023cbe9881af1b66eef49e4067d6faf7686ca6eed0aaf065485ec7
7
- data.tar.gz: 5aac57074bcb70e5952d60cfe7cc689f36de923de0b7a1358f27af1cfde7d50b655009e59c1aa517997b5f6b08c916df6e9af8cedfb6958c6f8a8585f9a0c78b
6
+ metadata.gz: 522ed97102cdbd68b4f4c63ff2378dbbd168460fa47d736fb64827279dc2763332ef6a783efbcefbe9f3623b8eaea72ebb693765e1a1263b245d7a1fd3538ba9
7
+ data.tar.gz: 2a6089896d245175942dca6373a0136ca110d7456a88fdfae57cacbba0e86d262d51c5c1c67036e6ed76508209bd22ee640eb269be89f4cba65cc9350191fa29
@@ -25,7 +25,7 @@ module Markety
25
25
  namespaces({"xmlns:ns1" => "http://www.marketo.com/mktows/"})
26
26
  env_namespace "SOAP-ENV"
27
27
  pretty_print_xml true
28
- log false if options[:log] == false
28
+ log options.fetch(:log, false)
29
29
  end
30
30
 
31
31
  @auth_header = Markety::AuthenticationHeader.new(access_key, secret_key)
@@ -2,11 +2,28 @@ module Markety
2
2
  module Command
3
3
  module SyncCustomObject
4
4
  def sync_custom_object(custom_object, operation="UPSERT")
5
+ sync_custom_objects_request(custom_object.object_type_name, operation, custom_object.to_sync_custom_object_hash)
6
+ end
7
+
8
+ def sync_custom_objects(custom_objects, operation="UPSERT")
9
+ object_type_name = custom_objects.first.object_type_name
10
+ sync_custom_objects_request(object_type_name, operation, multiple_custom_obj_params(custom_objects))
11
+ end
12
+
13
+ private
14
+
15
+ def multiple_custom_obj_params(custom_objects)
16
+ custom_objects.map{|custom_object| custom_object.to_sync_custom_object_hash}
17
+ end
18
+
19
+ def sync_custom_objects_request(object_type_name, operation, custom_obj_list)
5
20
  send_request(:sync_custom_objects,
6
21
  {
7
- "objTypeName" => custom_object.object_type_name,
22
+ "objTypeName" => object_type_name,
8
23
  "operation" => operation,
9
- "customObjList" => custom_object.to_sync_custom_object_hash
24
+ "customObjList" => {
25
+ "customObj" => custom_obj_list
26
+ }
10
27
  }
11
28
  )
12
29
  end
@@ -15,11 +15,8 @@ module Markety
15
15
 
16
16
  def to_sync_custom_object_hash
17
17
  {
18
- "customObj" =>
19
- {
20
- "customObjKeyList" => key_list,
21
- "customObjAttributeList" => attribute_list
22
- }
18
+ "customObjKeyList" => key_list,
19
+ "customObjAttributeList" => attribute_list
23
20
  }
24
21
  end
25
22
 
@@ -9,19 +9,16 @@ module Markety
9
9
  end
10
10
 
11
11
  def success?
12
- @success && !failed?
12
+ @success
13
13
  end
14
14
 
15
- def status
16
- @status ||= custom_obj_hash[:status]
17
- end
18
-
19
- def error_message
20
- @error_message ||= custom_obj_hash[:error]
21
- end
22
-
23
- def updated_custom_object
24
- CustomObject.from_marketo_hash(object_type_name, custom_obj_hash) if success?
15
+ def custom_objects
16
+ return [] unless success?
17
+ @custom_objects ||= begin
18
+ custom_obj_hash.map do |single_custom_obj_hash|
19
+ CustomObject.from_marketo_hash(object_type_name, single_custom_obj_hash)
20
+ end
21
+ end
25
22
  end
26
23
 
27
24
  private
@@ -31,11 +28,11 @@ module Markety
31
28
  end
32
29
 
33
30
  def object_type_name
34
- @object_type_name ||= custom_obj_hash[:obj_type_name]
31
+ @object_type_name ||= custom_obj_hash.first.fetch(:obj_type_name)
35
32
  end
36
33
 
37
34
  def custom_obj_hash
38
- to_hash[:success_sync_custom_objects][:result][:sync_custom_obj_status_list][:sync_custom_obj_status]
35
+ [to_hash[:success_sync_custom_objects][:result][:sync_custom_obj_status_list][:sync_custom_obj_status]].flatten
39
36
  end
40
37
 
41
38
  end
@@ -1,3 +1,3 @@
1
1
  module Markety
2
- VERSION = "2.2.0"
2
+ VERSION = "2.2.1"
3
3
  end
@@ -0,0 +1,45 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ns1="http://www.marketo.com/mktows/">
3
+ <SOAP-ENV:Body>
4
+ <ns1:successSyncCustomObjects>
5
+ <result>
6
+ <syncCustomObjStatusList>
7
+ <syncCustomObjStatus>
8
+ <objTypeName>Roadshow</objTypeName>
9
+ <customObjKeyList>
10
+ <attribute>
11
+ <attrName>MKTOID</attrName>
12
+ <attrType xsi:nil="true" />
13
+ <attrValue>1090177</attrValue>
14
+ </attribute>
15
+ <attribute>
16
+ <attrName>rid</attrName>
17
+ <attrType xsi:nil="true" />
18
+ <attrValue>rid1</attrValue>
19
+ </attribute>
20
+ </customObjKeyList>
21
+ <status>UPDATED</status>
22
+ <error xsi:nil="true" />
23
+ </syncCustomObjStatus>
24
+ <syncCustomObjStatus>
25
+ <objTypeName>Roadshow</objTypeName>
26
+ <customObjKeyList>
27
+ <attribute>
28
+ <attrName>MKTOID</attrName>
29
+ <attrType xsi:nil="true" />
30
+ <attrValue>1090178</attrValue>
31
+ </attribute>
32
+ <attribute>
33
+ <attrName>rid</attrName>
34
+ <attrType xsi:nil="true" />
35
+ <attrValue>rid2</attrValue>
36
+ </attribute>
37
+ </customObjKeyList>
38
+ <status>UPDATED</status>
39
+ <error xsi:nil="true" />
40
+ </syncCustomObjStatus>
41
+ </syncCustomObjStatusList>
42
+ </result>
43
+ </ns1:successSyncCustomObjects>
44
+ </SOAP-ENV:Body>
45
+ </SOAP-ENV:Envelope>
@@ -12,7 +12,7 @@ module Markety
12
12
  custom_object = double(CustomObject, object_type_name: "type", to_sync_custom_object_hash: {"custom_object" => "hash"})
13
13
  client.extend(SyncCustomObject)
14
14
  client.sync_custom_object(custom_object)
15
- expect(client).to have_received(:send_request).with(:sync_custom_objects, {"objTypeName" => "type", "operation" => "UPSERT", "customObjList" => {"custom_object" => "hash"}})
15
+ expect(client).to have_received(:send_request).with(:sync_custom_objects, {"objTypeName" => "type", "operation" => "UPSERT", "customObjList" => {"customObj" => {"custom_object" => "hash"}}})
16
16
  end
17
17
  end
18
18
  context "without an operation" do
@@ -20,7 +20,29 @@ module Markety
20
20
  custom_object = double(CustomObject, object_type_name: "type", to_sync_custom_object_hash: {"custom_object" => "hash"})
21
21
  client.extend(SyncCustomObject)
22
22
  client.sync_custom_object(custom_object, "INSERT")
23
- expect(client).to have_received(:send_request).with(:sync_custom_objects, {"objTypeName" => "type", "operation" => "INSERT", "customObjList" => {"custom_object" => "hash"}})
23
+ expect(client).to have_received(:send_request).with(:sync_custom_objects, {"objTypeName" => "type", "operation" => "INSERT", "customObjList" => {"customObj" => {"custom_object" => "hash"}}})
24
+ end
25
+ end
26
+ end
27
+
28
+ describe '#sync_custom_objects' do
29
+ context "without an operation" do
30
+ it "calls send_request on the client with the correct params and defaults to UPSERT" do
31
+ custom_object1 = double(CustomObject, object_type_name: "type", to_sync_custom_object_hash: {"custom_object" => "hash"})
32
+ custom_object2 = double(CustomObject, object_type_name: "type", to_sync_custom_object_hash: {"custom_object" => "hash2"})
33
+ client.extend(SyncCustomObject)
34
+ client.sync_custom_objects([custom_object1, custom_object2])
35
+ expect(client).to have_received(:send_request).with(:sync_custom_objects, {"objTypeName" => "type", "operation" => "UPSERT", "customObjList" => {"customObj" => [{"custom_object" => "hash"}, {"custom_object" => "hash2"}]}})
36
+ end
37
+ end
38
+
39
+ context "with an operation" do
40
+ it "calls send_request on the client with the operation" do
41
+ custom_object1 = double(CustomObject, object_type_name: "type", to_sync_custom_object_hash: {"custom_object" => "hash"})
42
+ custom_object2 = double(CustomObject, object_type_name: "type", to_sync_custom_object_hash: {"custom_object" => "hash2"})
43
+ client.extend(SyncCustomObject)
44
+ client.sync_custom_objects([custom_object1, custom_object2], "INSERT")
45
+ expect(client).to have_received(:send_request).with(:sync_custom_objects, {"objTypeName" => "type", "operation" => "INSERT", "customObjList" => {"customObj" => [{"custom_object" => "hash"}, {"custom_object" => "hash2"}]}})
24
46
  end
25
47
  end
26
48
  end
@@ -39,19 +39,17 @@ module Markety
39
39
  attributes: {"name" => "Some Roadshow", "anotherAttribute" => "Bananas"})
40
40
 
41
41
  expect(custom_object.to_sync_custom_object_hash).to eq({
42
- "customObj" => {
43
- "customObjKeyList" => {
44
- "attribute" => [
45
- {"attrName" => "MKTOID", "attrValue" => 123},
46
- {"attrName" => "rid", "attrValue" => 345}
47
- ]
48
- },
49
- "customObjAttributeList" => {
50
- "attribute" => [
51
- {"attrName" => "name", "attrValue" => "Some Roadshow"},
52
- {"attrName" => "anotherAttribute", "attrValue" => "Bananas"},
53
- ]
54
- }
42
+ "customObjKeyList" => {
43
+ "attribute" => [
44
+ {"attrName" => "MKTOID", "attrValue" => 123},
45
+ {"attrName" => "rid", "attrValue" => 345}
46
+ ]
47
+ },
48
+ "customObjAttributeList" => {
49
+ "attribute" => [
50
+ {"attrName" => "name", "attrValue" => "Some Roadshow"},
51
+ {"attrName" => "anotherAttribute", "attrValue" => "Bananas"},
52
+ ]
55
53
  }
56
54
  })
57
55
  end
@@ -4,65 +4,53 @@ module Markety
4
4
  module Response
5
5
  describe SyncCustomObjectResponse do
6
6
  let (:successful_response) {SavonHelper.create_response(File.read(File.expand_path("../../../fixtures/custom_objects/sync_custom_objects/successful_sync.xml", __FILE__)))}
7
- let (:failed_response) {SavonHelper.create_response(File.read(File.expand_path("../../../fixtures/custom_objects/sync_custom_objects/unknown_attribute.xml", __FILE__)))}
7
+ let (:successful_multiple_sync_response) {SavonHelper.create_response(File.read(File.expand_path("../../../fixtures/custom_objects/sync_custom_objects/multiple_syncs.xml", __FILE__)))}
8
+ let (:failed_response) {SavonHelper.create_response(File.read(File.expand_path("../../../fixtures/custom_objects/sync_custom_objects/invalid_object_name.xml", __FILE__)))}
8
9
 
9
10
  describe "#success?" do
10
- context "with a successful response" do
11
+ context "with a successful response with a single sync" do
11
12
  it "returns true" do
12
13
  response = SyncCustomObjectResponse.new(successful_response)
13
14
  expect(response.success?).to eq true
14
15
  end
15
16
  end
16
- context "with a failed response" do
17
- it "returns false" do
18
- response = SyncCustomObjectResponse.new(failed_response)
19
- expect(response.success?).to eq false
20
- end
21
- end
22
- end
23
-
24
- describe "#error_message" do
25
- context "with a successful response" do
26
- it "returns nil" do
27
- response = SyncCustomObjectResponse.new(successful_response)
28
- expect(response.error_message).to be_nil
17
+ context "with a successful response with multiple syncs" do
18
+ it "returns true" do
19
+ response = SyncCustomObjectResponse.new(successful_multiple_sync_response)
20
+ expect(response.success?).to eq true
29
21
  end
30
22
  end
31
23
  context "with a failed response" do
32
- it "returns the error" do
24
+ it "returns false" do
33
25
  response = SyncCustomObjectResponse.new(failed_response)
34
- expect(response.error_message).to eq "Unknown name attribute list: nameasdf"
26
+ expect(response.success?).to eq false
35
27
  end
36
28
  end
37
29
  end
38
30
 
39
- describe "#status" do
40
- context "with a successful response" do
41
- it "returns nil" do
31
+ describe "#custom_objects" do
32
+ context "with a successful response with a single sync" do
33
+ it "returns the custom object" do
42
34
  response = SyncCustomObjectResponse.new(successful_response)
43
- expect(response.status).to eq "UPDATED"
44
- end
45
- end
46
- context "with a failed response" do
47
- it "returns the status failed" do
48
- response = SyncCustomObjectResponse.new(failed_response)
49
- expect(response.status).to eq "FAILED"
35
+ custom_objects = response.custom_objects
36
+ expect(custom_objects.size).to eq 1
37
+ expect(custom_objects.first.object_type_name).to eq "Roadshow"
38
+ expect(custom_objects.first.keys).to eq({"MKTOID" => "1090177", "rid" => "rid1"})
50
39
  end
51
40
  end
52
- end
53
-
54
- describe "#updated_custom_object" do
55
- context "with a successful response" do
56
- it "returns the custom object" do
57
- response = SyncCustomObjectResponse.new(successful_response)
58
- expect(response.updated_custom_object.object_type_name).to eq "Roadshow"
59
- expect(response.updated_custom_object.keys).to eq({"MKTOID" => "1090177", "rid" => "rid1"})
41
+ context "with a successful response with multiple syncs" do
42
+ it "returns multiple custom objects" do
43
+ response = SyncCustomObjectResponse.new(successful_multiple_sync_response)
44
+ custom_objects = response.custom_objects
45
+ expect(custom_objects.size).to eq 2
46
+ expect(custom_objects[1].object_type_name).to eq "Roadshow"
47
+ expect(custom_objects[1].keys).to eq({"MKTOID" => "1090178", "rid" => "rid2"})
60
48
  end
61
49
  end
62
50
  context "with a failed response" do
63
51
  it "returns nil" do
64
52
  response = SyncCustomObjectResponse.new(failed_response)
65
- expect(response.updated_custom_object).to be_nil
53
+ expect(response.custom_objects).to eq []
66
54
  end
67
55
  end
68
56
  end
metadata CHANGED
@@ -1,117 +1,117 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: markety
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.0
4
+ version: 2.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Santoso
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-26 00:00:00.000000000 Z
11
+ date: 2015-04-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ~>
18
18
  - !ruby/object:Gem::Version
19
19
  version: '1.6'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ~>
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.6'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ">="
31
+ - - '>='
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ">="
38
+ - - '>='
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rspec
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - "~>"
45
+ - - ~>
46
46
  - !ruby/object:Gem::Version
47
47
  version: '2.3'
48
- - - ">="
48
+ - - '>='
49
49
  - !ruby/object:Gem::Version
50
50
  version: 2.3.0
51
51
  type: :development
52
52
  prerelease: false
53
53
  version_requirements: !ruby/object:Gem::Requirement
54
54
  requirements:
55
- - - "~>"
55
+ - - ~>
56
56
  - !ruby/object:Gem::Version
57
57
  version: '2.3'
58
- - - ">="
58
+ - - '>='
59
59
  - !ruby/object:Gem::Version
60
60
  version: 2.3.0
61
61
  - !ruby/object:Gem::Dependency
62
62
  name: rspec-nc
63
63
  requirement: !ruby/object:Gem::Requirement
64
64
  requirements:
65
- - - ">="
65
+ - - '>='
66
66
  - !ruby/object:Gem::Version
67
67
  version: '0'
68
68
  type: :development
69
69
  prerelease: false
70
70
  version_requirements: !ruby/object:Gem::Requirement
71
71
  requirements:
72
- - - ">="
72
+ - - '>='
73
73
  - !ruby/object:Gem::Version
74
74
  version: '0'
75
75
  - !ruby/object:Gem::Dependency
76
76
  name: pry
77
77
  requirement: !ruby/object:Gem::Requirement
78
78
  requirements:
79
- - - ">="
79
+ - - '>='
80
80
  - !ruby/object:Gem::Version
81
81
  version: '0'
82
82
  type: :development
83
83
  prerelease: false
84
84
  version_requirements: !ruby/object:Gem::Requirement
85
85
  requirements:
86
- - - ">="
86
+ - - '>='
87
87
  - !ruby/object:Gem::Version
88
88
  version: '0'
89
89
  - !ruby/object:Gem::Dependency
90
90
  name: savon
91
91
  requirement: !ruby/object:Gem::Requirement
92
92
  requirements:
93
- - - "~>"
93
+ - - ~>
94
94
  - !ruby/object:Gem::Version
95
95
  version: '2.3'
96
96
  type: :runtime
97
97
  prerelease: false
98
98
  version_requirements: !ruby/object:Gem::Requirement
99
99
  requirements:
100
- - - "~>"
100
+ - - ~>
101
101
  - !ruby/object:Gem::Version
102
102
  version: '2.3'
103
103
  - !ruby/object:Gem::Dependency
104
104
  name: wasabi
105
105
  requirement: !ruby/object:Gem::Requirement
106
106
  requirements:
107
- - - "~>"
107
+ - - ~>
108
108
  - !ruby/object:Gem::Version
109
109
  version: '3.2'
110
110
  type: :runtime
111
111
  prerelease: false
112
112
  version_requirements: !ruby/object:Gem::Requirement
113
113
  requirements:
114
- - - "~>"
114
+ - - ~>
115
115
  - !ruby/object:Gem::Version
116
116
  version: '3.2'
117
117
  description: A client to allow easy integration with Marketo's SOAP API
@@ -121,10 +121,10 @@ executables: []
121
121
  extensions: []
122
122
  extra_rdoc_files: []
123
123
  files:
124
- - ".coveralls.yml"
125
- - ".gitignore"
126
- - ".rspec"
127
- - ".travis.yml"
124
+ - .coveralls.yml
125
+ - .gitignore
126
+ - .rspec
127
+ - .travis.yml
128
128
  - Gemfile
129
129
  - Guardfile
130
130
  - LICENCE
@@ -167,6 +167,7 @@ files:
167
167
  - spec/fixtures/custom_objects/get_custom_objects/no_custom_objects_found.xml
168
168
  - spec/fixtures/custom_objects/get_custom_objects/one_custom_object_found.xml
169
169
  - spec/fixtures/custom_objects/sync_custom_objects/invalid_object_name.xml
170
+ - spec/fixtures/custom_objects/sync_custom_objects/multiple_syncs.xml
170
171
  - spec/fixtures/custom_objects/sync_custom_objects/successful_sync.xml
171
172
  - spec/fixtures/custom_objects/sync_custom_objects/unknown_attribute.xml
172
173
  - spec/markety/authentication_header_spec.rb
@@ -193,17 +194,17 @@ require_paths:
193
194
  - lib
194
195
  required_ruby_version: !ruby/object:Gem::Requirement
195
196
  requirements:
196
- - - ">="
197
+ - - '>='
197
198
  - !ruby/object:Gem::Version
198
199
  version: 2.0.0
199
200
  required_rubygems_version: !ruby/object:Gem::Requirement
200
201
  requirements:
201
- - - ">="
202
+ - - '>='
202
203
  - !ruby/object:Gem::Version
203
204
  version: '0'
204
205
  requirements: []
205
206
  rubyforge_project:
206
- rubygems_version: 2.4.5
207
+ rubygems_version: 2.0.14
207
208
  signing_key:
208
209
  specification_version: 4
209
210
  summary: Marketo SOAP API integration
@@ -212,6 +213,7 @@ test_files:
212
213
  - spec/fixtures/custom_objects/get_custom_objects/no_custom_objects_found.xml
213
214
  - spec/fixtures/custom_objects/get_custom_objects/one_custom_object_found.xml
214
215
  - spec/fixtures/custom_objects/sync_custom_objects/invalid_object_name.xml
216
+ - spec/fixtures/custom_objects/sync_custom_objects/multiple_syncs.xml
215
217
  - spec/fixtures/custom_objects/sync_custom_objects/successful_sync.xml
216
218
  - spec/fixtures/custom_objects/sync_custom_objects/unknown_attribute.xml
217
219
  - spec/markety/authentication_header_spec.rb
@@ -228,3 +230,4 @@ test_files:
228
230
  - spec/markety/response/sync_lead_response_spec.rb
229
231
  - spec/spec_helper.rb
230
232
  - spec/support/savon_helper.rb
233
+ has_rdoc: