Exemple #1
0
 public function token()
 {
     $config = TinyConfig::get('initial_setting');
     $contents = $this->delegator->postForm('/auth/token', ['client_id' => $config['client_id'], 'client_secret' => $config['client_secret'], 'username' => $config['username'], 'password' => $config['password'], 'grant_type' => $config['grant_type'], 'device_token' => $config['device_token']])->getBody()->getContents();
     $response = json_decode($contents, true)['response'];
     return new AuthEntity($response);
 }
Exemple #2
0
 /**
  * @param  string                               $link
  * @throws \TinyConfig\TinyConfigEmptyException
  * @throws \Yo\Exception\BadResponseException
  */
 private function sendYo($link = '')
 {
     $yoConfig = ['token' => TinyConfig::get('yo_api_token')];
     if (!empty($link)) {
         $yoConfig['link'] = $link;
     }
     $yoClient = new Yo($yoConfig);
     (new SendYoService($yoClient->getHttpClient(), $yoClient->getOptions()))->yo(TinyConfig::get('sendUser'));
 }
Exemple #3
0
 public function search($params)
 {
     $contents = $this->delegator->get("/v1/search/works.json", $params, ['Proxy-Connection' => 'keep-alive', 'Authorization' => 'Bearer ' . TinyConfig::get('token')])->getBody()->getContents();
     return new Search(json_decode($contents, true));
 }
            expect(TinyConfig::has('hello'))->to->ok();
        });
        it('should return false with unset value', function () {
            expect(TinyConfig::has('unknownKey'))->not->to->ok();
        });
    });
    context('getAll', function () {
        it('should all set values array', function () {
            $expected = ['hello' => 'world', 'foo' => 'bar'];
            expect(TinyConfig::getAll())->to->equal($expected);
        });
    });
    context('getKeys', function () {
        it('should return all keys array', function () {
            expect(TinyConfig::getKeys())->to->equal(['hello', 'foo']);
        });
    });
    context('delete', function () {
        it('should unset value', function () {
            TinyConfig::set('a', 'b');
            TinyConfig::delete('a');
            expect(TinyConfig::getKeys())->to->equal(['hello', 'foo']);
        });
    });
    context('delete all', function () {
        it('should unset all values', function () {
            TinyConfig::deleteAll();
            expect(TinyConfig::getAll())->to->empty();
        });
    });
});
Exemple #5
0
 private function retryWithToken($times, $proc)
 {
     return (new Retry())->beforeEach(function () {
         TinyConfig::set('token', $this->getAccessToken());
     })->retry($times, $proc);
 }