Class: EverSdk::NativeLibResponseResult

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(result: nil, error: nil) ⇒ NativeLibResponseResult

Returns a new instance of NativeLibResponseResult.



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/ever_sdk_client/types.rb', line 23

def initialize(result: nil, error: nil)
  if !result.nil? && !error.nil?
    raise ArgumentError.new('only either argument, result or error, should be specified')
  elsif !result.nil?
    @result = result
  elsif !error.nil?
    @error = SdkError.new(
      code: error["code"],
      message: error["message"],
      data: error["data"]
    )
  else
    # Some methods like unsubscribe will trigger this error. Should be refactored
    raise ArgumentError.new('some arguments are wrong; provide either result or error')
  end

  self
end

Instance Attribute Details

#errorObject (readonly)

Returns the value of attribute error.



21
22
23
# File 'lib/ever_sdk_client/types.rb', line 21

def error
  @error
end

#resultObject (readonly)

Returns the value of attribute result.



21
22
23
# File 'lib/ever_sdk_client/types.rb', line 21

def result
  @result
end

Instance Method Details

#failure?Boolean

Returns:

  • (Boolean)


43
# File 'lib/ever_sdk_client/types.rb', line 43

def failure? = !@error.nil?

#success?Boolean

Returns:

  • (Boolean)


42
# File 'lib/ever_sdk_client/types.rb', line 42

def success? = !@result.nil?