Class: EverSdk::Client::AppRequestResult
- Inherits:
-
Object
- Object
- EverSdk::Client::AppRequestResult
- Defined in:
- lib/ever_sdk_client/client.rb
Constant Summary collapse
- TYPES =
[:ok, :error]
Instance Attribute Summary collapse
-
#result ⇒ Object
readonly
Returns the value of attribute result.
-
#text ⇒ Object
readonly
Returns the value of attribute text.
-
#type_ ⇒ Object
readonly
Returns the value of attribute type_.
Instance Method Summary collapse
-
#initialize(type_:, result: nil, text: nil) ⇒ AppRequestResult
constructor
A new instance of AppRequestResult.
- #to_h ⇒ Object
Constructor Details
#initialize(type_:, result: nil, text: nil) ⇒ AppRequestResult
Returns a new instance of AppRequestResult.
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/ever_sdk_client/client.rb', line 67 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 |
Instance Attribute Details
#result ⇒ Object (readonly)
Returns the value of attribute result.
65 66 67 |
# File 'lib/ever_sdk_client/client.rb', line 65 def result @result end |
#text ⇒ Object (readonly)
Returns the value of attribute text.
65 66 67 |
# File 'lib/ever_sdk_client/client.rb', line 65 def text @text end |
#type_ ⇒ Object (readonly)
Returns the value of attribute type_.
65 66 67 |
# File 'lib/ever_sdk_client/client.rb', line 65 def type_ @type_ end |
Instance Method Details
#to_h ⇒ Object
84 85 86 87 88 89 90 91 92 |
# File 'lib/ever_sdk_client/client.rb', line 84 def to_h { type: Helper.sym_to_capitalized_case_str(@type_), # may be either one instead? result: @result, text: @text } end |