Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions src/Models/Purchase.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

namespace OntraportAPI\Models;

use OntraportAPI\Exceptions as Exceptions;

class Purchase
{
/**
* Purchase constructor
*
* @throws Exceptions\OntraportAPIException No gateway id provided for charge now
*
*/
public function __construct()
{
}

}
8 changes: 8 additions & 0 deletions src/Ontraport.php
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,14 @@ public function product()
{
return $this->getApi("Products");
}

/**
* @return Products
*/
public function purchase()
{
return $this->getApi("Purchases");
}

/**
* @return Offers
Expand Down
102 changes: 102 additions & 0 deletions src/Purchases.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
<?php

namespace OntraportAPI;

/**
* Class Purchases
*
* @author ONTRAPORT
*
* @package OntraportAPI
*/
class Purchases extends BaseApi
{
/**
* $var string endpoint for single purchase
*/
protected $_endpoint = "Purchase";

/**
* $var string endpoint for plural purchases
*/
protected $_endpointPlural = "Purchases";

/**
* @param Ontraport $client
*/
public function __construct(Ontraport $client)
{
parent::__construct($client);
}

/**
* @TODO: This is a placeholder, API needs to be changed to follow one standard for naming endpoints
*/
private $_mainPurchaseEndpoint = "purchase";

/**
* @brief Retrieve a single specified purchase
*
* @param mixed[] $requestParams The parameters to submit with GET request.
* Possible array keys: "id" (required)
*
* @return string JSON formatted HTTP response
*/
public function retrieveSingle($requestParams)
{
return parent::_retrieveSingle($requestParams);
}

/**
* @brief Retrieve multiple purchases according to specific criteria, handle pagination
*
* @param mixed[] $requestParams Array of parameters to submit with GET request. All parameters are optional but if "ids"
* are not specified, all will be selected.
* Possible array keys: "ids","start","range","sort","sortDir","condition","search",
* "searchNotes","group_ids","performAll","externs","listFields"
*
* @return string JSON formatted array of response data: each page of data will be an element in that array.
*/
public function retrieveMultiplePaginated($requestParams)
{
return parent::_retrieveMultiplePaginated($requestParams);
}

/**
* @brief Retrieve multiple purchases according to specific criteria
*
* @param mixed[] $requestParams Array of parameters to submit with GET request. All parameters are optional but if "ids"
* are not specified, all will be selected.
* Possible array keys: "ids","start","range","sort","sortDir","condition","search",
* "searchNotes","group_ids","performAll","externs","listFields"
*
* @return string JSON formatted HTTP response
*/
public function retrieveMultiple($requestParams)
{
return parent::_retrieveMultiple($requestParams);
}

/**
* @brief Retrieve information (such as number of purchases) about purchase collection
*
* @param mixed[] $requestParams Array of parameters to submit with GET request. All parameters are optional.
* Possible array keys: "condition","search","searchNotes","group_ids","performAll"
*
* @return string JSON formatted HTTP response
*/
public function retrieveCollectionInfo($requestParams)
{
return parent::_retrieveCollectionInfo($requestParams);
}

/**
* @brief Retrieve meta for a purchase object
*
* @return string JSON formatted meta for purchase object
*/
public function retrieveMeta()
{
return parent::_retrieveMeta();
}
}