Skip to content

Commit

Permalink
update pagination to api
Browse files Browse the repository at this point in the history
  • Loading branch information
AbdullahGhanem committed Aug 12, 2021
1 parent 7ef1439 commit a89606b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 50 deletions.
18 changes: 2 additions & 16 deletions src/GfycatController.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,9 @@ public function search($query, $limit = 25, $offset = 0, $rating = null, $lang =
return Request::search('gifs', $query, $limit, $offset, $rating, $lang);
}

public function trending($limit = 25, $rating = null)
{
return Request::trending('gifs', $limit, $rating);
}

public function translate($query, $rating = null, $lang = null)
{
return Request::translate('gifs', $query, $rating, $lang);
}

public function random($query, $rating = null)
{
return Request::random('gifs', $query, $rating);
}

public function getUserFeeds($user_id)
public function getUserFeeds($user_id, $cursor = null, $count = null)
{
return Request::getUserFeeds($user_id);
return Request::getUserFeeds($user_id, $cursor, $count);
}
}
40 changes: 6 additions & 34 deletions src/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ static public function request($endpoint, array $params = [])

static public function search($query, $limit, $offset, $rating, $lang)
{
$endpoint = 'v1/' . $type . '/search';
$endpoint = 'v1/search';
$params = [
'q' => urlencode($query),
'limit' => (int)$limit,
Expand All @@ -24,40 +24,12 @@ static public function search($query, $limit, $offset, $rating, $lang)
return Request::request($endpoint, $params);
}

static public function trending($limit, $rating)
static public function getUserFeeds($user_name, $cursor, $count)
{
$endpoint = 'v1/' . $type . '/trending';
$params = [
'limit' => (int)$limit
];
isset($rating) ? $params['rating'] = urlencode($rating) : null;
return Request::request($endpoint, $params);
}

static public function translate($query, $rating, $lang)
{
$endpoint = 'v1/' . $type . '/translate';
$params = [
's' => urlencode($query)
];
isset($rating) ? $params['rating'] = urlencode($rating) : null;
isset($lang) ? $params['lang'] = urlencode($lang) : null;
$endpoint = 'v1/users/' . $user_name . '/gfycats';
$params = [];
isset($count) ? $params['count'] = urlencode($count) : null;
isset($cursor) ? $params['cursor'] = urlencode($cursor) : null;
return Request::request($endpoint, $params);
}

static public function random($query, $rating)
{
$endpoint = 'v1/' . $type . '/random';
$params = [
'tag' => urlencode($query)
];
isset($rating) ? $params['rating'] = urlencode($rating) : null;
return Request::request($endpoint, $params);
}

static public function getUserFeeds($user_name)
{
$endpoint = 'v1/users/' . $user_name. '/gfycats';
return Request::request($endpoint);
}
}

0 comments on commit a89606b

Please sign in to comment.