Class: EverSdk::Debot::ParamsOfAppDebotBrowser

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

Constant Summary collapse

TYPE_VALUES =
[
  :log,
  :switch,
  :switch_completed,
  :show_action,
  :input,
  :get_signing_box,
  :invoke_debot,
  :send,
  :approve
]

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#actionObject (readonly)

Returns the value of attribute action.



115
116
117
# File 'lib/ever_sdk_client/debot.rb', line 115

def action
  @action
end

#activityObject (readonly)

Returns the value of attribute activity.



115
116
117
# File 'lib/ever_sdk_client/debot.rb', line 115

def activity
  @activity
end

#context_idObject (readonly)

Returns the value of attribute context_id.



115
116
117
# File 'lib/ever_sdk_client/debot.rb', line 115

def context_id
  @context_id
end

#debot_addrObject (readonly)

Returns the value of attribute debot_addr.



115
116
117
# File 'lib/ever_sdk_client/debot.rb', line 115

def debot_addr
  @debot_addr
end

#messageObject (readonly)

Returns the value of attribute message.



115
116
117
# File 'lib/ever_sdk_client/debot.rb', line 115

def message
  @message
end

#msgObject (readonly)

Returns the value of attribute msg.



115
116
117
# File 'lib/ever_sdk_client/debot.rb', line 115

def msg
  @msg
end

#promptObject (readonly)

Returns the value of attribute prompt.



115
116
117
# File 'lib/ever_sdk_client/debot.rb', line 115

def prompt
  @prompt
end

#typeObject (readonly)

Returns the value of attribute type.



115
116
117
# File 'lib/ever_sdk_client/debot.rb', line 115

def type
  @type
end

Class Method Details

.from_json(j) ⇒ Object



173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
# File 'lib/ever_sdk_client/debot.rb', line 173

def self.from_json(j)
  return nil if j.nil?

  tp = self.parse_type(j["type"])
  case tp
  when :log
    self.new_with_type_log(j["msg"])

  when :switch
    self.new_with_type_switch(j["context_id"])

  when :switch_completed
    self.new_with_type_switch_completed

  when :show_action
    self.new_with_type_show_action(DebotAction.from_json(j["action"]))

  when :input
    self.new_with_type_input(j["prompt"])

  when :get_signing_box
    self.new_with_type_get_signing_box

  when :invoke_debot
    self.new_with_type_invoke_debot(j["debot_addr"], DebotAction.from_json(j["action"]))

  when :send
    self.new_with_type_send(j["message"])

  when :approve
    self.new_with_type_send(DebotActivity.from_json(j["activity"]))

  else
    raise ArgumentError.new("no handler for type: #{tp}")
  end
end

.new_with_type_approve(activity) ⇒ Object



156
157
158
159
# File 'lib/ever_sdk_client/debot.rb', line 156

def self.new_with_type_approve(activity)
  @type = :approve
  @activity = activity
end

.new_with_type_get_signing_boxObject



141
142
143
# File 'lib/ever_sdk_client/debot.rb', line 141

def self.new_with_type_get_signing_box
  @type = :get_signing_box
end

.new_with_type_input(prompt) ⇒ Object



136
137
138
139
# File 'lib/ever_sdk_client/debot.rb', line 136

def self.new_with_type_input(prompt)
  @type = :input
  @prompt = prompt
end

.new_with_type_invoke_debot(debot_addr, action) ⇒ Object



145
146
147
148
149
# File 'lib/ever_sdk_client/debot.rb', line 145

def self.new_with_type_invoke_debot(debot_addr, action)
  @type = :invoke_debot
  @debot_addr = debot_addr
  @action = action
end

.new_with_type_log(msg) ⇒ Object



117
118
119
120
# File 'lib/ever_sdk_client/debot.rb', line 117

def self.new_with_type_log(msg)
  @type = :log
  @msg = msg
end

.new_with_type_send(message) ⇒ Object



151
152
153
154
# File 'lib/ever_sdk_client/debot.rb', line 151

def self.new_with_type_send(message)
  @type = :send
  @message = message
end

.new_with_type_show_action(action) ⇒ Object



131
132
133
134
# File 'lib/ever_sdk_client/debot.rb', line 131

def self.new_with_type_show_action(action)
  @type = :show_action
  @action = action
end

.new_with_type_switch(context_id) ⇒ Object



122
123
124
125
# File 'lib/ever_sdk_client/debot.rb', line 122

def self.new_with_type_switch(context_id)
  @type = :switch
  @context_id = context_id
end

.new_with_type_switch_completedObject



127
128
129
# File 'lib/ever_sdk_client/debot.rb', line 127

def self.new_with_type_switch_completed
  @type = :switch_completed
end

Instance Method Details

#to_hObject



161
162
163
164
165
166
167
168
169
170
171
# File 'lib/ever_sdk_client/debot.rb', line 161

def to_h
  {
    type: Helper.sym_to_capitalized_case_str(type),
    msg: msg,
    context_id: context_id,
    action: action,
    prompt: prompt,
    debot_addr: debot_addr,
    message: message
  }
end