Skip to content
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,4 @@ config.yaml
/objsamples/config.yaml
/objsamples/AllTest.bat
.DS_STORE
.idea
9 changes: 9 additions & 0 deletions lib/fuelsdk/objects.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ def post
client.soap_post id, Array.wrap(properties)
end

def upsert
client.soap_upsert id, Array.wrap(properties)
end

def patch
client.soap_patch id, Array.wrap(properties)
end
Expand Down Expand Up @@ -203,6 +207,11 @@ def post
super
end

def upsert
add_customer_key self.properties
super
end

def patch
add_customer_key self.properties
super
Expand Down
8 changes: 7 additions & 1 deletion lib/fuelsdk/soap.rb
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,11 @@ def soap_post object_type, properties
soap_cud :create, object_type, properties
end

def soap_upsert object_type, properties
options = {'SaveOptions' => [{'SaveOption' => {'PropertyName'=> "*", 'SaveAction' => "UpdateAdd"}}]}
soap_cud :update, object_type, properties, options
end

def soap_put object_type, properties
soap_cud :update, object_type, properties
end
Expand Down Expand Up @@ -386,9 +391,10 @@ def normalize_properties_for_cud object_type, properties

private

def soap_cud action, object_type, properties
def soap_cud action, object_type, properties, options = {}
properties = normalize_properties_for_cud object_type, properties
message = create_objects_message object_type, properties
message['Options'] = options
soap_request action, message
end

Expand Down