Class: Muxi::Webhook::WebhookEvent

Inherits:
Struct
  • Object
show all
Defined in:
lib/muxi/webhook.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#clarificationObject

Returns the value of attribute clarification

Returns:

  • (Object)

    the current value of clarification



47
48
49
# File 'lib/muxi/webhook.rb', line 47

def clarification
  @clarification
end

#contentObject

Returns the value of attribute content

Returns:

  • (Object)

    the current value of content



47
48
49
# File 'lib/muxi/webhook.rb', line 47

def content
  @content
end

#errorObject

Returns the value of attribute error

Returns:

  • (Object)

    the current value of error



47
48
49
# File 'lib/muxi/webhook.rb', line 47

def error
  @error
end

#formation_idObject

Returns the value of attribute formation_id

Returns:

  • (Object)

    the current value of formation_id



47
48
49
# File 'lib/muxi/webhook.rb', line 47

def formation_id
  @formation_id
end

#processing_modeObject

Returns the value of attribute processing_mode

Returns:

  • (Object)

    the current value of processing_mode



47
48
49
# File 'lib/muxi/webhook.rb', line 47

def processing_mode
  @processing_mode
end

#processing_timeObject

Returns the value of attribute processing_time

Returns:

  • (Object)

    the current value of processing_time



47
48
49
# File 'lib/muxi/webhook.rb', line 47

def processing_time
  @processing_time
end

#rawObject

Returns the value of attribute raw

Returns:

  • (Object)

    the current value of raw



47
48
49
# File 'lib/muxi/webhook.rb', line 47

def raw
  @raw
end

#request_idObject

Returns the value of attribute request_id

Returns:

  • (Object)

    the current value of request_id



47
48
49
# File 'lib/muxi/webhook.rb', line 47

def request_id
  @request_id
end

#statusObject

Returns the value of attribute status

Returns:

  • (Object)

    the current value of status



47
48
49
# File 'lib/muxi/webhook.rb', line 47

def status
  @status
end

#timestampObject

Returns the value of attribute timestamp

Returns:

  • (Object)

    the current value of timestamp



47
48
49
# File 'lib/muxi/webhook.rb', line 47

def timestamp
  @timestamp
end

#user_idObject

Returns the value of attribute user_id

Returns:

  • (Object)

    the current value of user_id



47
48
49
# File 'lib/muxi/webhook.rb', line 47

def user_id
  @user_id
end

#webhook_urlObject

Returns the value of attribute webhook_url

Returns:

  • (Object)

    the current value of webhook_url



47
48
49
# File 'lib/muxi/webhook.rb', line 47

def webhook_url
  @webhook_url
end

Class Method Details

.from_hash(data) ⇒ Object



52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/muxi/webhook.rb', line 52

def self.from_hash(data)
  content = (data["response"] || []).map { |item| ContentItem.from_hash(item) }
  error = data["error"] ? ErrorDetails.from_hash(data["error"]) : nil
  clarification = data["status"] == "awaiting_clarification" ? Clarification.from_hash(data) : nil

  new(
    request_id: data["id"] || "",
    status: data["status"] || "unknown",
    timestamp: data["timestamp"] || 0,
    content: content,
    error: error,
    clarification: clarification,
    formation_id: data["formation_id"],
    user_id: data["user_id"],
    processing_time: data["processing_time"],
    processing_mode: data["processing_mode"] || "async",
    webhook_url: data["webhook_url"],
    raw: data
  )
end