예제 #1
0
파일: Apps.php 프로젝트: redaktor/depot
 public function exchangeCode(Model\Server\ServerInterface $server, Model\App\ClientAppInterface $clientApp, $code)
 {
     list($apiRoot) = $server->servers();
     $payload = array('code' => $code, 'token_type' => 'mac');
     $response = $this->tentHttpClient->post($apiRoot . '/apps/' . $clientApp->id() . '/authorizations', null, json_encode($payload))->send();
     $json = json_decode($response->getBody(), true);
     return new Dto\App\ClientAuthorizationResponse($clientApp, $this->authFactory->create($json['access_token'], $json['mac_key'], $json['mac_algorithm']), $json['token_type'], $json['refresh_token'], isset($json['tent_expires_at']) ? $json['tent_expires_at'] : null);
 }
예제 #2
0
파일: Profile.php 프로젝트: redaktor/depot
 public function putProfileInfoInternal(Model\Server\ServerInterface $server, $apiRoot, Model\Entity\ProfileInfoInterface $profileInfo)
 {
     $response = $this->tentHttpClient->put($apiRoot . '/profile/' . rawurlencode($profileInfo->uri()), null, json_encode($profileInfo->content()));
     $profileInfo = new Model\Entity\ProfileInfo($profileInfo->uri(), json_decode($response->body(), true));
     if ($server instanceof Model\Server\EntityServer) {
         $server->entity()->profile()->set($profileInfo);
     }
     return $profileInfo;
 }
예제 #3
0
 public static function tryAllServers(Model\Server\ServerInterface $server, $callback, $additionalArgs = null)
 {
     foreach ($server->servers() as $target) {
         $args = array($server, $target);
         if (null !== $additionalArgs) {
             $args = array_merge($args, $additionalArgs);
         }
         return call_user_func_array($callback, $args);
     }
     throw new \RuntimeException("Unable to send to any server");
 }