Skip to content

Commit

Permalink
Add type stubs for endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
baileyherbert committed Mar 15, 2024
1 parent 6939338 commit 9b9f54a
Show file tree
Hide file tree
Showing 5 changed files with 462 additions and 4 deletions.
158 changes: 158 additions & 0 deletions src/Envato/Stubs/CatalogStub.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
<?php

namespace Herbert\Envato\Stubs;

use Herbert\Envato\ResultSet;

/**
* A collection of endpoints for browsing the Envato Market catalog.
*/
interface CatalogStub {

/**
* Returns details of, and items contained within, a public collection.
*
* ```php
* $client->catalog->collection(['id' => 12345]);
* ```
*
* @param array $parameters
* @return ResultSet
* @see https://build.envato.com/api/#market_0_getCatalogCollection
*/
public function collection(array $parameters);

/**
* Returns all details of a particular item on Envato Market.
*
* ```php
* $client->catalog->item(['id' => 12345]);
* ```
*
* @param array $parameters
* @return ResultSet
* @see https://build.envato.com/api/#market_0_getCatalogItem
*/
public function item(array $parameters);

/**
* Returns the latest available version of a theme/plugin. This is the recommended endpoint for Wordpress
* theme/plugin authors building an auto-upgrade system into their item that needs to check if a new version is
* available.
*
* ```php
* $client->catalog->item_version(['id' => 12345]);
* ```
*
* @param array $parameters
* @return ResultSet
* @see https://build.envato.com/api/#market_0_getCatalogItemVersion
*/
public function item_version(array $parameters);

/**
* Search for items.
*
* ```php
* $client->catalog->items(['site' => 'codecanyon.net', 'term' => '']);
* ```
*
* @param array $parameters
* @return ResultSet
* @see https://build.envato.com/api/#search_getSearchItem
*/
public function items(array $parameters);

/**
* Search for comments.
*
* ```php
* $client->catalog->comments(['item_id' => 12345]);
* ```
*
* @param array $parameters
* @return ResultSet
* @see https://build.envato.com/api/#search_getSearchComment
*/
public function comments(array $parameters);

/**
* Returns the popular files for a particular site. Requires a site parameter, e.g. `themeforest`.
*
* ```php
* $client->catalog->popular(['site' => 'codecanyon']);
* ```
*
* @param array $parameters
* @return ResultSet
* @see https://build.envato.com/api/#market_getPopular
*/
public function popular(array $parameters);

/**
* Lists the categories of a particular site. Requires a site parameter, e.g. `themeforest`.
*
* ```php
* $client->catalog->categories(['site' => 'codecanyon']);
* ```
*
* @param array $parameters
* @return ResultSet
* @see https://build.envato.com/api/#market_getCategories
*/
public function categories(array $parameters);

/**
* Return available licenses and prices for the given item ID.
*
* ```php
* $client->catalog->prices(['item_id' => 12345]);
* ```
*
* @param array $parameters
* @return ResultSet
* @see https://build.envato.com/api/#market_getItemPrices
*/
public function prices(array $parameters);

/**
* New files, recently uploaded to a particular site. Requires `site` and `category` parameters.
*
* ```php
* $client->catalog->newest(['site' => 'codecanyon', 'category' => 'php-scripts']);
* ```
*
* @param array $parameters
* @return ResultSet
* @see https://build.envato.com/api/#market_getNewFiles
*/
public function newest(array $parameters);

/**
* Shows the current site features.
*
* ```php
* $client->catalog->featured(['site' => 'codecanyon']);
* ```
*
* @param array $parameters
* @return ResultSet
* @see https://build.envato.com/api/#market_getFeatures
*/
public function featured(array $parameters);

/**
* Shows a random list of newly uploaded files from a particular site. Requires a site parameter, e.g.
* `themeforest`.
*
* ```php
* $client->catalog->random(['site' => 'codecanyon']);
* ```
*
* @param array $parameters
* @return ResultSet
* @see https://build.envato.com/api/#market_getRandomNewFiles
*/
public function random(array $parameters);

}
49 changes: 49 additions & 0 deletions src/Envato/Stubs/MarketStub.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?php

namespace Herbert\Envato\Stubs;

use Herbert\Envato\ResultSet;

/**
* A collection of endpoints for obtaining Envato Market statistics.
*/
interface MarketStub {

/**
* Returns the total number of subscribed users on Envato Market.
*
* ```php
* $client->market->users();
* ```
*
* @return ResultSet
* @see https://build.envato.com/api/#market_getTotalUsers
*/
public function users();

/**
* Returns the total number of items listed on Envato Market.
*
* ```php
* $client->market->items();
* ```
*
* @return ResultSet
* @see https://build.envato.com/api/#market_getTotalItems
*/
public function items();

/**
* Returns the total number of items listed on Envato Market for a specific site.
*
* ```php
* $client->market->site(['site' => 'codecanyon']);
* ```
*
* @param array $parameters
* @return ResultSet
* @see https://build.envato.com/api/#market_getNumberOfFiles
*/
public function site(array $parameters);

}
93 changes: 93 additions & 0 deletions src/Envato/Stubs/ProfileStub.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
<?php

namespace Herbert\Envato\Stubs;

use Herbert\Envato\ResultSet;

/**
* A collection of endpoints for obtaining public information about other users.
*/
interface ProfileStub {

/**
* Lists all of the **current user's** private and public collections.
*
* ```php
* $client->profile->collections();
* ```
*
* @param array $parameters
* @return ResultSet
* @see https://build.envato.com/api/#market_0_getUserCollections
*/
public function collections();

/**
* Returns details and items for any public collection, or returns details and items for one of the current user's
* private collections, by its ID.
*
* ```php
* $client->profile->collection(['id' => 12345]);
* ```
*
* @param array $parameters
* @return ResultSet
* @see https://build.envato.com/api/#market_0_getUserCollection
*/
public function collection(array $parameters);

/**
* Returns the username, country, number of sales, number of followers, location and image for a user. Requires a
* username, e.g. `collis`.
*
* ```php
* $client->profile->details(['username' => 'collis']);
* ```
*
* @param array $parameters
* @return ResultSet
* @see https://build.envato.com/api/#market_getUser
*/
public function details(array $parameters);

/**
* Returns a list of badges for the given user.
*
* ```php
* $client->profile->badges(['username' => 'baileyherbert']);
* ```
*
* @param array $parameters
* @return ResultSet
* @see https://build.envato.com/api/#market_getUserBadges
*/
public function badges(array $parameters);

/**
* Returns the number of items that the user has for sale on each Market site. Requires a username, e.g. `collis`.
*
* ```php
* $client->profile->portfolio(['username' => 'baileyherbert']);
* ```
*
* @param array $parameters
* @return ResultSet
* @see https://build.envato.com/api/#market_getUserItemsBySite
*/
public function portfolio(array $parameters);

/**
* Returns up to 1,000 of the newest files from a particular user on the target Market site. Requires a username
* and a site parameter, e.g. `collis` and `themeforest`.
*
* ```php
* $client->profile->newest(['username' => 'collis', 'site' => 'themeforest']);
* ```
*
* @param array $parameters
* @return ResultSet
* @see https://build.envato.com/api/#market_getNewFilesFromUser
*/
public function newest(array $parameters);

}
Loading

0 comments on commit 9b9f54a

Please sign in to comment.