class Virgil::SDK::Client::Requests::CreateCardRequest
Create card signable API request.
Attributes
data[RW]
identity[RW]
identity_type[RW]
info[RW]
public_key[RW]
scope[RW]
Public Class Methods
import(data_base64)
click to toggle source
# 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
new(attributes)
click to toggle source
Constructs new CreateCardRequest
object
Calls superclass method
# File lib/virgil/sdk/client/requests/create_card_request.rb, line 44 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
Public Instance Methods
restore_from_snapshot_model(snapshot_model)
click to toggle source
Restores request from snapshot model.
Args:
snapshot_model: snapshot model dict
# 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()
click to toggle source
Constructs snapshot model for exporting and signing.
Returns:
Dict containing snapshot data model used for card creation request.
# File lib/virgil/sdk/client/requests/create_card_request.rb, line 91 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