-
Notifications
You must be signed in to change notification settings - Fork 198
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #287 from HubSpot/feature/LineItems
Feature/line items
- Loading branch information
Showing
8 changed files
with
476 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,195 @@ | ||
<?php | ||
|
||
namespace SevenShores\Hubspot\Resources; | ||
|
||
/** | ||
* @see https://developers.hubspot.com/docs/methods/line-items/line-items-overview | ||
*/ | ||
class LineItems extends Resource | ||
{ | ||
/** | ||
* Get all line items. | ||
* | ||
* @see https://developers.hubspot.com/docs/methods/line-items/get-all-line-items | ||
* | ||
* @return \SevenShores\Hubspot\Http\Response | ||
*/ | ||
public function all(array $params = []) | ||
{ | ||
$endpoint = 'https://api.hubapi.com/crm-objects/v1/objects/line_items/paged'; | ||
|
||
return $this->client->request( | ||
'get', | ||
$endpoint, | ||
[], | ||
build_query_string($params) | ||
); | ||
} | ||
|
||
/** | ||
* Get a line item by ID. | ||
* | ||
* @param int $id | ||
* | ||
* @see https://developers.hubspot.com/docs/methods/line-items/get_line_item_by_id | ||
* | ||
* @return \SevenShores\Hubspot\Http\Response | ||
*/ | ||
public function getById($id, array $params = []) | ||
{ | ||
$endpoint = "https://api.hubapi.com/crm-objects/v1/objects/line_items/{$id}"; | ||
|
||
return $this->client->request( | ||
'get', | ||
$endpoint, | ||
[], | ||
build_query_string($params) | ||
); | ||
} | ||
|
||
/** | ||
* Get a group of line items by ID. | ||
* | ||
* @see https://developers.hubspot.com/docs/methods/line-items/batch-get-line-items | ||
* | ||
* @return \SevenShores\Hubspot\Http\Response | ||
*/ | ||
public function getBatchByIds(array $ids, array $params = []) | ||
{ | ||
$endpoint = 'https://api.hubapi.com/crm-objects/v1/objects/line_items/batch-read'; | ||
|
||
return $this->client->request( | ||
'post', | ||
$endpoint, | ||
['json' => ['ids' => $ids]], | ||
build_query_string($params) | ||
); | ||
} | ||
|
||
/** | ||
* Create a line item. | ||
* | ||
* @see https://developers.hubspot.com/docs/methods/line-items/create-line-item | ||
* | ||
* @return \SevenShores\Hubspot\Http\Response | ||
*/ | ||
public function create(array $properties) | ||
{ | ||
$endpoint = 'https://api.hubapi.com/crm-objects/v1/objects/line_items'; | ||
|
||
return $this->client->request( | ||
'post', | ||
$endpoint, | ||
['json' => $properties] | ||
); | ||
} | ||
|
||
/** | ||
* Create a group of line items. | ||
* | ||
* @see https://developers.hubspot.com/docs/methods/line-items/batch-create-line-items | ||
* | ||
* @return \SevenShores\Hubspot\Http\Response | ||
*/ | ||
public function createBatch(array $lineItems) | ||
{ | ||
$endpoint = 'https://api.hubapi.com/crm-objects/v1/objects/line_items/batch-create'; | ||
|
||
return $this->client->request( | ||
'post', | ||
$endpoint, | ||
['json' => $lineItems] | ||
); | ||
} | ||
|
||
/** | ||
* Update a line item. | ||
* | ||
* @param int $id | ||
* | ||
* @see https://developers.hubspot.com/docs/methods/line-items/update-line-item | ||
* | ||
* @return \SevenShores\Hubspot\Http\Response | ||
*/ | ||
public function update($id, array $properties) | ||
{ | ||
$endpoint = "https://api.hubapi.com/crm-objects/v1/objects/line_items/{$id}"; | ||
|
||
return $this->client->request( | ||
'put', | ||
$endpoint, | ||
['json' => $properties] | ||
); | ||
} | ||
|
||
/** | ||
* Update a group of line items. | ||
* | ||
* @see https://developers.hubspot.com/docs/methods/line-items/batch-update-line-items | ||
* | ||
* @return \SevenShores\Hubspot\Http\Response | ||
*/ | ||
public function updateBatch(array $lineItems) | ||
{ | ||
$endpoint = 'https://api.hubapi.com/crm-objects/v1/objects/line_items/batch-update'; | ||
|
||
return $this->client->request( | ||
'post', | ||
$endpoint, | ||
['json' => $lineItems] | ||
); | ||
} | ||
|
||
/** | ||
* Delete a line item. | ||
* | ||
* @param int $id | ||
* | ||
* @see https://developers.hubspot.com/docs/methods/line-items/delete-line-item | ||
* | ||
* @return \SevenShores\Hubspot\Http\Response | ||
*/ | ||
public function delete($id) | ||
{ | ||
$endpoint = "https://api.hubapi.com/crm-objects/v1/objects/line_items/{$id}"; | ||
|
||
return $this->client->request('delete', $endpoint); | ||
} | ||
|
||
/** | ||
* Delete a group of line items. | ||
* | ||
* @see https://developers.hubspot.com/docs/methods/line-items/batch-delete-line-items | ||
* | ||
* @return \SevenShores\Hubspot\Http\Response | ||
*/ | ||
public function deleteBatch(array $ids) | ||
{ | ||
$endpoint = 'https://api.hubapi.com/crm-objects/v1/objects/line_items/batch-delete'; | ||
|
||
return $this->client->request( | ||
'post', | ||
$endpoint, | ||
['json' => ['ids' => $ids]] | ||
); | ||
} | ||
|
||
/** | ||
* Get a log of changes for line items. | ||
* | ||
* @see https://developers.hubspot.com/docs/methods/line-items/get-line-item-changes | ||
* | ||
* @return \SevenShores\Hubspot\Http\Response | ||
*/ | ||
public function getLineItemChanges(array $params = []) | ||
{ | ||
$endpoint = 'https://api.hubapi.com/crm-objects/v1/change-log/line_items'; | ||
|
||
return $this->client->request( | ||
'get', | ||
$endpoint, | ||
[], | ||
build_query_string($params) | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?php | ||
|
||
namespace SevenShores\Hubspot\Tests\Integration\Abstraction; | ||
|
||
trait ProductData | ||
{ | ||
protected function getData(string $name = 'A new product'): array | ||
{ | ||
return [ | ||
['name' => 'name', 'value' => $name], | ||
['name' => 'description', 'value' => 'A description of this product.'], | ||
['name' => 'price', 'value' => 27.50], | ||
['name' => 'recurringbillingfrequency', 'value' => 'quarterly'], | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.