コード例 #1
0
ファイル: API.php プロジェクト: vantoozz/oboom-php-sdk
 /**
  * @param       $endpoint
  * @param       $method
  * @param array $params
  *
  * @return mixed
  */
 public function call($endpoint, $method, array $params = [])
 {
     if (!in_array($endpoint, $this->endpoints)) {
         throw new InvalidArgumentException('No such endpoint');
     }
     $params['token'] = $this->auth->getToken();
     return $this->transport->call('https://' . $endpoint . $method, $params);
 }
コード例 #2
0
ファイル: Auth.php プロジェクト: vantoozz/oboom-php-sdk
 /**
  * @return $this
  */
 public function login()
 {
     $data = $this->transport->call('https://' . API::ENDPOINT_WWW . '/1/login', ['auth' => $this->username, 'pass' => $this->password, 'source' => '/#app']);
     if (empty($data[1]['session'])) {
         throw new RuntimeException('API error');
     }
     $this->token = $data[1]['session'];
     return $this;
 }
コード例 #3
0
ファイル: AuthSpec.php プロジェクト: vantoozz/oboom-php-sdk
 public function it_returns_token(TransportInterface $transport)
 {
     $transport->call('https://www.oboom.com/1/login', ['auth' => '*****@*****.**', 'pass' => 'f9cc0aeaefc9fb9cab93bc1f3c426958', 'source' => '/#app'])->shouldBeCalled()->willReturn([0 => 200, 1 => ['session' => 'cb597b3e-cfc4-4329-abe0-5dc2b64a8e9a']]);
     $this->setConfig(['username' => '*****@*****.**', 'password' => '1234567'])->login();
     $this->getToken()->shouldReturn('cb597b3e-cfc4-4329-abe0-5dc2b64a8e9a');
 }
コード例 #4
0
ファイル: APISpec.php プロジェクト: vantoozz/oboom-php-sdk
 public function it_make_api_calls(TransportInterface $transport, Auth $auth)
 {
     $auth->getToken()->willReturn('cb597b3e-cfc4-4329-abe0-5dc2b64a8e9a');
     $transport->call('https://api.oboom.com/method', ['param1' => 'aaa', 'param2' => 'bbb', 'token' => 'cb597b3e-cfc4-4329-abe0-5dc2b64a8e9a'])->shouldBeCalled();
     $this->call('api.oboom.com', '/method', ['param1' => 'aaa', 'param2' => 'bbb']);
 }