From 18dd6b41ec0b1c19ebbc69b2e01dfd8fe9f12803 Mon Sep 17 00:00:00 2001 From: Brooke Bryan Date: Wed, 22 Feb 2017 08:38:14 +0000 Subject: [PATCH] Support setting name on existing customers --- src/Models/AbstractCustomer.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/Models/AbstractCustomer.php b/src/Models/AbstractCustomer.php index cd2afa0..f94d79f 100644 --- a/src/Models/AbstractCustomer.php +++ b/src/Models/AbstractCustomer.php @@ -4,6 +4,7 @@ use Fortifi\FortifiApi\Customer\Endpoints\CustomerEndpoint; use Fortifi\FortifiApi\Customer\Payloads\CustomerEmailPayload; use Fortifi\FortifiApi\Customer\Payloads\CustomerPhonePayload; +use Fortifi\FortifiApi\Customer\Payloads\UpdateCustomerPayload; use Fortifi\FortifiApi\Property\Endpoints\PropertyEndpoint; use Fortifi\FortifiApi\Property\Payloads\SetPropertyValuePayload; use Packaged\Helpers\ValueAs; @@ -139,4 +140,20 @@ public function decrementCounter($name, $value = 1) return $this; } + + public function setName($first, $last) + { + if(empty($this->_customerFid)) + { + throw new \RuntimeException( + "You cannot set a name before setting a customer fid" + ); + } + + $pl = UpdateCustomerPayload::create($this->_customerFid); + $pl->firstName = $first; + $pl->lastName = $last; + $this->_processRequest($this->_getEndpoint()->update($pl)); + return $this; + } }