1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Rs\VersionEye\Api; |
4
|
|
|
|
5
|
|
|
/** |
6
|
|
|
* Products API. |
7
|
|
|
* |
8
|
|
|
* @author Robert Schönthal <[email protected]> |
9
|
|
|
* |
10
|
|
|
* @see https://www.versioneye.com/api/v2/swagger_doc/products |
11
|
|
|
*/ |
12
|
|
|
class Products extends BaseApi implements Api |
13
|
|
|
{ |
14
|
|
|
/** |
15
|
|
|
* search packages. |
16
|
|
|
* |
17
|
|
|
* @param string $query |
18
|
|
|
* @param string $language |
19
|
|
|
* @param string $group |
20
|
|
|
* |
21
|
|
|
* @return array |
22
|
|
|
*/ |
23
|
1 |
|
public function search($query, $language = null, $group = null) |
24
|
|
|
{ |
25
|
1 |
|
$url = sprintf('products/search/%s?%s', $query, http_build_query([ |
26
|
1 |
|
'lang' => $language, |
27
|
1 |
|
'g' => $group, |
28
|
1 |
|
'page' => 1, |
29
|
|
|
])); |
30
|
|
|
|
31
|
1 |
|
return $this->request($url); |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* detailed information for specific package. |
36
|
|
|
* |
37
|
|
|
* @param string $language |
38
|
|
|
* @param string $product |
39
|
|
|
* |
40
|
|
|
* @return array |
41
|
|
|
*/ |
42
|
1 |
|
public function show($language, $product) |
43
|
|
|
{ |
44
|
1 |
|
return $this->request(sprintf('products/%s/%s', $language, $this->transform($product))); |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* check your following status. |
49
|
|
|
* |
50
|
|
|
* @param string $language |
51
|
|
|
* @param string $product |
52
|
|
|
* |
53
|
|
|
* @return array |
54
|
|
|
*/ |
55
|
1 |
|
public function followStatus($language, $product) |
56
|
|
|
{ |
57
|
1 |
|
return $this->request(sprintf('products/%s/%s/follow', $language, $this->transform($product))); |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* follow your favorite software package. |
62
|
|
|
* |
63
|
|
|
* @param string $language |
64
|
|
|
* @param string $product |
65
|
|
|
* |
66
|
|
|
* @return array |
67
|
|
|
*/ |
68
|
1 |
|
public function follow($language, $product) |
69
|
|
|
{ |
70
|
1 |
|
return $this->request(sprintf('products/%s/%s/follow', $language, $this->transform($product)), 'POST'); |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
/** |
74
|
|
|
* unfollow given software package. |
75
|
|
|
* |
76
|
|
|
* @param string $language |
77
|
|
|
* @param string $product |
78
|
|
|
* |
79
|
|
|
* @return array |
80
|
|
|
*/ |
81
|
1 |
|
public function unfollow($language, $product) |
82
|
|
|
{ |
83
|
1 |
|
return $this->request(sprintf('products/%s/%s/follow', $language, $this->transform($product)), 'DELETE'); |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
/** |
87
|
|
|
* shows all references for the given package. |
88
|
|
|
* |
89
|
|
|
* @param string $language |
90
|
|
|
* @param string $product |
91
|
|
|
* |
92
|
|
|
* @return array |
93
|
|
|
*/ |
94
|
1 |
|
public function references($language, $product) |
95
|
|
|
{ |
96
|
1 |
|
return $this->request(sprintf('products/%s/%s/references?page=%d', $language, $this->transform($product), 1)); |
97
|
|
|
} |
98
|
|
|
|
99
|
|
|
/** |
100
|
|
|
* shows all version for the given package. |
101
|
|
|
* |
102
|
|
|
* @param string $language |
103
|
|
|
* @param string $product |
104
|
|
|
* |
105
|
|
|
* @return array |
106
|
|
|
*/ |
107
|
1 |
|
public function versions($language, $product) |
108
|
|
|
{ |
109
|
1 |
|
return $this->request(sprintf('products/%s/%s/versions', $language, $this->transform($product))); |
110
|
|
|
} |
111
|
|
|
} |
112
|
|
|
|