Class: Line::Bot::V2::Webhook::ScenarioResult

Inherits:
Object
  • Object
show all
Defined in:
lib/line/bot/v2/webhook/model/scenario_result.rb

Overview

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(scenario_id: nil, revision: nil, start_time:, end_time:, result_code:, action_results: nil, ble_notification_payload: nil, error_reason: nil, **dynamic_attributes) ⇒ ScenarioResult

Returns a new instance of ScenarioResult.

Parameters:

  • scenario_id (String, nil) (defaults to: nil)

    Scenario ID executed

  • revision (Integer, nil) (defaults to: nil)

    Revision number of the scenario set containing the executed scenario

  • start_time (Integer)

    Timestamp for when execution of scenario action started (milliseconds, LINE app time)

  • end_time (Integer)

    Timestamp for when execution of scenario was completed (milliseconds, LINE app time)

  • result_code (String)

    Scenario execution completion status

  • action_results (Array[ActionResult, Hash[Symbol, untyped]], nil) (defaults to: nil)

    Execution result of individual operations specified in action. Only included when things.result.resultCode is success.

  • ble_notification_payload (String, nil) (defaults to: nil)

    Data contained in notification.

  • error_reason (String, nil) (defaults to: nil)

    Error reason.



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# File 'lib/line/bot/v2/webhook/model/scenario_result.rb', line 49

def initialize(
  scenario_id: nil,
  revision: nil,
  start_time:,
  end_time:,
  result_code:,
  action_results: nil,
  ble_notification_payload: nil,
  error_reason: nil,
  **dynamic_attributes
)
  
  @scenario_id = scenario_id
  @revision = revision
  @start_time = start_time
  @end_time = end_time
  @result_code = result_code
  @action_results = action_results&.map do |item|
    if item.is_a?(Hash)
      Line::Bot::V2::Webhook::ActionResult.create(**item) # steep:ignore InsufficientKeywordArguments
    else
      item
    end
  end
  @ble_notification_payload = ble_notification_payload
  @error_reason = error_reason

  dynamic_attributes.each do |key, value|
    self.class.attr_accessor key

    if value.is_a?(Hash)
      struct_klass = Struct.new(*value.keys.map(&:to_sym))
      struct_values = value.map { |_k, v| v.is_a?(Hash) ? Line::Bot::V2::Utils.hash_to_struct(v) : v }
      instance_variable_set("@#{key}", struct_klass.new(*struct_values))
    else
      instance_variable_set("@#{key}", value)
    end
  end
end

Instance Attribute Details

#action_resultsArray[ActionResult]?

Returns Execution result of individual operations specified in action. Only included when things.result.resultCode is success.

Returns:

  • (Array[ActionResult], nil)

    Execution result of individual operations specified in action. Only included when things.result.resultCode is success.



33
34
35
# File 'lib/line/bot/v2/webhook/model/scenario_result.rb', line 33

def action_results
  @action_results
end

#ble_notification_payloadString?

Returns Data contained in notification.

Returns:

  • (String, nil)

    Data contained in notification.



36
37
38
# File 'lib/line/bot/v2/webhook/model/scenario_result.rb', line 36

def ble_notification_payload
  @ble_notification_payload
end

#end_timeInteger

Returns Timestamp for when execution of scenario was completed (milliseconds, LINE app time).

Returns:

  • (Integer)

    Timestamp for when execution of scenario was completed (milliseconds, LINE app time)



27
28
29
# File 'lib/line/bot/v2/webhook/model/scenario_result.rb', line 27

def end_time
  @end_time
end

#error_reasonString?

Returns Error reason.

Returns:

  • (String, nil)

    Error reason.



39
40
41
# File 'lib/line/bot/v2/webhook/model/scenario_result.rb', line 39

def error_reason
  @error_reason
end

#result_codeString

Returns Scenario execution completion status.

Returns:

  • (String)

    Scenario execution completion status



30
31
32
# File 'lib/line/bot/v2/webhook/model/scenario_result.rb', line 30

def result_code
  @result_code
end

#revisionInteger?

Returns Revision number of the scenario set containing the executed scenario.

Returns:

  • (Integer, nil)

    Revision number of the scenario set containing the executed scenario



21
22
23
# File 'lib/line/bot/v2/webhook/model/scenario_result.rb', line 21

def revision
  @revision
end

#scenario_idString?

Returns Scenario ID executed.

Returns:

  • (String, nil)

    Scenario ID executed



18
19
20
# File 'lib/line/bot/v2/webhook/model/scenario_result.rb', line 18

def scenario_id
  @scenario_id
end

#start_timeInteger

Returns Timestamp for when execution of scenario action started (milliseconds, LINE app time).

Returns:

  • (Integer)

    Timestamp for when execution of scenario action started (milliseconds, LINE app time)



24
25
26
# File 'lib/line/bot/v2/webhook/model/scenario_result.rb', line 24

def start_time
  @start_time
end

Class Method Details

.create(args) ⇒ Line::Bot::V2::Webhook::ScenarioResult

Create an instance of the class from a hash

Parameters:

  • args (Hash)

    Hash containing all the required attributes

Returns:



92
93
94
95
# File 'lib/line/bot/v2/webhook/model/scenario_result.rb', line 92

def self.create(args) # steep:ignore
  symbolized_args = Line::Bot::V2::Utils.deep_symbolize(args)
  return new(**symbolized_args) # steep:ignore
end

Instance Method Details

#==(other) ⇒ Boolean

Returns true if the objects are equal, false otherwise.

Parameters:

  • other (Object)

    Object to compare

Returns:

  • (Boolean)

    true if the objects are equal, false otherwise



99
100
101
102
103
104
105
# File 'lib/line/bot/v2/webhook/model/scenario_result.rb', line 99

def ==(other)
  return false unless self.class == other.class

  instance_variables.all? do |var|
      instance_variable_get(var) == other.instance_variable_get(var)
  end
end

#hashInteger

Returns Hash code of the object.

Returns:

  • (Integer)

    Hash code of the object



108
109
110
# File 'lib/line/bot/v2/webhook/model/scenario_result.rb', line 108

def hash
  [self.class, *instance_variables.map { |var| instance_variable_get(var) }].hash
end