public function toArray() { $account = array_filter(get_object_vars($this)); if ($this->creditor instanceof Creditor) { unset($account['creditor']); $account['links'] = ['creditor' => $this->creditor->getId()]; } return $account; }
/** @depends it_can_create_a_creditor */ function test_it_can_get_a_single_creditor(Creditor $old) { $new = $this->api->getCreditor($old->getId()); $this->assertInstanceOf('GoCardless\\Pro\\Models\\Creditor', $new); $this->assertEquals($old->toArray(), $new->toArray()); return $new; }
/** * @return array */ public function toArray() { $mandate = array_filter(get_object_vars($this)); if ($this->customer_bank_account instanceof CustomerBankAccount) { unset($mandate['customer_bank_account']); $mandate['links']['customer_bank_account'] = $this->customer_bank_account->getId(); } if ($this->creditor instanceof Creditor) { unset($mandate['creditor']); $mandate['links']['creditor'] = $this->creditor->getId(); } return $mandate; }
/** * Returns the entity as an array (as the API expects) * * @return array */ public function toArray() { $redirectFlow = array_filter(get_object_vars($this)); if ($this->creditor instanceof Creditor) { unset($redirectFlow['creditor']); $redirectFlow['links']['creditor'] = $this->creditor->getId(); } if ($this->mandate instanceof Mandate) { unset($redirectFlow['mandate']); $redirectFlow['links']['mandate'] = $this->mandate->getId(); } return $redirectFlow; }
/** * @see https://developer.gocardless.com/pro/#creditors-update-a-creditor * * @param Creditor $creditor * * @return Creditor */ public function updateCreditor(Creditor $creditor) { $response = $this->put(self::CREDITORS, $creditor->toArrayForUpdating(), $creditor->getId()); return Creditor::fromArray($response); }