Class: Zavudev::Models::Message

Inherits:
Internal::Type::BaseModel show all
Defined in:
lib/zavudev/models/message.rb,
sig/zavudev/models/message.rbs

Overview

See Also:

  • Zavudev::Resources::Messages#list

Defined Under Namespace

Modules: Direction

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Internal::Type::BaseModel

==, #==, #[], coerce, #deconstruct_keys, #deep_to_h, dump, fields, hash, #hash, inherited, inspect, #inspect, known_fields, optional, recursively_to_h, required, #to_h, #to_json, #to_s, to_sorbet_type, #to_yaml

Methods included from Internal::Type::Converter

#coerce, coerce, #dump, dump, inspect, #inspect, meta_info, new_coerce_state, type_info

Methods included from Internal::Util::SorbetRuntimeSupport

#const_missing, #define_sorbet_constant!, #sorbet_constant_defined?, #to_sorbet_type, to_sorbet_type

Constructor Details

#initialize(id:, channel:, created_at:, direction:, message_type:, status:, to:, content: nil, conversation_id: nil, cost: nil, cost_provider: nil, cost_total: nil, error_code: nil, error_message: nil, from: nil, metadata: nil, provider_message_id: nil, sender_id: nil, text: nil, updated_at: nil) ⇒ Object

Some parameter documentations has been truncated, see Zavudev::Models::Message for more details.

Parameters:

  • id (String)
  • channel (Symbol, Zavudev::Models::Channel) —

    Delivery channel. Use 'auto' for intelligent routing.

  • created_at (Time)
  • direction (Symbol, Zavudev::Models::Message::Direction) —

    Who sent the message. Needed to render a thread: status cannot tell the two ap

  • message_type (Symbol, Zavudev::Models::MessageType) —

    Type of message. Non-text types are supported by WhatsApp and Telegram (varies b

  • status (Symbol, Zavudev::Models::MessageStatus)
  • to (String)
  • content (Zavudev::Models::MessageContent) (defaults to: nil) —

    Content for non-text message types (WhatsApp and Telegram).

  • conversation_id (String) (defaults to: nil) —

    ID of the conversation (inbox thread) this message belongs to. Use it to build a

  • cost (Float, nil) (defaults to: nil) —

    Zavu platform charge in USD for this message. Messaging is billed against your p

  • cost_provider (Float, nil) (defaults to: nil) —

    Carrier and delivery cost in USD.

  • cost_total (Float, nil) (defaults to: nil) —

    Total cost in USD (platform charge + delivery cost).

  • error_code (String, nil) (defaults to: nil)
  • error_message (String, nil) (defaults to: nil)
  • from (String) (defaults to: nil)
  • metadata (Hash{Symbol=>String}) (defaults to: nil)
  • provider_message_id (String) (defaults to: nil) —

    Message ID from the delivery provider.

  • sender_id (String) (defaults to: nil)
  • text (String) (defaults to: nil) —

    Text content or caption.

  • updated_at (Time) (defaults to: nil)


# File 'lib/zavudev/models/message.rb', line 137


Instance Attribute Details

#channel ⇒ Symbol, Zavudev::Models::Channel

Delivery channel. Use 'auto' for intelligent routing.

Parameters:

  • value (Zavudev::Models::channel)

Returns:



16
# File 'lib/zavudev/models/message.rb', line 16

required :channel, enum: -> { Zavudev::Channel }

#content ⇒ Zavudev::Models::MessageContent?

Content for non-text message types (WhatsApp and Telegram).



65
# File 'lib/zavudev/models/message.rb', line 65

optional :content, -> { Zavudev::MessageContent }

#conversation_id ⇒ String?

ID of the conversation (inbox thread) this message belongs to. Use it to build a direct dashboard link: https://dashboard.zavu.dev/{locale}/inbox?conv={conversationId}. Omitted only on legacy messages created before conversation threading.

Parameters:

  • (String)

Returns:

  • (String, nil)


74
# File 'lib/zavudev/models/message.rb', line 74

optional :conversation_id, String, api_name: :conversationId

#cost ⇒ Float?

Zavu platform charge in USD for this message. Messaging is billed against your plan's monthly limits plus usage-based overage.

Parameters:

  • value (Float, nil)

Returns:

  • (Float, nil)


81
# File 'lib/zavudev/models/message.rb', line 81

optional :cost, Float, nil?: true

#cost_provider ⇒ Float?

Carrier and delivery cost in USD.

Parameters:

  • value (Float, nil)

Returns:

  • (Float, nil)


87
# File 'lib/zavudev/models/message.rb', line 87

optional :cost_provider, Float, api_name: :costProvider, nil?: true

#cost_total ⇒ Float?

Total cost in USD (platform charge + delivery cost).

Parameters:

  • value (Float, nil)

Returns:

  • (Float, nil)


93
# File 'lib/zavudev/models/message.rb', line 93

optional :cost_total, Float, api_name: :costTotal, nil?: true

#created_at ⇒ Time

Parameters:

  • value (Time)

Returns:

  • (Time)


21
# File 'lib/zavudev/models/message.rb', line 21

required :created_at, Time, api_name: :createdAt

#direction ⇒ Symbol, Zavudev::Models::Message::Direction

Who sent the message. Needed to render a thread: status cannot tell the two apart, because an inbound message is also stored as delivered.

Parameters:

  • value (Zavudev::Models::Message::direction)

Returns:



28
# File 'lib/zavudev/models/message.rb', line 28

required :direction, enum: -> { Zavudev::Message::Direction }

#error_code ⇒ String?

Parameters:

  • value (String, nil)

Returns:

  • (String, nil)


98
# File 'lib/zavudev/models/message.rb', line 98

optional :error_code, String, api_name: :errorCode, nil?: true

#error_message ⇒ String?

Parameters:

  • value (String, nil)

Returns:

  • (String, nil)


103
# File 'lib/zavudev/models/message.rb', line 103

optional :error_message, String, api_name: :errorMessage, nil?: true

#from ⇒ String?

Parameters:

  • (String)

Returns:

  • (String, nil)


108
# File 'lib/zavudev/models/message.rb', line 108

optional :from, String

#id ⇒ String

Parameters:

  • value (String)

Returns:

  • (String)


10
# File 'lib/zavudev/models/message.rb', line 10

required :id, String

#message_type ⇒ Symbol, Zavudev::Models::MessageType

Type of message. Non-text types are supported by WhatsApp and Telegram (varies by type).

location_request asks the recipient to share their location and is WhatsApp-only. It takes no content object — the prompt goes in text (max 1024 characters) and the button label is fixed by WhatsApp. The recipient's answer arrives as an inbound location message whose content.replyToMessageId is the ID of the request.

request_contact_info asks the recipient to share their phone number and is WhatsApp-only. Like location_request it takes no content object — the prompt goes in text (max 1024 characters) and WhatsApp renders a fixed Share Contact Info button. The answer arrives as an inbound contact message. Use it to recover the phone number of a contact who adopted a WhatsApp username and is only known by their business-scoped user ID (BSUID); when they share it, Zavu automatically links the phone number to that contact.

Parameters:

  • value (Zavudev::Models::message_type)

Returns:



49
# File 'lib/zavudev/models/message.rb', line 49

required :message_type, enum: -> { Zavudev::MessageType }, api_name: :messageType

#metadata ⇒ Hash{Symbol=>String}?

Parameters:

  • (::Hash[Symbol, String])

Returns:

  • (Hash{Symbol=>String}, nil)


113
# File 'lib/zavudev/models/message.rb', line 113

optional :metadata, Zavudev::Internal::Type::HashOf[String]

#provider_message_id ⇒ String?

Message ID from the delivery provider.

Parameters:

  • (String)

Returns:

  • (String, nil)


119
# File 'lib/zavudev/models/message.rb', line 119

optional :provider_message_id, String, api_name: :providerMessageId

#sender_id ⇒ String?

Parameters:

  • (String)

Returns:

  • (String, nil)


124
# File 'lib/zavudev/models/message.rb', line 124

optional :sender_id, String, api_name: :senderId

#status ⇒ Symbol, Zavudev::Models::MessageStatus

Parameters:

  • value (Zavudev::Models::message_status)

Returns:



54
# File 'lib/zavudev/models/message.rb', line 54

required :status, enum: -> { Zavudev::MessageStatus }

#text ⇒ String?

Text content or caption.

Parameters:

  • (String)

Returns:

  • (String, nil)


130
# File 'lib/zavudev/models/message.rb', line 130

optional :text, String

#to ⇒ String

Parameters:

  • value (String)

Returns:

  • (String)


59
# File 'lib/zavudev/models/message.rb', line 59

required :to, String

#updated_at ⇒ Time?

Parameters:

  • (Time)

Returns:

  • (Time, nil)


135
# File 'lib/zavudev/models/message.rb', line 135

optional :updated_at, Time, api_name: :updatedAt

Instance Method Details

#to_hash ⇒ {

Returns:

  • ({)


107
# File 'sig/zavudev/models/message.rbs', line 107

def to_hash: -> {