/** * @param \SubscribePro\Service\Token\TokenInterface $token * @return \SubscribePro\Service\Token\TokenInterface * @throws \SubscribePro\Exception\EntityInvalidDataException * @throws \SubscribePro\Exception\HttpException */ public function saveToken(TokenInterface $token) { if (!$token->isValid()) { throw new EntityInvalidDataException('Not all required fields are set.'); } $response = $this->httpClient->post('/services/v1/vault/token.json', [self::API_NAME_TOKEN => $token->getFormData()]); return $this->retrieveItem($response, self::API_NAME_TOKEN, $token); }
/** * @param array $data * @param bool $isValid * @dataProvider isValidDataProvider */ public function testIsValid($data, $isValid) { $this->token->importData($data); $this->assertEquals($isValid, $this->token->isValid()); }