Class: Sendly::ConversationContext
- Inherits:
-
Object
- Object
- Sendly::ConversationContext
- Defined in:
- lib/sendly/types.rb
Overview
============================================================================
Conversation Context
Instance Attribute Summary collapse
-
#business ⇒ Object
readonly
Returns the value of attribute business.
-
#context ⇒ Object
readonly
Returns the value of attribute context.
-
#conversation ⇒ Object
readonly
Returns the value of attribute conversation.
-
#token_estimate ⇒ Object
readonly
Returns the value of attribute token_estimate.
Instance Method Summary collapse
-
#initialize(data) ⇒ ConversationContext
constructor
A new instance of ConversationContext.
- #to_h ⇒ Object
Constructor Details
#initialize(data) ⇒ ConversationContext
Returns a new instance of ConversationContext.
905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 |
# File 'lib/sendly/types.rb', line 905 def initialize(data) @context = data["context"] @conversation = { id: data.dig("conversation", "id"), phone_number: data.dig("conversation", "phoneNumber") || data.dig("conversation", "phone_number"), status: data.dig("conversation", "status"), message_count: data.dig("conversation", "messageCount") || data.dig("conversation", "message_count") || 0, unread_count: data.dig("conversation", "unreadCount") || data.dig("conversation", "unread_count") || 0 } @token_estimate = data["tokenEstimate"] || data["token_estimate"] || 0 if data["business"] @business = { name: data.dig("business", "name"), use_case: data.dig("business", "useCase") || data.dig("business", "use_case") } end end |
Instance Attribute Details
#business ⇒ Object (readonly)
Returns the value of attribute business.
903 904 905 |
# File 'lib/sendly/types.rb', line 903 def business @business end |
#context ⇒ Object (readonly)
Returns the value of attribute context.
903 904 905 |
# File 'lib/sendly/types.rb', line 903 def context @context end |
#conversation ⇒ Object (readonly)
Returns the value of attribute conversation.
903 904 905 |
# File 'lib/sendly/types.rb', line 903 def conversation @conversation end |
#token_estimate ⇒ Object (readonly)
Returns the value of attribute token_estimate.
903 904 905 |
# File 'lib/sendly/types.rb', line 903 def token_estimate @token_estimate end |
Instance Method Details
#to_h ⇒ Object
923 924 925 926 927 928 929 930 931 |
# File 'lib/sendly/types.rb', line 923 def to_h result = { context: context, conversation: conversation, token_estimate: token_estimate } result[:business] = business if business result end |