Skip to content
This repository was archived by the owner on Jan 20, 2024. It is now read-only.

Update savon to ~> 2.3 #112

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 28 additions & 18 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,17 @@ PATH
sfmc-fuelsdk-ruby (1.3.0)
json (~> 1.8, >= 1.8.1)
jwt (~> 1.0, >= 1.0.0)
savon (= 2.2.0)
savon (~> 2.3)

GEM
remote: https://rubygems.org/
specs:
akami (1.2.2)
addressable (2.7.0)
public_suffix (>= 2.0.2, < 5.0)
akami (1.3.1)
gyoku (>= 0.4.0)
nokogiri
builder (3.2.3)
builder (3.2.4)
coderay (1.1.2)
diff-lcs (1.3)
ffi (1.9.25)
Expand All @@ -28,10 +30,11 @@ GEM
guard-rspec (2.6.0)
guard (>= 1.8)
rspec (~> 2.13)
gyoku (1.0.0)
gyoku (1.3.1)
builder (>= 2.1.2)
httpi (2.0.2)
httpi (2.4.5)
rack
socksify
json (1.8.6)
jwt (1.5.6)
listen (1.3.1)
Expand All @@ -41,13 +44,18 @@ GEM
lumberjack (1.0.13)
method_source (0.9.0)
mini_portile2 (2.4.0)
nokogiri (1.10.1-x64-mingw32)
nokogiri (1.10.10)
mini_portile2 (~> 2.4.0)
nori (2.1.0)
nokogiri (1.10.10-x64-mingw32)
mini_portile2 (~> 2.4.0)
nokogiri (1.10.10-x86-mingw32)
mini_portile2 (~> 2.4.0)
nori (2.6.0)
pry (0.11.3)
coderay (~> 1.1.0)
method_source (~> 0.9.0)
rack (2.0.6)
public_suffix (4.0.6)
rack (2.2.3)
rake (0.9.6)
rb-fsevent (0.10.3)
rb-inotify (0.9.10)
Expand All @@ -62,18 +70,20 @@ GEM
rspec-expectations (2.99.2)
diff-lcs (>= 1.1.3, < 2.0)
rspec-mocks (2.99.4)
savon (2.2.0)
akami (~> 1.2.0)
savon (2.12.1)
akami (~> 1.2)
builder (>= 2.1.2)
gyoku (~> 1.0.0)
httpi (~> 2.0.2)
nokogiri (>= 1.4.0)
nori (~> 2.1.0)
wasabi (~> 3.1.0)
gyoku (~> 1.2)
httpi (~> 2.3)
nokogiri (>= 1.8.1)
nori (~> 2.4)
wasabi (~> 3.4)
socksify (1.7.1)
thor (0.20.0)
wasabi (3.1.0)
wasabi (3.6.1)
addressable
httpi (~> 2.0)
nokogiri (>= 1.4.0)
nokogiri (>= 1.4.2)

PLATFORMS
ruby
Expand All @@ -89,4 +99,4 @@ DEPENDENCIES
sfmc-fuelsdk-ruby!

BUNDLED WITH
1.17.1
1.17.3
2 changes: 1 addition & 1 deletion lib/marketingcloudsdk/objects.rb
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ def cleanProps
# If the ID property is specified for the destination then it must be a list import
if properties.has_key?('DestinationObject') then
if properties['DestinationObject'].has_key?('ID') then
properties[:attributes!] = { 'DestinationObject' => { 'xsi:type' => 'tns:List'}}
properties['DesintationObject'][:'@xsi:type'] = 'tns:List'
end
end
end
Expand Down
30 changes: 17 additions & 13 deletions lib/marketingcloudsdk/soap.rb
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,10 @@ def header
else
raise 'Require legacy token for soap header' unless internal_token
{
'oAuth' => {'oAuthToken' => internal_token},
:attributes! => { 'oAuth' => { 'xmlns' => 'http://exacttarget.com' }}
'oAuth' => {
:'@xmlns' => 'http://exacttarget.com',
'oAuthToken' => internal_token
}
}
end
end
Expand Down Expand Up @@ -180,7 +182,7 @@ def soap_perform object_type, action, properties
message = {}
message['Action'] = action
message['Definitions'] = {'Definition' => properties}
message['Definitions'][:attributes!] = { 'Definition' => { 'xsi:type' => ('tns:' + object_type) }}
message['Definitions'][:'@xsi:type'] = 'tns:' + object_type

soap_request :perform, message
end
Expand All @@ -198,7 +200,7 @@ def soap_configure object_type, action, properties
else
message['Configurations'] = {'Configuration' => properties}
end
message['Configurations'][:attributes!] = { 'Configuration' => { 'xsi:type' => ('tns:' + object_type) }}
message['Configurations'][:'@xsi:type'] = 'tns:' + object_type

soap_request :configure, message
end
Expand All @@ -222,13 +224,12 @@ def soap_get object_type, properties=nil, filter=nil

if filter and filter.kind_of? Hash
message['Filter'] = filter
message[:attributes!] = { 'Filter' => { 'xsi:type' => 'tns:SimpleFilterPart' } }
message['Filter'][:'@xsi:type'] = 'tns:SimpleFilterPart'

if filter.has_key?('LogicalOperator')
message[:attributes!] = { 'Filter' => { 'xsi:type' => 'tns:ComplexFilterPart' }}
message['Filter'][:attributes!] = {
'LeftOperand' => { 'xsi:type' => 'tns:SimpleFilterPart' },
'RightOperand' => { 'xsi:type' => 'tns:SimpleFilterPart' }}
message['Filter'][:'@xsi:type'] = 'tns:ComplexFilterPart'
message['Filter']['LeftOperand']['@xsi:type'] = 'tns:SimpleFilterPart'
message['Filter']['RightOperand']['@xsi:type'] = 'tns:SimpleFilterPart'
end
end
message = {'RetrieveRequest' => message}
Expand Down Expand Up @@ -274,10 +275,13 @@ def soap_cud action, object_type, properties, upsert=nil
# end
#

message = {
'Objects' => properties,
:attributes! => { 'Objects' => { 'xsi:type' => ('tns:' + object_type) } }
}
message = {'Objects' => properties}

if properties.is_a? Array
properties.each { |p| p[:'@xsi:type'] = ('tns:' + object_type) }
else
message['Objects'][:'@xsi:type'] = 'tns:' + object_type
end

if upsert
message['Options'] = {"SaveOptions" => {"SaveOption" => {"PropertyName"=> "*", "SaveAction" => "UpdateAdd"}}}
Expand Down
57 changes: 25 additions & 32 deletions lib/new.rb
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,10 @@ def initialize(getWSDL = true, debug = false, params = nil)

self.determineStack

@authObj = {'oAuth' => {'oAuthToken' => @internalAuthToken}}
@authObj[:attributes!] = { 'oAuth' => { 'xmlns' => 'http://exacttarget.com' }}
@authObj = {'oAuth' => {
:@xmlns => 'http://exacttarget.com',
'oAuthToken' => @internalAuthToken
}}

myWSDL = File.read(@path + '/ExactTargetWSDL.xml')
@auth = Savon.client(
Expand Down Expand Up @@ -257,8 +259,10 @@ def refreshToken(force = nil)
self.determineStack
end

@authObj = {'oAuth' => {'oAuthToken' => @internalAuthToken}}
@authObj[:attributes!] = { 'oAuth' => { 'xmlns' => 'http://exacttarget.com' }}
@authObj = {'oAuth' => {
:@xmlns => 'http://exacttarget.com',
'oAuthToken' => @internalAuthToken
}}

myWSDL = File.read(@path + '/ExactTargetWSDL.xml')
@auth = Savon.client(
Expand Down Expand Up @@ -362,24 +366,20 @@ def initialize(authStub = nil, objType = nil)
end

class ET_Post < ET_Constructor
def initialize(authStub, objType, props = nil)
def initialize(authStub, objType, props = {})
@results = []

begin
authStub.refreshToken
if props.is_a? Array then
obj = {
'Objects' => [],
:attributes! => { 'Objects' => { 'xsi:type' => ('tns:' + objType) } }
}
obj = { 'Objects' => [] }
props.each{ |p|
p[':@xsi:type'] = 'tns:' + objType
obj['Objects'] << p
}
else
obj = {
'Objects' => props,
:attributes! => { 'Objects' => { 'xsi:type' => ('tns:' + objType) } }
}
obj = { 'Objects' => props }
obj['Objects']['@xsi:type'] = 'tns:' + objType
end

response = authStub.auth.call(:create, :message => obj)
Expand Down Expand Up @@ -410,18 +410,14 @@ def initialize(authStub, objType, props = nil)
begin
authStub.refreshToken
if props.is_a? Array then
obj = {
'Objects' => [],
:attributes! => { 'Objects' => { 'xsi:type' => ('tns:' + objType) } }
}
obj = { 'Objects' => [] }
props.each{ |p|
p[':@xsi:type'] = 'tns:' + objType
obj['Objects'] << p
}
else
obj = {
'Objects' => props,
:attributes! => { 'Objects' => { 'xsi:type' => ('tns:' + objType) } }
}
obj = { 'Objects' => props }
obj['Objects']['@xsi:type'] = 'tns:' + objType
end

response = authStub.auth.call(:delete, :message => obj)
Expand All @@ -447,18 +443,14 @@ def initialize(authStub, objType, props = nil)
begin
authStub.refreshToken
if props.is_a? Array then
obj = {
'Objects' => [],
:attributes! => { 'Objects' => { 'xsi:type' => ('tns:' + objType) } }
}
obj = { 'Objects' => [] }
props.each{ |p|
p[':@xsi:type'] = 'tns:' + objType
obj['Objects'] << p
}
else
obj = {
'Objects' => props,
:attributes! => { 'Objects' => { 'xsi:type' => ('tns:' + objType) } }
}
obj = { 'Objects' => props }
obj['Objects']['@xsi:type'] = 'tns:' + objType
end

response = authStub.auth.call(:update, :message => obj)
Expand Down Expand Up @@ -537,11 +529,12 @@ def initialize(authStub, objType, props = nil, filter = nil)
if filter then
if filter.has_key?('LogicalOperator') then
obj['Filter'] = filter
obj[:attributes!] = { 'Filter' => { 'xsi:type' => 'tns:ComplexFilterPart' }}
obj['Filter'][:attributes!] = { 'LeftOperand' => { 'xsi:type' => 'tns:SimpleFilterPart' }, 'RightOperand' => { 'xsi:type' => 'tns:SimpleFilterPart' }}
obj['Filter'][:'@xsi:type'] = 'tns:ComplexFilterPart'
obj['Filter']['LeftOperand'][:'@xsi:type'] = 'tns:SimpleFilterPart'
obj['Filter']['RightOperand'][:'@xsi:type'] = 'tns:SimpleFilterPart'
else
obj['Filter'] = filter
obj[:attributes!] = { 'Filter' => { 'xsi:type' => 'tns:SimpleFilterPart' } }
obj['Filter'][:'@xsi:type'] = 'tns:SimpleFilterPart'
end
end

Expand Down
2 changes: 1 addition & 1 deletion marketingcloudsdk.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Gem::Specification.new do |spec|
spec.add_development_dependency "guard",'~> 1.1'
spec.add_development_dependency "guard-rspec",'~> 2.0'

spec.add_dependency "savon", "2.2.0"
spec.add_dependency "savon", "~> 2.3"
spec.add_dependency "json", "~>1.8",">= 1.8.1"
spec.add_dependency "jwt", "~>1.0",">= 1.0.0"
end
39 changes: 22 additions & 17 deletions spec/soap_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@
client.internal_token = 'innerspace'
expect(client.header).to eq(
{
'oAuth' => { 'oAuthToken' => 'innerspace' },
:attributes! => {
'oAuth' => { 'xmlns' => 'http://exacttarget.com' }
'oAuth' => {
:@xmlns => 'http://exacttarget.com',
'oAuthToken' => 'innerspace'
}
}
)
Expand Down Expand Up @@ -76,27 +76,28 @@
it 'formats soap :create message for single object' do
expect(subject.soap_post 'Subscriber', 'EmailAddress' => '[email protected]' ).to eq([:create,
{
'Objects' => {'EmailAddress' => '[email protected]'},
:attributes! => {'Objects' => {'xsi:type' => ('tns:Subscriber')}}
'Objects' => {:'@xsi:type' => 'tns:Subscriber', 'EmailAddress' => '[email protected]'}
}])
end

it 'formats soap :create message for multiple objects' do
expect(subject.soap_post 'Subscriber', [{'EmailAddress' => '[email protected]'}, {'EmailAddress' => '[email protected]'}] ).to eq([:create,
{
'Objects' => [{'EmailAddress' => '[email protected]'}, {'EmailAddress' => '[email protected]'}],
:attributes! => {'Objects' => {'xsi:type' => ('tns:Subscriber')}}
'Objects' => [
{:'@xsi:type' => 'tns:Subscriber', 'EmailAddress' => '[email protected]'},
{:'@xsi:type' => 'tns:Subscriber', 'EmailAddress' => '[email protected]'}
],
}])
end

it 'formats soap :create message for single object with an attribute' do
expect(subject.soap_post 'Subscriber', {'EmailAddress' => '[email protected]', 'Attributes'=> [{'Name'=>'First Name', 'Value'=>'first'}]}).to eq([:create,
{
'Objects' => {
:'@xsi:type' => 'tns:Subscriber',
'EmailAddress' => '[email protected]',
'Attributes' => [{'Name' => 'First Name', 'Value' => 'first'}],
},
:attributes! => {'Objects' => {'xsi:type' => ('tns:Subscriber')}}
}
}])
end

Expand All @@ -110,8 +111,8 @@
{'Name' => 'First Name', 'Value' => 'first'},
{'Name' => 'Last Name', 'Value' => 'subscriber'},
],
},
:attributes! => {'Objects' => {'xsi:type' => ('tns:Subscriber')}}
:'@xsi:type' => 'tns:Subscriber'
}
}])
end

Expand All @@ -120,19 +121,23 @@
{'EmailAddress' => '[email protected]', 'Attributes'=> [{'Name'=>'First Name', 'Value'=>'second'}, {'Name'=>'Last Name', 'Value'=>'subscriber'}]}]).to eq([:create,
{
'Objects' => [
{'EmailAddress' => '[email protected]',
{
'EmailAddress' => '[email protected]',
'Attributes' => [
{'Name' => 'First Name', 'Value' => 'first'},
{'Name' => 'Last Name', 'Value' => 'subscriber'},
]
],
:'@xsi:type' => 'tns:Subscriber'
},
{'EmailAddress' => '[email protected]',
{
'EmailAddress' => '[email protected]',
'Attributes' => [
{'Name' => 'First Name', 'Value' => 'second'},
{'Name' => 'Last Name', 'Value' => 'subscriber'},
]
}],
:attributes! => {'Objects' => {'xsi:type' => ('tns:Subscriber')}}
],
:'@xsi:type' => 'tns:Subscriber'
}
]
}])
end
end
Expand Down