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 ⇒ Object
Returns the value of attribute data.
-
#device ⇒ Object
Returns the value of attribute device.
-
#device_name ⇒ Object
Returns the value of attribute device_name.
-
#id ⇒ Object
Returns the value of attribute id.
-
#identity ⇒ Object
Returns the value of attribute identity.
-
#identity_type ⇒ Object
Returns the value of attribute identity_type.
-
#public_key ⇒ Object
Returns the value of attribute public_key.
-
#relations ⇒ Object
Returns the value of attribute relations.
-
#scope ⇒ Object
Returns the value of attribute scope.
-
#signatures ⇒ Object
Returns the value of attribute signatures.
-
#snapshot ⇒ Object
Returns the value of attribute snapshot.
-
#validation_token ⇒ Object
Returns the value of attribute validation_token.
-
#version ⇒ Object
Returns the value of attribute version.
Class Method Summary collapse
- .from_request_model(request_model) ⇒ Object
-
.from_response(response) ⇒ Object
Create new Card from response containing json-encoded snapshot.
Instance Method Summary collapse
- #export ⇒ Object
-
#initialize(options) ⇒ Card
constructor
A new instance of Card.
- #to_request ⇒ Object
Constructor Details
#initialize(options) ⇒ Card
Returns a new instance of Card.
46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/virgil/sdk/client/card.rb', line 46 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 ⇒ Object
Returns the value of attribute data
40 41 42 |
# File 'lib/virgil/sdk/client/card.rb', line 40 def data @data end |
#device ⇒ Object
Returns the value of attribute device
40 41 42 |
# File 'lib/virgil/sdk/client/card.rb', line 40 def device @device end |
#device_name ⇒ Object
Returns the value of attribute device_name
40 41 42 |
# File 'lib/virgil/sdk/client/card.rb', line 40 def device_name @device_name end |
#id ⇒ Object
Returns the value of attribute id
40 41 42 |
# File 'lib/virgil/sdk/client/card.rb', line 40 def id @id end |
#identity ⇒ Object
Returns the value of attribute identity
40 41 42 |
# File 'lib/virgil/sdk/client/card.rb', line 40 def identity @identity end |
#identity_type ⇒ Object
Returns the value of attribute identity_type
40 41 42 |
# File 'lib/virgil/sdk/client/card.rb', line 40 def identity_type @identity_type end |
#public_key ⇒ Object
Returns the value of attribute public_key
40 41 42 |
# File 'lib/virgil/sdk/client/card.rb', line 40 def public_key @public_key end |
#relations ⇒ Object
Returns the value of attribute relations
40 41 42 |
# File 'lib/virgil/sdk/client/card.rb', line 40 def relations @relations end |
#scope ⇒ Object
Returns the value of attribute scope
40 41 42 |
# File 'lib/virgil/sdk/client/card.rb', line 40 def scope @scope end |
#signatures ⇒ Object
Returns the value of attribute signatures
40 41 42 |
# File 'lib/virgil/sdk/client/card.rb', line 40 def signatures @signatures end |
#snapshot ⇒ Object
Returns the value of attribute snapshot
40 41 42 |
# File 'lib/virgil/sdk/client/card.rb', line 40 def snapshot @snapshot end |
#validation_token ⇒ Object
Returns the value of attribute validation_token
40 41 42 |
# File 'lib/virgil/sdk/client/card.rb', line 40 def validation_token @validation_token end |
#version ⇒ Object
Returns the value of attribute version
40 41 42 |
# File 'lib/virgil/sdk/client/card.rb', line 40 def version @version end |
Class Method Details
.from_request_model(request_model) ⇒ Object
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 |
# File 'lib/virgil/sdk/client/card.rb', line 103 def self.from_request_model(request_model) snapshot = Base64.decode64(request_model[:content_snapshot]) # if request_model[:content_snapshot].is_a?(Array) # snapshot = Virgil::Crypto::Bytes.new(request_model[:content_snapshot]).to_s # end 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) ⇒ Object
Create new Card from response containing json-encoded snapshot. Args:
response: Cards service response containing base64 encoded content_snapshot.
Returns:
Card model restored from snapshot.
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/virgil/sdk/client/card.rb', line 66 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 ⇒ Object
98 99 100 |
# File 'lib/virgil/sdk/client/card.rb', line 98 def export self.to_request.export end |