Class: EverSdk::Crypto::CryptoBoxSecret

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

Constant Summary collapse

TYPES =
%i[random_seed_phrase predefined_seed_phrase encrypted_secret]

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of CryptoBoxSecret.



246
247
248
249
250
251
252
# File 'lib/ever_sdk_client/crypto.rb', line 246

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.



244
245
246
# File 'lib/ever_sdk_client/crypto.rb', line 244

def args
  @args
end

#typeObject (readonly)

Returns the value of attribute type.



244
245
246
# File 'lib/ever_sdk_client/crypto.rb', line 244

def type
  @type
end

Instance Method Details

#to_hObject



254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
# File 'lib/ever_sdk_client/crypto.rb', line 254

def to_h
  hash = case type
         when :random_seed_phrase
           {
             dictionary: args[:dictionary],
             wordcount: args[:wordcount]
           }
         when :predefined_seed_phrase
           {
             phrase: args[:phrase],
             dictionary: args[:dictionary],
             wordcount: args[:wordcount]
           }
         when :encrypted_secret
           {
             encrypted_secret: args[:encrypted_secret]
           }
         end
  {
    type: Helper.sym_to_capitalized_case_str(type)
  }.merge(hash)
end