Ejemplo n.º 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);
 }
Ejemplo n.º 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'));
 }
Ejemplo n.º 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));
 }
Ejemplo n.º 4
0
<?php

use TinyConfig\TinyConfig;
describe('\\TinyConfig\\TinyConfig', function () {
    beforeEach(function () {
        TinyConfig::set('hello', 'world');
        TinyConfig::set('foo', 'bar');
    });
    context('get', function () {
        it('should return set value', function () {
            expect(TinyConfig::get('hello'))->to->equal('world');
        });
        it('should throw unset value', function () {
            expect(function () {
                TinyConfig::get('unknownKey');
            })->to->throw('\\TinyConfig\\TinyConfigEmptyException');
        });
    });
    context('has', function () {
        it('should return true with set value', function () {
            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);
        });