Returns a list of games objects sorted by number of current viewers on Twitch, most popular first.

Learn more:
https://github.com/justintv/Twitch-API/blob/master/v3_resources/games.md#get-gamestop

@param  array $params Optional parameters

@return array
343903
public function getTopGames($params = [])
  {
      $defaults = [
          'limit'  => 10,
          'offset' => 0,
      ];

      return $this->wrapper->request('GET', 'games/top', ['query' => $this->resolveOptions($params, $defaults)]);
  }
1170074
public function getRealParams(array $params)
    {
        foreach ($params as $k => $p) {
            if (is_array($p)) {
                $params[$k] = $p[1];
            }
        }

        return $params;
    }
477013
public function getRooms($params = array())
    {
        $response = $this->client->get("/v2/room", $params);

        $rooms = array();
        foreach ($response['items'] as $response) {
            $rooms[] = new Room($response);
        }
        return $rooms;
    }
66252
public function getList($params = array())
    {
        $resource = 'georegion.json';
        $resource .= '?' . $this->buildQueryString($params);
        $response = $this->getServiceResponse($resource);

        $geoRegions = new Models\ResponseGeoRegionsGet($response);

        return $geoRegions;
    }
1731
public function searchGames($query, $params = [])
  {
      $defaults = [
          'query' => urlencode($query),
          'limit' => 25,
          'type'  => 'suggest',
          'live'  => false,
      ];

      return $this->wrapper->request('GET', 'search/games', ['query' => $this->resolveOptions($params, $defaults)]);
  }
937539
public function getTransactionData($params)
    {
        $this->sdk->ServiceURL = $this->getApiEndpoint('QueryTradeInfo');
        $this->sdk->Query['MerchantTradeNo'] = $params['MerchantTradeNo'];
        $details = $this->sdk->QueryTradeInfo();
        $details['RtnCode'] = $details['TradeStatus'] === '1' ? '1' : '2';

        return $details;
    }
675106
public function getPurchaseHistoryURI($params = array()) {
        $default_params = array(
            'client_id' => $this->getClientID(),
            'response_type' => 'code',
            'redirect_uri' => $this->getCurrentURI(),
        );
        if ($this->xiti) {
            $default_params['xiti_json'] = $this->getXitiConfiguration();
        }
        $default_params['v'] = self::VERSION;
        return $this->getUrl('www', 'account/purchasehistory', array_merge($default_params, $params));
    }
431657
public function searchItems( stdClass $params )
	{
		$total = 0;
		$search = $this->_initCriteria( $this->_getManager()->createSearch(), $params );

		$sort = $search->getSortations();
		$sort[] = $search->sort( '+', 'locale.currency.label' );
		$search->setSortations( $sort );

		$items = $this->_getManager()->searchItems( $search, array(), $total );

		return array(
			'items' => $this->_toArray( $items ),
			'total' => $total,
			'success' => true,
		);
	}
749160
public function countByParams($params = [])
    {
        $this->injectParams($params);
        $query = $this->newQuery('select');
        $query->addParams($params);

        return $this->countByQuery($query);
    }
107202
public function search($params)
    {
        $query = WarehouseVoucherItems::find();
        $dataProvider = new ActiveDataProvider([
            'query' => $query,
        ]);
        $this->load($params);
        if (!$this->validate()) {
            // uncomment the following line if you do not want to return any records when validation fails
            // $query->where('0=1');
            return $dataProvider;
        }
        $query->andFilterWhere([
            'id'                   => $this->id,
            'warehouse_voucher'    => $this->warehouse_voucher,
            'warehouse_product'    => $this->warehouse_product,
            'product_unit'         => $this->product_unit,
            'product_unit_price'   => $this->product_unit_price,
            'quantity'             => $this->quantity,
            'supplier_quantity'    => $this->quantity,
            'supplier_total_price' => $this->supplier_total_price,
            'total_price'          => $this->total_price,
            'created_at'           => $this->created_at,
            'updated_at'           => $this->updated_at,
            'created_by'           => $this->created_by,
            'updated_by'           => $this->updated_by,
        ]);
        $query->andFilterWhere([
            'like',
            'currency_unit',
            $this->currency_unit,
        ]);

        return $dataProvider;
    }
22180
public function getEmoticonImages($params = [])
  {
      $defaults = [
          'emotesets' => null,
      ];

      return $this->wrapper->request('GET', 'chat/emoticon_images', ['query' => $this->resolveOptions($params, $defaults)]);
  }
1331523
public function export(array $params = array()) {
		$result = array(
			'type' => 'list',
			'count' => $this->getCount(),
			'limit' => elgg_extract('limit', $this->options, elgg_get_config('default_limit')),
			'offset' => elgg_extract('offset', $this->options, 0),
			'items' => array(),
		);

		$batch = $this->getBatch();
		foreach ($batch as $entity) {
			$result['items'][] = hypeApps()->graph->export($entity, $params);
		}

		return $result;
	}
1323069
public function all(array $params = array())
    {
        $endpoint = '/admin/locations.json';
        $response = $this->request($endpoint, 'GET', $params);
        return $this->createCollection(Location::class, $response['locations']);
    }
861297
public function getDernieresActualites($params = array())
	{
		$sqlLimit = "";
		if (isset($params['sqlLimit']) && $params['sqlLimit']!='') {
			$sqlLimit = $params['sqlLimit'];

		}

		$sqlFields = "idActualite,  titre,  date,  ".
				"photoIllustration,  texte,  urlFichier";
		if (isset($params['sqlFields']) && $params['sqlFields']!='') {
			$sqlFields = $params['sqlFields'];
		}

		$sqlWhere = "";
		if (isset($params['sqlWhere']) && $params['sqlWhere']!='') {
			$sqlWhere = $params['sqlWhere'];
		}

		$req = "SELECT $sqlFields FROM actualites ".
				"WHERE 1=1 $sqlWhere ORDER BY date DESC $sqlLimit";
		$res = $this->connexionBdd->requete($req);

		$i=0;
		if (!isset($params['returnAsMysqlRes'])
		|| $params['returnAsMysqlRes']!=true
		) {
			$retour = array();
			while ($fetch = mysql_fetch_assoc($res)) {
				$retour[$i] = $fetch;
				$i++;
			}
		} else {
			$retour = $res;
		}

		return $retour;
	}
1082628
public function search($params)
    {
        $subquery = (new Query())
                    ->select(['m2.replyto'])
                    ->from(['m1' => Message::tableName()])
                    ->leftJoin(['m2' => Message::tableName()], 'm1.replyto = m2.id')
                    ->where(['is not', 'm2.replyto', null]);
        $query = static::find()->where(['and',
            ['receiver_id' => User::loggedId()],
            ['!=', 'receiver_status', self::STATUS_DELETED],
            ['not in', 'message_id', $subquery]
        ]);
        $dataProvider = new ActiveDataProvider([
            'query' => $query,
        ]);
        $dataProvider->sort->attributes['senderName'] = [
            'asc' => [
                User::tableName() . '.username' => SORT_ASC,
                User::tableName() . '.id' => SORT_ASC
            ],
            'desc' => [
                User::tableName() . '.username' => SORT_DESC,
                User::tableName() . '.id' => SORT_DESC
            ],
            'default' => SORT_ASC
        ];
        $dataProvider->sort->defaultOrder = ['id' => SORT_DESC];
        $dataProvider->pagination->pageSize = Yii::$app->session->get('per-page', 20);

        if (!($this->load($params) && $this->validate())) {
            $dataProvider->query->joinWith(['message' => function ($q) {
                $q->joinWith(['sender']);
            }]);
            return $dataProvider;
        }

        $dataProvider->query->andFilterWhere(['like', 'topic', $this->topic]);

        if (preg_match('/^(forum|orum|rum|um|m)?#([0-9]+)$/', strtolower($this->senderName), $matches)) {
            $dataProvider->query->joinWith(['message' => function ($q) use ($matches) {
                $q->joinWith(['sender' => function ($q) use ($matches) {
                    $q->andFilterWhere(['and',
                        [User::tableName() . '.id' => $matches[2]],
                        ['or',
                            ['username' => ''],
                            ['username' => null]
                        ]
                    ]);
                }]);
            }]);
        } elseif (preg_match('/^([0-9]+)$/', $this->senderName, $matches)) {
            $dataProvider->query->joinWith(['message' => function ($q) use ($matches) {
                $q->joinWith(['sender' => function ($q) use ($matches) {
                    $q->andFilterWhere(['or',
                        ['like', 'username', $this->senderName],
                        ['and',
                            ['id' => $matches[1]],
                            ['or',
                                ['username' => ''],
                                ['username' => null]
                            ]
                        ],
                    ]);
                }]);
            }]);
        } else {
            $dataProvider->query->joinWith(['message' => function ($q) {
                $q->joinWith(['sender' => function ($q) {
                    $q->andFilterWhere(['like', User::tableName() . '.username', $this->senderName]);
                }]);
            }]);
        }
        return $dataProvider;
    }
708897
public function fetchAll($params = [])
    {
        return $this->table->select(
            function (Select $select) {
                $select->columns([]);
                $select->join(
                    $this->roleTableName,
                    sprintf('%s.role_id=%s.role_id', $this->roleTableName, $this->table->getTable())
                );
                $select->where(['user_id' => $this->getUserId()]);
            }
        );

//        $adapter = new DbSelect($select, $this->table->getAdapter());
//        return new $this->collectionClass($adapter);
    }
400438
protected function actionGet($params=array())
    {
        $response = array(
            'errors'=>array(),
            'data' => array(
                'count' => 0,
                'items' => array(),
            ),
        );
        $offset = isset($params['offset'])?(int)$params['offset']:0;
        if ($offset < 0) $offset = 0;
        $count = isset($params['count'])?(int)$params['count']:100;
        if ($count < 1) $count = 1;
        if ($count > 100) $count = 100;
        $filter = array(
            'fields' => array(),
            'offset' => $offset,
            'count' => $count,
        );
        $idsRaw = isset($params['ids'])?(string)$params['ids']:null;
        $idsRaw = preg_replace('/[^a-f0-9\,]/ui','',$idsRaw);
        $idsRaw = preg_replace('/^\,+|\,+$/ui','',$idsRaw);
        $idsRaw = preg_replace('/\,+/ui',',',$idsRaw);
        if (!empty($idsRaw)) {
            $ids = explode(',',$idsRaw);
            if (count($ids) > 1) {
                $filter['fields'][] = array(
                    'field' => 'id',
                    'compare' => 'in',
                    'value' => $ids,
                );
            } elseif (count($ids) == 1) {
                $filter['fields'][] = array(
                    'field' => 'id',
                    'compare' => '=',
                    'value' => $ids[0],
                );
            }
        }
        $street = isset($params['street'])?trim((string)$params['street']):null;
        $number = isset($params['number'])?trim((string)$params['number']):null;

        if ($street && !$number) {
            $filter['fields'][] = array(
                'field' => 'street',
                'compare' => '=',
                'value' => $street,
            );
        }
        if (!$street && $number) {
            $filter['fields'][] = array(
                'field' => 'number',
                'compare' => '=',
                'value' => $street,
            );
        }
        if ($street && $number) {
            $filter['fields'][] = array(
                'field' => 'id',
                'compare' => '=',
                'value' => $this->build->getId(array('street'=>$street,'number'=>$number)),
            );
        }
        $response['data']['count'] = $this->build->count($filter);
        $builds = $this->build->find($filter);
        $response['data']['items'] = $builds;
        return $response;
    }