Class: EverSdk::Crypto::ParamsOfAppEncryptionBox

Inherits:
Object
  • Object
show all
Defined in:
lib/ever_sdk_client/crypto.rb

Constant Summary collapse

TYPES =
%i[get_info encrypt decrypt]

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type:, **args) ⇒ ParamsOfAppEncryptionBox

Returns a new instance of ParamsOfAppEncryptionBox.



316
317
318
319
320
321
322
# File 'lib/ever_sdk_client/crypto.rb', line 316

def initialize(type:, **args)
  unless TYPES.include?(type)
    raise ArgumentError.new("type #{type} is unknown; known types: #{TYPES}")
  end
  @type = type
  @args = args
end

Instance Attribute Details

#argsObject (readonly)

Returns the value of attribute args.



314
315
316
# File 'lib/ever_sdk_client/crypto.rb', line 314

def args
  @args
end

#typeObject (readonly)

Returns the value of attribute type.



314
315
316
# File 'lib/ever_sdk_client/crypto.rb', line 314

def type
  @type
end

Instance Method Details

#to_hObject



324
325
326
327
328
329
330
331
332
333
334
335
336
# File 'lib/ever_sdk_client/crypto.rb', line 324

def to_h
  hash = case type
         when :get_info
           {}
         when :encrypt, :decrypt
           {
             data: args[:data]
           }
         end
  {
    type: Helper.sym_to_capitalized_case_str(type)
  }.merge(hash)
end