getCustomerId($customer_number); // Check if the customer exists if ($customer) { return $this->parseCustomer($customer); } return $this; } public function parseCustomer($customer): static { global /** @var response $response */ $response; $this->customer_number = $customer->customerNumber; $this->name = ($customer->name ?? null); $this->address = ($customer->address ?? null); $this->city = ($customer->city ?? null); $this->zip = ($customer->zip ?? null); $this->corporateIdentificationNumber = ($customer->corporateIdentificationNumber ?? null); $this->email = ($customer->email ?? null); $this->mobilePhone = ($customer->mobilePhone ?? null); $this->currency = ($customer->currency ?? null); $this->country = ($customer->country ?? null); $users_o = new users_o(); $user = $users_o->getUserByCustomerNumber($this->customer_number); // Cache the customer if ($user->exists()) { $user->cache('economic_customer', $this); } // Add the customer to the debug log $response->add_debug_list('economic_customer', $this->customer_number, $customer); return $this; } public function asArray(): array { // If the customer does not exist, return an empty array if (!isset($this->customer_number)) { return []; } return [ 'customerNumber' => $this->customer_number, 'name' => $this->name, 'address' => $this->address, 'city' => $this->city, 'zip' => $this->zip, 'corporateIdentificationNumber' => $this->corporateIdentificationNumber, 'email' => $this->email, 'mobilePhone' => $this->mobilePhone, 'currency' => $this->currency, 'country' => $this->country, ]; } }