-
Notifications
You must be signed in to change notification settings - Fork 40
/
Copy pathSmartCollectionService.php
114 lines (104 loc) · 3.42 KB
/
SmartCollectionService.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
<?php
namespace Shopify\Service;
use Shopify\Object\SmartCollection;
class SmartCollectionService extends AbstractService
{
/**
* Receive a list of all SmartCollection
*
* @link https://help.shopify.com/api/reference/smartcollection#index
* @param array $params
* @return SmartCollection[]
*/
public function all(array $params = array())
{
$endpoint = '/admin/smart_collections.json';
$response = $this->request($endpoint, 'GET', $params);
return $this->createCollection(SmartCollection::class, $response['smart_collections']);
}
/**
* Receive a count of smart collections
*
* @link https://help.shopify.com/api/reference/smartcollection#count
* @return integer
*/
public function count()
{
$endpoint = '/admin/smart_collections/count.json';
$response = $this->request($endpoint);
return $response['count'];
}
/**
* Receive a single smart collection
*
* @link https://help.shopify.com/api/reference/smartcollection#show
* @param integer $smartCollectionId
* @param array $params
* @return SmartCollection
*/
public function get($smartCollectionId, array $params = array())
{
$endpoint = '/admin/smart_collections/'.$smartCollectionId.'.json';
$response = $this->request($endpoint, 'GET', $params);
return $this->createObject(SmartCollection::class, $response['smart_collection']);
}
/**
* Create a new smart collection
*
* @link https://help.shopify.com/api/reference/smartcollection#create
* @param SmartCollection $smartCollection
* @return void
*/
public function create(SmartCollection &$smartCollection)
{
$data = $smartCollection->exportData();
$endpoint = '/admin/smart_collections.json';
$response = $this->request(
$endpoint, 'POST', array(
'smart_collection' => $data
)
);
$smartCollection->setData($response['smart_collection']);
}
/**
* Modify an existing smart collection
*
* @link https://help.shopify.com/api/reference/smartcollection#update
* @param SmartCollection $smartCollection
* @return void
*/
public function update(SmartCollection &$smartCollection)
{
$data = $smartCollection->exportData();
$endpoint = '/admin/smart_collections/'.$smartCollection->id.'.json';
$response = $this->request(
$endpoint, 'PUT', array(
'smart_collection' => $data
)
);
$smartCollection->setData($response['smart_collection']);
}
/**
* Delete an existing smart_collection
*
* @link https://help.shopify.com/api/reference/smartcollection#destroy
* @param SmartCollection $smartCollection
* @return void
*/
public function delete(SmartCollection $smartCollection)
{
$request = $this->createRequest('/admin/smart_collections/'.$smartCollection->getId().'.json', static::REQUEST_METHOD_DELETE);
$this->send($request);
}
/**
* Set the ordering type or manual order of products
*
* @link https://help.shopify.com/api/reference/smartcollection#order
* @param integer $smatCollectionId
* @param OrderOptions $options
* @return void
*/
public function order($smatCollectionId, OrderOptions $options)
{
}
}