class TonSdk::Client::AppRequestResult

Constants

TYPES

Attributes

result[R]
text[R]
type_[R]

Public Class Methods

new(type_:, result: nil, text: nil) click to toggle source
# File lib/ton_sdk_client/client.rb, line 69
def initialize(type_:, result: nil, text: nil)
  unless TYPES.include?(type_)
    raise ArgumentError.new("type #{type_} is unknown; known types: #{TYPES}")
  end
  @type_ = type_

  if !result.nil? && !text.nil?
    raise ArgumentError.new("both 'result' and 'text' may not contain values at the same time")
  end

  if @type_ == :ok
    @result = result
  elsif @type_ == :error
    @text = text
  end
end

Public Instance Methods

to_h() click to toggle source
# File lib/ton_sdk_client/client.rb, line 86
def to_h
  {
    type: Helper.sym_to_capitalized_case_str(@type_),

    # may be either one instead?
    result: @result,
    text: @text
  }
end