1
|
|
|
<?php |
2
|
|
|
namespace CodeCloud\Bundle\ShopifyBundle\Api\Endpoint; |
3
|
|
|
|
4
|
|
|
use CodeCloud\Bundle\ShopifyBundle\Api\Request\DeleteParams; |
5
|
|
|
use CodeCloud\Bundle\ShopifyBundle\Api\Request\GetJson; |
6
|
|
|
use CodeCloud\Bundle\ShopifyBundle\Api\Request\PostJson; |
7
|
|
|
use CodeCloud\Bundle\ShopifyBundle\Api\Request\PutJson; |
8
|
|
|
use CodeCloud\Bundle\ShopifyBundle\Api\GenericResource; |
9
|
|
|
|
10
|
|
|
class CustomCollectionEndpoint extends AbstractEndpoint |
11
|
|
|
{ |
12
|
|
|
/** |
13
|
|
|
* @param array $query |
14
|
|
|
* @return array|GenericResource[] |
15
|
|
|
*/ |
16
|
|
|
public function findAll(array $query = array()) |
17
|
|
|
{ |
18
|
|
|
$request = new GetJson('/admin/custom_collections.json', $query); |
19
|
|
|
$response = $this->sendPaged($request, 'custom_collections'); |
20
|
|
|
return $this->createCollection($response); |
21
|
|
|
} |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* @param array $query |
25
|
|
|
* @return int |
26
|
|
|
*/ |
27
|
|
|
public function countAll(array $query = array()) |
28
|
|
|
{ |
29
|
|
|
$request = new GetJson('/admin/custom_collections/count.json', $query); |
30
|
|
|
$response = $this->send($request); |
31
|
|
|
return $response->get('count'); |
|
|
|
|
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* @param int $customCollectionId |
36
|
|
|
* @return \CodeCloud\Bundle\ShopifyBundle\Api\GenericResource |
37
|
|
|
*/ |
38
|
|
|
public function findOne($customCollectionId) |
39
|
|
|
{ |
40
|
|
|
$request = new GetJson('/admin/custom_collections/' . $customCollectionId . '.json'); |
41
|
|
|
$response = $this->send($request); |
42
|
|
|
return $this->createEntity($response->get('custom_collection')); |
|
|
|
|
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* @param GenericResource $customCollection |
47
|
|
|
* @return \CodeCloud\Bundle\ShopifyBundle\Api\GenericResource |
48
|
|
|
*/ |
49
|
|
|
public function create(GenericResource $customCollection) |
50
|
|
|
{ |
51
|
|
|
$request = new PostJson('/admin/custom_collections.json', array('custom_collection' => $customCollection->toArray())); |
52
|
|
|
$response = $this->send($request); |
53
|
|
|
return $this->createEntity($response->get('custom_collection')); |
|
|
|
|
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* @param int $customCollectionId |
58
|
|
|
* @param \CodeCloud\Bundle\ShopifyBundle\Api\GenericResource $customCollection |
59
|
|
|
* @return GenericResource |
60
|
|
|
*/ |
61
|
|
|
public function update($customCollectionId, GenericResource $customCollection) |
62
|
|
|
{ |
63
|
|
|
$request = new PutJson('/admin/custom_collections/' . $customCollectionId . '.json', array('custom_collection' => $customCollection->toArray())); |
64
|
|
|
$response = $this->send($request); |
65
|
|
|
return $this->createEntity($response->get('custom_collection')); |
|
|
|
|
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* @param int $customCollectionId |
70
|
|
|
*/ |
71
|
|
|
public function delete($customCollectionId) |
72
|
|
|
{ |
73
|
|
|
$request = new DeleteParams('/admin/custom_collections/' . $customCollectionId . '.json'); |
74
|
|
|
$this->send($request); |
75
|
|
|
} |
76
|
|
|
} |
77
|
|
|
|