protected function _initialize($customerAttribs)
{
$this->_attributes = $customerAttribs;
$addressArray = [];
if (isset($customerAttribs['addresses'])) {
foreach ($customerAttribs['addresses'] as $address) {
$addressArray[] = Address::factory($address);
}
}
$this->_set('addresses', $addressArray);
$creditCardArray = [];
if (isset($customerAttribs['creditCards'])) {
foreach ($customerAttribs['creditCards'] as $creditCard) {
$creditCardArray[] = CreditCard::factory($creditCard);
}
}
$this->_set('creditCards', $creditCardArray);
$coinbaseAccountArray = [];
if (isset($customerAttribs['coinbaseAccounts'])) {
foreach ($customerAttribs['coinbaseAccounts'] as $coinbaseAccount) {
$coinbaseAccountArray[] = CoinbaseAccount::factory($coinbaseAccount);
}
}
$this->_set('coinbaseAccounts', $coinbaseAccountArray);
$paypalAccountArray = [];
if (isset($customerAttribs['paypalAccounts'])) {
foreach ($customerAttribs['paypalAccounts'] as $paypalAccount) {
$paypalAccountArray[] = PayPalAccount::factory($paypalAccount);
}
}
$this->_set('paypalAccounts', $paypalAccountArray);
$applePayCardArray = [];
if (isset($customerAttribs['applePayCards'])) {
foreach ($customerAttribs['applePayCards'] as $applePayCard) {
$applePayCardArray[] = ApplePayCard::factory($applePayCard);
}
}
$this->_set('applePayCards', $applePayCardArray);
$androidPayCardArray = [];
if (isset($customerAttribs['androidPayCards'])) {
foreach ($customerAttribs['androidPayCards'] as $androidPayCard) {
$androidPayCardArray[] = AndroidPayCard::factory($androidPayCard);
}
}
$this->_set('androidPayCards', $androidPayCardArray);
$amexExpressCheckoutCardArray = [];
if (isset($customerAttribs['amexExpressCheckoutCards'])) {
foreach ($customerAttribs['amexExpressCheckoutCards'] as $amexExpressCheckoutCard) {
$amexExpressCheckoutCardArray[] = AmexExpressCheckoutCard::factory($amexExpressCheckoutCard);
}
}
$this->_set('amexExpressCheckoutCards', $amexExpressCheckoutCardArray);
$venmoAccountArray = array();
if (isset($customerAttribs['venmoAccounts'])) {
foreach ($customerAttribs['venmoAccounts'] as $venmoAccount) {
$venmoAccountArray[] = VenmoAccount::factory($venmoAccount);
}
}
$this->_set('venmoAccounts', $venmoAccountArray);
$usBankAccountArray = array();
if (isset($customerAttribs['usBankAccounts'])) {
foreach ($customerAttribs['usBankAccounts'] as $usBankAccount) {
$usBankAccountArray[] = UsBankAccount::factory($usBankAccount);
}
}
$this->_set('usBankAccounts', $usBankAccountArray);
$this->_set('paymentMethods', array_merge($this->creditCards, $this->paypalAccounts, $this->applePayCards, $this->coinbaseAccounts, $this->androidPayCards, $this->amexExpressCheckoutCards, $this->venmoAccounts, $this->usBankAccounts));
}