From 396d9297a359e949355fc79f7f29b605decd59ec Mon Sep 17 00:00:00 2001 From: Tom Ashe Date: Wed, 23 Dec 2020 18:45:28 -0800 Subject: [PATCH] Add Upsert support by implementing put method on DataExtension Row --- src/ET_DataExtension_Row.php | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/src/ET_DataExtension_Row.php b/src/ET_DataExtension_Row.php index 63dbfff..8d9c5f4 100644 --- a/src/ET_DataExtension_Row.php +++ b/src/ET_DataExtension_Row.php @@ -85,7 +85,30 @@ public function patch() $this->props = $originalProps; return $response; } - + + /** + * Put this instance. + * @return ET_Patch Object of type ET_Patch which contains http status code, response, etc from the PATCH SOAP service + */ + public function put() + { + $this->getCustomerKey(); + $originalProps = $this->props; + $overrideProps = array(); + $fields = array(); + + foreach ($this->props as $key => $value){ + $fields[] = array("Name" => $key, "Value" => $value); + } + $overrideProps['CustomerKey'] = $this->CustomerKey; + $overrideProps['Properties'] = array("Property"=> $fields); + + $this->props = $overrideProps; + $response = parent::put(); + $this->props = $originalProps; + return $response; + } + /** * Delete this instance. * @return ET_Delete Object of type ET_Delete which contains http status code, response, etc from the DELETE SOAP service @@ -151,4 +174,4 @@ private function getCustomerKey() } } } -?> \ No newline at end of file +?>