public function toArray() { $account = array_filter(get_object_vars($this)); if ($this->customer instanceof Customer) { unset($account['customer']); $account['links'] = ['customer' => $this->customer->getId()]; } return $account; }
/** @test */ function it_has_alias_for_setting_the_customer_name() { $customer = new Customer(); $customer->setForename('John')->setSurname('Doe'); $this->assertEquals('John', $customer->getForename()); $this->assertEquals('Doe', $customer->getSurname()); $this->assertEquals(['given_name' => 'John', 'family_name' => 'Doe'], $customer->toArray()); $customer->setFirstName('Jane')->setLastName('Smith'); $this->assertEquals('Jane', $customer->getFirstName()); $this->assertEquals('Smith', $customer->getLastName()); $this->assertEquals(['given_name' => 'Jane', 'family_name' => 'Smith'], $customer->toArray()); }
/** * @see https://developer.gocardless.com/pro/#customers-get-a-single-customer * * @param $id * * @return Customer */ public function getCustomer($id) { $response = $this->get(self::CUSTOMERS, [], $id); return Customer::fromArray($response); }
/** * @depends it_can_create_a_customer * @depends test_it_can_create_a_customer_bank_account */ function test_it_can_return_customer_bank_accounts_for_a_specific_customer(Customer $customer, CustomerBankAccount $old) { $accounts = $this->api->listCustomerBankAccounts(['customer' => $customer->getId()]); $this->assertCount(1, $accounts); $this->assertInternalType('array', $accounts); $this->assertInstanceOf('GoCardless\\Pro\\Models\\CustomerBankAccount', $accounts[0]); $this->assertEquals($old->getId(), $accounts[0]->getId()); }
/** * @return Customer */ protected function get_full_customer() { return Customer::fromArray($this->full_customer_details()); }