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.
826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 |
# File 'lib/sendly/types.rb', line 826 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.
824 825 826 |
# File 'lib/sendly/types.rb', line 824 def business @business end |
#context ⇒ Object (readonly)
Returns the value of attribute context.
824 825 826 |
# File 'lib/sendly/types.rb', line 824 def context @context end |
#conversation ⇒ Object (readonly)
Returns the value of attribute conversation.
824 825 826 |
# File 'lib/sendly/types.rb', line 824 def conversation @conversation end |
#token_estimate ⇒ Object (readonly)
Returns the value of attribute token_estimate.
824 825 826 |
# File 'lib/sendly/types.rb', line 824 def token_estimate @token_estimate end |
Instance Method Details
#to_h ⇒ Object
844 845 846 847 848 849 850 851 852 |
# File 'lib/sendly/types.rb', line 844 def to_h result = { context: context, conversation: conversation, token_estimate: token_estimate } result[:business] = business if business result end |