Skip to content

Commit

Permalink
add billing and delivery contact on Invoice
Browse files Browse the repository at this point in the history
  • Loading branch information
dara committed Feb 13, 2015
1 parent 24c7ac5 commit 478eda9
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 5 deletions.
31 changes: 27 additions & 4 deletions lib/v2_1/Contact.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,27 @@
*
* $response = $contact->retrieve();
*
* if ($response->statusCode === 201) {
* if ($response->statusCode === 200) {
* // Success
* }
* ~~~
*
* ~~~
* // List all contacts
* $contact = new Rebilly\v2_1\Contact();
* $contact->setEnvironment(RebillyRequest::ENV_SANDBOX);
* $contact->setApiKey('apiKey');
*
* $response = $contact->listAll();
*
* if ($response->statusCode === 200) {
* // Success
* }
* ~~~
*/
class Contact extends RebillyRequest
{
const END_POINT = 'contacts/';
const CONTACT_END_POINT = 'contacts/';
/** @var string $firstName */
public $firstName;
/** @var string $lastName */
Expand All @@ -68,6 +81,7 @@ class Contact extends RebillyRequest

/** @var string $id */
private $id;

/**
* Set api version and endpoint
* @param null $id
Expand All @@ -78,7 +92,7 @@ public function __construct($id = null)
$this->id = $id;
}
$this->setVersion(2.1);
$this->setApiController(self::END_POINT);
$this->setApiController(self::CONTACT_END_POINT);
}

/**
Expand All @@ -101,8 +115,17 @@ public function retrieve()
if (empty($this->id)) {
throw new Exception('contact id cannot be empty.');
}
$this->setApiController(self::END_POINT . $this->id);
$this->setApiController(self::CONTACT_END_POINT . $this->id);

return $this->sendGetRequest();
}

/**
* List all contact belong to a customer
* @return RebillyResponse
*/
public function listAll()
{
return $this->sendGetRequest();
}

Expand Down
4 changes: 4 additions & 0 deletions lib/v2_1/Invoice.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ class Invoice extends RebillyRequest
public $currency;
/** @var string $dueTime */
public $dueTime;
/** @var string $billingContact */
public $billingContact;
/** @var string $deliveryContact */
public $deliveryContact;

private $id;

Expand Down
3 changes: 2 additions & 1 deletion rebilly_api.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

// v2.1
require_once(dirname(__FILE__) . '/lib/v2_1/Blacklist.php');
require_once(dirname(__FILE__) . '/lib/v2_1/Contact.php');
require_once(dirname(__FILE__) . '/lib/v2_1/Customer.php');
require_once(dirname(__FILE__) . '/lib/v2_1/Invoice.php');
require_once(dirname(__FILE__) . '/lib/v2_1/InvoiceItem.php');
Expand All @@ -29,5 +30,5 @@
require_once(dirname(__FILE__) . '/lib/v2_1/Plan.php');
require_once(dirname(__FILE__) . '/lib/v2_1/Signature.php');
require_once(dirname(__FILE__) . '/lib/v2_1/Subscription.php');
require_once(dirname(__FILE__) . '/lib/v2_1/Transaction.php');
require_once(dirname(__FILE__) . '/lib/v2_1/Token.php');
require_once(dirname(__FILE__) . '/lib/v2_1/Transaction.php');

0 comments on commit 478eda9

Please sign in to comment.