Class: Virgil::SDK::Client::Requests::CreateCardRequest
- Inherits:
-
SignableRequest
- Object
- SignableRequest
- Virgil::SDK::Client::Requests::CreateCardRequest
- Defined in:
- lib/virgil/sdk/client/requests/create_card_request.rb
Overview
Create card signable API request.
Instance Attribute Summary collapse
-
#data ⇒ Object
Returns the value of attribute data.
-
#identity ⇒ Object
Returns the value of attribute identity.
-
#identity_type ⇒ Object
Returns the value of attribute identity_type.
-
#info ⇒ Object
Returns the value of attribute info.
-
#public_key ⇒ Object
Returns the value of attribute public_key.
-
#scope ⇒ Object
Returns the value of attribute scope.
Attributes inherited from SignableRequest
#relations, #signatures, #snapshot, #validation_token
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(attributes) ⇒ CreateCardRequest
constructor
Initializes a new instance of the class.
-
#restore_from_snapshot_model(snapshot_model) ⇒ Object
Restores request from snapshot model.
-
#snapshot_model ⇒ Hash
Constructs snapshot model for exporting and signing.
Methods inherited from SignableRequest
#export, #request_model, #restore, #sign_with, #take_snapshot
Constructor Details
#initialize(attributes) ⇒ CreateCardRequest
Initializes a new instance of the class.
45 46 47 48 49 50 51 52 53 |
# File 'lib/virgil/sdk/client/requests/create_card_request.rb', line 45 def initialize(attributes) super() self.identity = attributes[:identity] self.identity_type = attributes[:identity_type] self.public_key = attributes[:raw_public_key] self.scope = attributes[:scope] || Card::APPLICATION self.data = attributes[:data] self.info = attributes[:info] end |
Instance Attribute Details
#data ⇒ Object
Returns the value of attribute data
41 42 43 |
# File 'lib/virgil/sdk/client/requests/create_card_request.rb', line 41 def data @data end |
#identity ⇒ Object
Returns the value of attribute identity
41 42 43 |
# File 'lib/virgil/sdk/client/requests/create_card_request.rb', line 41 def identity @identity end |
#identity_type ⇒ Object
Returns the value of attribute identity_type
41 42 43 |
# File 'lib/virgil/sdk/client/requests/create_card_request.rb', line 41 def identity_type @identity_type end |
#info ⇒ Object
Returns the value of attribute info
41 42 43 |
# File 'lib/virgil/sdk/client/requests/create_card_request.rb', line 41 def info @info end |
#public_key ⇒ Object
Returns the value of attribute public_key
41 42 43 |
# File 'lib/virgil/sdk/client/requests/create_card_request.rb', line 41 def public_key @public_key end |
#scope ⇒ Object
Returns the value of attribute scope
41 42 43 |
# File 'lib/virgil/sdk/client/requests/create_card_request.rb', line 41 def scope @scope end |
Class Method Details
.import(data_base64) ⇒ Object
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/virgil/sdk/client/requests/create_card_request.rb', line 68 def self.import(data_base64) request = new({}) begin request_model = JSON.parse(Base64.decode64(data_base64)) rescue JSON::ParserError => e raise ArgumentError.new("data_base64 is not valid") end validation_token = nil if request_model['meta']['validation'] && request_model['meta']['validation']['token'] validation_token = Virgil::Crypto::Bytes.from_base64(request_model['meta']['validation']['token']) end request.restore(Virgil::Crypto::Bytes.from_base64(request_model['content_snapshot']), request_model['meta']['signs'], validation_token, request_model['meta']['relations'] ) request end |
Instance Method Details
#restore_from_snapshot_model(snapshot_model) ⇒ Object
Restores request from snapshot model.
58 59 60 61 62 63 64 65 |
# File 'lib/virgil/sdk/client/requests/create_card_request.rb', line 58 def restore_from_snapshot_model(snapshot_model) self.identity = snapshot_model['identity'] self.identity_type = snapshot_model['identity_type'] self.public_key = snapshot_model['public_key'] self.scope = snapshot_model['scope'] self.data = snapshot_model.fetch('data', {}) self.info = snapshot_model['info'] end |
#snapshot_model ⇒ Hash
Constructs snapshot model for exporting and signing.
90 91 92 93 94 95 96 97 98 99 100 |
# File 'lib/virgil/sdk/client/requests/create_card_request.rb', line 90 def snapshot_model model = { 'identity': identity, 'identity_type': identity_type, 'public_key': Virgil::Crypto::Bytes.new(public_key).to_base64, 'scope': scope, 'data': data } model['info'] = info if (info && info.any?) model end |