Class: Virgil::SDK::Client::Card
- Inherits:
-
Struct
- Object
- Struct
- Virgil::SDK::Client::Card
- Defined in:
- lib/virgil/sdk/client/card.rb
Overview
Model representing cards information.
Constant Summary collapse
- APPLICATION =
"application"
- GLOBAL =
"global"
- SERVICE_URL =
"https://cards.virgilsecurity.com"
- READ_ONLY_SERVICE_URL =
"https://cards-ro.virgilsecurity.com"
- RA_SERVICE_URL =
"https://ra.virgilsecurity.com"
- VRA_VERSION =
version of service, which creates and deletes local and global cards
"v1"
- VC_VERSION =
version of service, which gets, searchs card
"v4"
Instance Attribute Summary collapse
-
#data ⇒ Hash
The current value of data.
-
#device ⇒ String
The current value of device.
-
#device_name ⇒ String
The current value of device_name.
-
#id ⇒ String
The current value of id.
-
#identity ⇒ String
The current value of identity.
-
#identity_type ⇒ String
The current value of identity_type.
-
#public_key ⇒ Crypto::Bytes
The current value of public_key.
-
#relations ⇒ Hash
The current value of relations.
-
#scope ⇒ String
The current value of scope.
-
#signatures ⇒ Hash
The current value of signatures.
-
#snapshot ⇒ Hash
The current value of snapshot.
-
#validation_token ⇒ HighLevel::VirgilIdentity::ValidationToken
The current value of validation_token.
-
#version ⇒ String
The current value of version.
Class Method Summary collapse
-
.from_request_model(request_model) ⇒ Card
New card.
-
.from_response(response) ⇒ Card
Create new Card from response containing json-encoded snapshot.
Instance Method Summary collapse
-
#export ⇒ String
Base64-encoded json representation of card's content_snapshot and meta.
-
#initialize(options) ⇒ Card
constructor
Initializes a new instance of the Card class.
- #to_request ⇒ Requests::CreateCardRequest
Constructor Details
#initialize(options) ⇒ Card
Initializes a new instance of the Virgil::SDK::Client::Card class.
60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/virgil/sdk/client/card.rb', line 60 def initialize() self.id = [:id] self.snapshot = [:snapshot] self.identity = [:identity] self.identity_type = [:identity_type] self.public_key = [:public_key] self.scope = [:scope] self.data = [:data] || {} self.device = [:device] self.device_name = [:device_name] self.version = [:version] self.signatures = [:signatures] || {} self.relations = [:relations] || {} end |
Instance Attribute Details
#data ⇒ Hash
Returns the current value of data
53 54 55 |
# File 'lib/virgil/sdk/client/card.rb', line 53 def data @data end |
#device ⇒ String
Returns the current value of device
53 54 55 |
# File 'lib/virgil/sdk/client/card.rb', line 53 def device @device end |
#device_name ⇒ String
Returns the current value of device_name
53 54 55 |
# File 'lib/virgil/sdk/client/card.rb', line 53 def device_name @device_name end |
#id ⇒ String
Returns the current value of id
53 54 55 |
# File 'lib/virgil/sdk/client/card.rb', line 53 def id @id end |
#identity ⇒ String
Returns the current value of identity
53 54 55 |
# File 'lib/virgil/sdk/client/card.rb', line 53 def identity @identity end |
#identity_type ⇒ String
Returns the current value of identity_type
53 54 55 |
# File 'lib/virgil/sdk/client/card.rb', line 53 def identity_type @identity_type end |
#public_key ⇒ Crypto::Bytes
Returns the current value of public_key
53 54 55 |
# File 'lib/virgil/sdk/client/card.rb', line 53 def public_key @public_key end |
#relations ⇒ Hash
Returns the current value of relations
53 54 55 |
# File 'lib/virgil/sdk/client/card.rb', line 53 def relations @relations end |
#scope ⇒ String
Returns the current value of scope
53 54 55 |
# File 'lib/virgil/sdk/client/card.rb', line 53 def scope @scope end |
#signatures ⇒ Hash
Returns the current value of signatures
53 54 55 |
# File 'lib/virgil/sdk/client/card.rb', line 53 def signatures @signatures end |
#snapshot ⇒ Hash
Returns the current value of snapshot
53 54 55 |
# File 'lib/virgil/sdk/client/card.rb', line 53 def snapshot @snapshot end |
#validation_token ⇒ HighLevel::VirgilIdentity::ValidationToken
Returns the current value of validation_token
53 54 55 |
# File 'lib/virgil/sdk/client/card.rb', line 53 def validation_token @validation_token end |
#version ⇒ String
Returns the current value of version
53 54 55 |
# File 'lib/virgil/sdk/client/card.rb', line 53 def version @version end |
Class Method Details
.from_request_model(request_model) ⇒ Card
Returns new card.
124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 |
# File 'lib/virgil/sdk/client/card.rb', line 124 def self.from_request_model(request_model) snapshot = Base64.decode64(request_model[:content_snapshot]) snapshot_model = JSON.parse(snapshot) = request_model[:meta] info = snapshot_model.fetch("info", {}) || {} return new( snapshot: snapshot, identity: snapshot_model["identity"], identity_type: snapshot_model["identity_type"], public_key: Virgil::Crypto::Bytes.from_base64( snapshot_model["public_key"] ), device: info["device"], device_name: info["device_name"], data: snapshot_model.fetch("data", {}), scope: snapshot_model["scope"], signatures: [:signs], relations: [:relations] ) end |
.from_response(response) ⇒ Card
Create new Virgil::SDK::Client::Card from response containing json-encoded snapshot.
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
# File 'lib/virgil/sdk/client/card.rb', line 79 def self.from_response(response) snapshot = Base64.decode64(response["content_snapshot"]) snapshot_model = JSON.parse(snapshot) info = snapshot_model.fetch("info", {}) || {} return new( id: response["id"], snapshot: snapshot, identity: snapshot_model["identity"], identity_type: snapshot_model["identity_type"], public_key: Virgil::Crypto::Bytes.from_base64( snapshot_model["public_key"] ), device: info["device"], device_name: info["device_name"], data: snapshot_model.fetch("data", {}), scope: snapshot_model["scope"], version: response["meta"]["card_version"], signatures: response["meta"]["signs"], relations: response["meta"]["relations"] ) end |
Instance Method Details
#export ⇒ String
Returns base64-encoded json representation of card's content_snapshot and meta.
117 118 119 |
# File 'lib/virgil/sdk/client/card.rb', line 117 def export self.to_request.export end |
#to_request ⇒ Requests::CreateCardRequest
106 107 108 109 110 |
# File 'lib/virgil/sdk/client/card.rb', line 106 def to_request request = Virgil::SDK::Client::Requests::CreateCardRequest.new({}) request.restore(Crypto::Bytes.from_string(snapshot), signatures, validation_token, relations) request end |