diff --git a/.gitignore b/.gitignore index d3ffc31..d103b8e 100755 --- a/.gitignore +++ b/.gitignore @@ -24,3 +24,4 @@ config.yaml /objsamples/config.yaml /objsamples/AllTest.bat .DS_STORE +.idea \ No newline at end of file diff --git a/lib/fuelsdk/objects.rb b/lib/fuelsdk/objects.rb index 9407bfd..119834c 100644 --- a/lib/fuelsdk/objects.rb +++ b/lib/fuelsdk/objects.rb @@ -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 @@ -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 diff --git a/lib/fuelsdk/soap.rb b/lib/fuelsdk/soap.rb index c19edb1..075d8ea 100644 --- a/lib/fuelsdk/soap.rb +++ b/lib/fuelsdk/soap.rb @@ -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 @@ -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