Skip to content

Commit 9b9f54a

Browse files
committed
Add type stubs for endpoints
1 parent 6939338 commit 9b9f54a

File tree

5 files changed

+462
-4
lines changed

5 files changed

+462
-4
lines changed

src/Envato/Stubs/CatalogStub.php

Lines changed: 158 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,158 @@
1+
<?php
2+
3+
namespace Herbert\Envato\Stubs;
4+
5+
use Herbert\Envato\ResultSet;
6+
7+
/**
8+
* A collection of endpoints for browsing the Envato Market catalog.
9+
*/
10+
interface CatalogStub {
11+
12+
/**
13+
* Returns details of, and items contained within, a public collection.
14+
*
15+
* ```php
16+
* $client->catalog->collection(['id' => 12345]);
17+
* ```
18+
*
19+
* @param array $parameters
20+
* @return ResultSet
21+
* @see https://build.envato.com/api/#market_0_getCatalogCollection
22+
*/
23+
public function collection(array $parameters);
24+
25+
/**
26+
* Returns all details of a particular item on Envato Market.
27+
*
28+
* ```php
29+
* $client->catalog->item(['id' => 12345]);
30+
* ```
31+
*
32+
* @param array $parameters
33+
* @return ResultSet
34+
* @see https://build.envato.com/api/#market_0_getCatalogItem
35+
*/
36+
public function item(array $parameters);
37+
38+
/**
39+
* Returns the latest available version of a theme/plugin. This is the recommended endpoint for Wordpress
40+
* theme/plugin authors building an auto-upgrade system into their item that needs to check if a new version is
41+
* available.
42+
*
43+
* ```php
44+
* $client->catalog->item_version(['id' => 12345]);
45+
* ```
46+
*
47+
* @param array $parameters
48+
* @return ResultSet
49+
* @see https://build.envato.com/api/#market_0_getCatalogItemVersion
50+
*/
51+
public function item_version(array $parameters);
52+
53+
/**
54+
* Search for items.
55+
*
56+
* ```php
57+
* $client->catalog->items(['site' => 'codecanyon.net', 'term' => '']);
58+
* ```
59+
*
60+
* @param array $parameters
61+
* @return ResultSet
62+
* @see https://build.envato.com/api/#search_getSearchItem
63+
*/
64+
public function items(array $parameters);
65+
66+
/**
67+
* Search for comments.
68+
*
69+
* ```php
70+
* $client->catalog->comments(['item_id' => 12345]);
71+
* ```
72+
*
73+
* @param array $parameters
74+
* @return ResultSet
75+
* @see https://build.envato.com/api/#search_getSearchComment
76+
*/
77+
public function comments(array $parameters);
78+
79+
/**
80+
* Returns the popular files for a particular site. Requires a site parameter, e.g. `themeforest`.
81+
*
82+
* ```php
83+
* $client->catalog->popular(['site' => 'codecanyon']);
84+
* ```
85+
*
86+
* @param array $parameters
87+
* @return ResultSet
88+
* @see https://build.envato.com/api/#market_getPopular
89+
*/
90+
public function popular(array $parameters);
91+
92+
/**
93+
* Lists the categories of a particular site. Requires a site parameter, e.g. `themeforest`.
94+
*
95+
* ```php
96+
* $client->catalog->categories(['site' => 'codecanyon']);
97+
* ```
98+
*
99+
* @param array $parameters
100+
* @return ResultSet
101+
* @see https://build.envato.com/api/#market_getCategories
102+
*/
103+
public function categories(array $parameters);
104+
105+
/**
106+
* Return available licenses and prices for the given item ID.
107+
*
108+
* ```php
109+
* $client->catalog->prices(['item_id' => 12345]);
110+
* ```
111+
*
112+
* @param array $parameters
113+
* @return ResultSet
114+
* @see https://build.envato.com/api/#market_getItemPrices
115+
*/
116+
public function prices(array $parameters);
117+
118+
/**
119+
* New files, recently uploaded to a particular site. Requires `site` and `category` parameters.
120+
*
121+
* ```php
122+
* $client->catalog->newest(['site' => 'codecanyon', 'category' => 'php-scripts']);
123+
* ```
124+
*
125+
* @param array $parameters
126+
* @return ResultSet
127+
* @see https://build.envato.com/api/#market_getNewFiles
128+
*/
129+
public function newest(array $parameters);
130+
131+
/**
132+
* Shows the current site features.
133+
*
134+
* ```php
135+
* $client->catalog->featured(['site' => 'codecanyon']);
136+
* ```
137+
*
138+
* @param array $parameters
139+
* @return ResultSet
140+
* @see https://build.envato.com/api/#market_getFeatures
141+
*/
142+
public function featured(array $parameters);
143+
144+
/**
145+
* Shows a random list of newly uploaded files from a particular site. Requires a site parameter, e.g.
146+
* `themeforest`.
147+
*
148+
* ```php
149+
* $client->catalog->random(['site' => 'codecanyon']);
150+
* ```
151+
*
152+
* @param array $parameters
153+
* @return ResultSet
154+
* @see https://build.envato.com/api/#market_getRandomNewFiles
155+
*/
156+
public function random(array $parameters);
157+
158+
}

src/Envato/Stubs/MarketStub.php

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<?php
2+
3+
namespace Herbert\Envato\Stubs;
4+
5+
use Herbert\Envato\ResultSet;
6+
7+
/**
8+
* A collection of endpoints for obtaining Envato Market statistics.
9+
*/
10+
interface MarketStub {
11+
12+
/**
13+
* Returns the total number of subscribed users on Envato Market.
14+
*
15+
* ```php
16+
* $client->market->users();
17+
* ```
18+
*
19+
* @return ResultSet
20+
* @see https://build.envato.com/api/#market_getTotalUsers
21+
*/
22+
public function users();
23+
24+
/**
25+
* Returns the total number of items listed on Envato Market.
26+
*
27+
* ```php
28+
* $client->market->items();
29+
* ```
30+
*
31+
* @return ResultSet
32+
* @see https://build.envato.com/api/#market_getTotalItems
33+
*/
34+
public function items();
35+
36+
/**
37+
* Returns the total number of items listed on Envato Market for a specific site.
38+
*
39+
* ```php
40+
* $client->market->site(['site' => 'codecanyon']);
41+
* ```
42+
*
43+
* @param array $parameters
44+
* @return ResultSet
45+
* @see https://build.envato.com/api/#market_getNumberOfFiles
46+
*/
47+
public function site(array $parameters);
48+
49+
}

src/Envato/Stubs/ProfileStub.php

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
<?php
2+
3+
namespace Herbert\Envato\Stubs;
4+
5+
use Herbert\Envato\ResultSet;
6+
7+
/**
8+
* A collection of endpoints for obtaining public information about other users.
9+
*/
10+
interface ProfileStub {
11+
12+
/**
13+
* Lists all of the **current user's** private and public collections.
14+
*
15+
* ```php
16+
* $client->profile->collections();
17+
* ```
18+
*
19+
* @param array $parameters
20+
* @return ResultSet
21+
* @see https://build.envato.com/api/#market_0_getUserCollections
22+
*/
23+
public function collections();
24+
25+
/**
26+
* Returns details and items for any public collection, or returns details and items for one of the current user's
27+
* private collections, by its ID.
28+
*
29+
* ```php
30+
* $client->profile->collection(['id' => 12345]);
31+
* ```
32+
*
33+
* @param array $parameters
34+
* @return ResultSet
35+
* @see https://build.envato.com/api/#market_0_getUserCollection
36+
*/
37+
public function collection(array $parameters);
38+
39+
/**
40+
* Returns the username, country, number of sales, number of followers, location and image for a user. Requires a
41+
* username, e.g. `collis`.
42+
*
43+
* ```php
44+
* $client->profile->details(['username' => 'collis']);
45+
* ```
46+
*
47+
* @param array $parameters
48+
* @return ResultSet
49+
* @see https://build.envato.com/api/#market_getUser
50+
*/
51+
public function details(array $parameters);
52+
53+
/**
54+
* Returns a list of badges for the given user.
55+
*
56+
* ```php
57+
* $client->profile->badges(['username' => 'baileyherbert']);
58+
* ```
59+
*
60+
* @param array $parameters
61+
* @return ResultSet
62+
* @see https://build.envato.com/api/#market_getUserBadges
63+
*/
64+
public function badges(array $parameters);
65+
66+
/**
67+
* Returns the number of items that the user has for sale on each Market site. Requires a username, e.g. `collis`.
68+
*
69+
* ```php
70+
* $client->profile->portfolio(['username' => 'baileyherbert']);
71+
* ```
72+
*
73+
* @param array $parameters
74+
* @return ResultSet
75+
* @see https://build.envato.com/api/#market_getUserItemsBySite
76+
*/
77+
public function portfolio(array $parameters);
78+
79+
/**
80+
* Returns up to 1,000 of the newest files from a particular user on the target Market site. Requires a username
81+
* and a site parameter, e.g. `collis` and `themeforest`.
82+
*
83+
* ```php
84+
* $client->profile->newest(['username' => 'collis', 'site' => 'themeforest']);
85+
* ```
86+
*
87+
* @param array $parameters
88+
* @return ResultSet
89+
* @see https://build.envato.com/api/#market_getNewFilesFromUser
90+
*/
91+
public function newest(array $parameters);
92+
93+
}

0 commit comments

Comments
 (0)