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;
 }
Beispiel #2
0
 /** @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;
 }
Beispiel #3
0
 /**
  * @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;
 }
Beispiel #4
0
 /**
  * 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;
 }
Beispiel #5
0
 /**
  * @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);
 }