Skip to content

Commit

Permalink
added new methods
Browse files Browse the repository at this point in the history
  • Loading branch information
Adam Train committed Nov 6, 2019
1 parent 324837b commit 4532a93
Showing 1 changed file with 67 additions and 3 deletions.
70 changes: 67 additions & 3 deletions src/Invoice.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ class Invoice extends BaseObject
use Operations\Update;
use Operations\Delete;

/*
* Sends the invoice to the customer,
/**
* Sends the invoice to the customer.
*
* @param array $params
* @param array $opts
Expand All @@ -27,6 +27,42 @@ public function send(array $params = [], array $opts = [])
return Util::buildObjects($email, $response['body']);
}

/**
* Sends the invoice to the customer by SMS.
*
* @param array $params
* @param array $opts
*
* @return array(Invoiced\TextMessage)
*/
public function sendSMS(array $params = [], array $opts = [])
{
$response = $this->_client->request('post', $this->getEndpoint().'/text_messages', $params, $opts);

// build text message objects
$textMessage = new TextMessage($this->_client);

return Util::buildObjects($textMessage, $response['body']);
}

/**
* Sends the invoice to the customer by mail.
*
* @param array $params
* @param array $opts
*
* @return array(Invoiced\Letter)
*/
public function sendLetter(array $params = [], array $opts = [])
{
$response = $this->_client->request('post', $this->getEndpoint().'/letters', $params, $opts);

// build letter objects
$letter = new Letter($this->_client);

return Util::buildObjects($letter, $response['body']);
}

/**
* Attempts to collect payment on the invoice.
*
Expand Down Expand Up @@ -86,4 +122,32 @@ public function paymentPlan()

return $paymentPlan;
}
}

/**
* Gets a note object for this invoice.
*
* @return Note
*/
public function notes()
{
$paymentPlan = new Note($this->_client);
$paymentPlan->setEndpointBase($this->getEndpoint());

return $paymentPlan;
}

/**
* Voids the invoice.
*
* @return Invoice
*/
public function void()
{
$response = $this->_client->request('post', $this->getEndpoint().'/void', [], []);

// update the local values with the response
$this->_values = array_replace((array) $response['body'], ['id' => $this->id]);

return $response['code'] == 200;
}
}

0 comments on commit 4532a93

Please sign in to comment.