CardClient
@objc(VSSCardClient)
open class CardClient : BaseClient
extension CardClient: CardClientProtocol
Class representing operations with Virgil Cards service
-
Default URL for service
Declaration
Swift
@objc public static let defaultURL: URL
-
Error domain for Error instances thrown from service
Declaration
Swift
override open class var serviceErrorDomain: String { get }
-
Initializes new
CardClient
instanceDeclaration
Swift
@objc public convenience init(accessTokenProvider: AccessTokenProvider)
Parameters
accessTokenProvider
Access Token Provider
-
Initializes new
CardClient
instanceDeclaration
Swift
@objc public convenience init(accessTokenProvider: AccessTokenProvider, serviceUrl: URL)
Parameters
accessTokenProvider
Access Token Provider
serviceUrl
service URL
-
Initializes new
CardClient
instanceDeclaration
Swift
public init(accessTokenProvider: AccessTokenProvider, serviceUrl: URL, connection: HttpConnectionProtocol? = nil, retryConfig: ExpBackoffRetry.Config)
Parameters
accessTokenProvider
Access Token Provider
serviceUrl
service URL
requestRetryConfig
Retry config
-
HTTP header key for getCard response that marks outdated cards
Declaration
Swift
@objc public static let xVirgilIsSuperseededKey: String
-
HTTP header value for xVirgilIsSuperseededKey key for getCard response that marks outdated cards
Declaration
Swift
@objc public static let xVirgilIsSuperseededTrue: String
-
Returns
GetCardResponse
withRawSignedModel
of card from the Virgil Cards Service with given ID, if existsThrows
CardClientError.constructingUrl
, if url initialization failed- Rethrows from
ServiceRequest
- Rethrows
ServiceError
orNSError
fromBaseClient
Declaration
Swift
open func getCard(withId cardId: String) throws -> GetCardResponse
Parameters
cardId
String with unique Virgil Card identifier
Return Value
GetCardResponse
if card found -
Creates Virgil Card instance on the Virgil Cards Service Also makes the Card accessible for search/get queries from other users
RawSignedModel
should contain appropriate signaturesThrows
CardClientError.constructingUrl
, if url initialization failed- Rethrows from
ServiceRequest
- Rethrows
ServiceError
orNSError
fromBaseClient
Declaration
Swift
open func publishCard(model: RawSignedModel) throws -> RawSignedModel
Parameters
model
Signed
RawSignedModel
Return Value
RawSignedModel
of created card -
Performs search of Virgil Cards using given identities on the Virgil Cards Service
Throws
- CardClientError.constructingUrl, if url initialization failed
- ServiceError, if service returned correctly-formed error json
- NSError with CardClient.serviceErrorDomain error domain, http status code as error code, and description string if present in http body
- Rethrows from
ServiceRequest
,HttpConnectionProtocol
,JsonDecoder
,BaseClient
Declaration
Swift
public func searchCards(identities: [String]) throws -> [RawSignedModel]
Parameters
identities
Identities of cards to search
Return Value
Array with
RawSignedModel
s of matched Virgil Cards -
Returns list of cards that were replaced with newer ones
Throws
- CardClientError.constructingUrl, if url initialization failed
- ServiceError, if service returned correctly-formed error json
- NSError with CardClient.serviceErrorDomain error domain, http status code as error code, and description string if present in http body
- Rethrows from
ServiceRequest
,HttpConnectionProtocol
,JsonDecoder
,BaseClient
Declaration
Swift
public func getOutdated(cardIds: [String]) throws -> [String]
Parameters
cardIds
card ids to check
Return Value
List of old card ids
-
Revokes card. Revoked card gets isOutdated flag to be set to true. Also, such cards could be obtained using get query, but will be absent in search query result.
Throws
- CardClientError.constructingUrl, if url initialization failed
- ServiceError, if service returned correctly-formed error json
- NSError with CardClient.serviceErrorDomain error domain, http status code as error code, and description string if present in http body
- Rethrows from
ServiceRequest
,HttpConnectionProtocol
,JsonDecoder
,BaseClient
Declaration
Swift
public func revokeCard(withId cardId: String) throws
Parameters
cardId
identifier of card to revoke