Skip to content

Commit

Permalink
Support setting name on existing customers
Browse files Browse the repository at this point in the history
  • Loading branch information
bajb committed Feb 22, 2017
1 parent cbb46e6 commit 18dd6b4
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/Models/AbstractCustomer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
}

0 comments on commit 18dd6b4

Please sign in to comment.