request() public method

Make a custom api request.
public request ( string $method, string $uri, array $headers = [], string | Psr\Http\Message\StreamInterface | null $body = null ) : array
$method string HTTP Method
$uri string URI template
$headers array
$body string | Psr\Http\Message\StreamInterface | null
return array
コード例 #1
0
 /**
  * Export all information about devices in a CSV format for your application.
  *
  * Application auth key must be set.
  *
  * @return array
  */
 public function csvExport()
 {
     return $this->api->request('POST', '/players/csv_export', ['headers' => ['Authorization' => 'Basic ' . $this->api->getConfig()->getApplicationAuthKey()], 'json' => ['app_id' => $this->api->getConfig()->getApplicationId()]]);
 }
コード例 #2
0
 /**
  * Increment the device's total session length.
  *
  * @param string $id   Device ID
  * @param array  $data Device data
  *
  * @return array
  */
 public function onFocus($id, array $data)
 {
     $data = (new OptionsResolver())->setDefault('state', 'ping')->setRequired('active_time')->setAllowedTypes('active_time', 'int')->resolve($data);
     return $this->api->request('PUT', '/players/' . $id . '/on_focus', ['headers' => ['Content-Type' => 'application/json'], 'json' => $data]);
 }
コード例 #3
0
 /**
  * Cancel notification.
  *
  * Application authentication key and ID must be set.
  *
  * @param string $id Notification ID
  *
  * @return array
  */
 public function cancel($id)
 {
     return $this->api->request('DELETE', '/notifications/' . $id, ['headers' => ['Authorization' => 'Basic ' . $this->api->getConfig()->getApplicationAuthKey()], 'json' => ['app_id' => $this->api->getConfig()->getApplicationId()]]);
 }
コード例 #4
0
ファイル: Apps.php プロジェクト: ahilles107/onesignal-php-api
 /**
  * Update application with provided data.
  *
  * User authentication key must be set.
  *
  * @param string $id   ID of your application
  * @param array  $data New application data
  *
  * @return \GuzzleHttp\Message\Response
  */
 public function update($id, array $data)
 {
     $data = $this->resolve($data);
     return $this->api->request('PUT', '/apps/' . $id, ['headers' => ['Authorization' => 'Basic ' . $this->api->getConfig()->getUserAuthKey(), 'Content-Type' => 'application/json'], 'json' => $data]);
 }