|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace ShopifyClient\Resource; |
|
4
|
|
|
|
|
5
|
|
|
use ShopifyClient\Action\Action; |
|
6
|
|
|
use ShopifyClient\Request; |
|
7
|
|
|
|
|
8
|
|
|
/** |
|
9
|
|
|
* https://help.shopify.com/api/reference/article |
|
10
|
|
|
* |
|
11
|
|
|
* @method create(float $parentId, array $parameters = []) |
|
12
|
|
|
* @method get(float $parentId, float $childId) |
|
13
|
|
|
* @method all(float $parentId, array $parameters = []) |
|
14
|
|
|
* @method count(float $parentId) |
|
15
|
|
|
* @method update(float $parentId, float $childId, array $parameters = []) |
|
16
|
|
|
* @method tags(float $parentId, array $parameters = []) |
|
17
|
|
|
* @method authors |
|
18
|
|
|
* @method delete(float $parentId, float $childId) |
|
19
|
|
|
* |
|
20
|
|
|
* @property ArticleMetaField $metafields |
|
21
|
|
|
* @property CustomerAddress $addresses |
|
22
|
|
|
*/ |
|
23
|
|
|
class Article extends AbstractResource implements Resource |
|
24
|
|
|
{ |
|
25
|
|
|
/** |
|
26
|
|
|
* @var array |
|
27
|
|
|
*/ |
|
28
|
|
|
protected $childResources = [ |
|
29
|
|
|
'metafields' => ArticleMetaField::class, |
|
30
|
|
|
]; |
|
31
|
|
|
|
|
32
|
|
|
/** |
|
33
|
|
|
* Article constructor. |
|
34
|
|
|
* @param Request $request |
|
35
|
|
|
*/ |
|
36
|
5 |
|
public function __construct(Request $request) |
|
37
|
|
|
{ |
|
38
|
5 |
|
parent::__construct($request); |
|
39
|
|
|
|
|
40
|
5 |
|
$this->actions->add( |
|
41
|
5 |
|
'create', |
|
42
|
5 |
|
new Action( |
|
43
|
5 |
|
Request::METHOD_POST, |
|
44
|
5 |
|
'blogs/%s/articles.json', |
|
45
|
5 |
|
'article', |
|
46
|
5 |
|
'article' |
|
47
|
|
|
) |
|
48
|
|
|
); |
|
49
|
5 |
|
$this->actions->add( |
|
50
|
5 |
|
'get', |
|
51
|
5 |
|
new Action( |
|
52
|
5 |
|
Request::METHOD_GET, |
|
53
|
5 |
|
'blogs/%s/articles/%s.json', |
|
54
|
5 |
|
'article', |
|
55
|
5 |
|
'article' |
|
56
|
|
|
) |
|
57
|
|
|
); |
|
58
|
5 |
|
$this->actions->add( |
|
59
|
5 |
|
'all', |
|
60
|
5 |
|
new Action( |
|
61
|
5 |
|
Request::METHOD_GET, |
|
62
|
5 |
|
'blogs/%s/articles.json', |
|
63
|
5 |
|
'articles', |
|
64
|
5 |
|
'articles' |
|
65
|
|
|
) |
|
66
|
|
|
); |
|
67
|
5 |
|
$this->actions->add( |
|
68
|
5 |
|
'count', |
|
69
|
5 |
|
new Action( |
|
70
|
5 |
|
Request::METHOD_GET, |
|
71
|
5 |
|
'blogs/%s/articles/count.json', |
|
72
|
5 |
|
'count', |
|
73
|
5 |
|
'count' |
|
74
|
|
|
) |
|
75
|
|
|
); |
|
76
|
5 |
|
$this->actions->add( |
|
77
|
5 |
|
'update', |
|
78
|
5 |
|
new Action( |
|
79
|
5 |
|
Request::METHOD_PUT, |
|
80
|
5 |
|
'blogs/%s/articles/%s.json', |
|
81
|
5 |
|
'article', |
|
82
|
5 |
|
'article' |
|
83
|
|
|
) |
|
84
|
|
|
); |
|
85
|
5 |
|
$this->actions->add( |
|
86
|
5 |
|
'tags', |
|
87
|
5 |
|
new Action( |
|
88
|
5 |
|
Request::METHOD_GET, |
|
89
|
5 |
|
'blogs/%s/articles/tags.json', |
|
90
|
5 |
|
'tags', |
|
91
|
5 |
|
'tags' |
|
92
|
|
|
) |
|
93
|
|
|
); |
|
94
|
5 |
|
$this->actions->add( |
|
95
|
5 |
|
'authors', |
|
96
|
5 |
|
new Action( |
|
97
|
5 |
|
Request::METHOD_GET, |
|
98
|
5 |
|
'articles/authors.json', |
|
99
|
5 |
|
'authors', |
|
100
|
5 |
|
'authors' |
|
101
|
|
|
) |
|
102
|
|
|
); |
|
103
|
5 |
|
$this->actions->add( |
|
104
|
5 |
|
'delete', |
|
105
|
5 |
|
new Action( |
|
106
|
5 |
|
Request::METHOD_DELETE, |
|
107
|
5 |
|
'blogs/%s/articles/%s.json' |
|
108
|
|
|
) |
|
109
|
|
|
); |
|
110
|
5 |
|
} |
|
111
|
|
|
} |
|
112
|
|
|
|