/** * @inheritdoc */ public function getTokens() { $request = $this->createNewRequest(); $request->setMethod(Request::METHOD_GET); $request->setPath('tokens'); $this->addIdentityHeader($request); $this->addSignatureHeader($request); $this->request = $request; $this->response = $this->sendRequest($this->request); $body = json_decode($this->response->getBody(), true); if (empty($body['data'])) { throw new \Exception('Error with request: no data returned'); } $tokens = array(); array_walk($body['data'], function ($value, $key) use(&$tokens) { $key = current(array_keys($value)); $value = current(array_values($value)); $token = new \Bitpay\Token(); $token->setFacade($key)->setToken($value); $tokens[$token->getFacade()] = $token; }); return $tokens; }