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.
757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 |
# File 'lib/sendly/types.rb', line 757 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.
755 756 757 |
# File 'lib/sendly/types.rb', line 755 def business @business end |
#context ⇒ Object (readonly)
Returns the value of attribute context.
755 756 757 |
# File 'lib/sendly/types.rb', line 755 def context @context end |
#conversation ⇒ Object (readonly)
Returns the value of attribute conversation.
755 756 757 |
# File 'lib/sendly/types.rb', line 755 def conversation @conversation end |
#token_estimate ⇒ Object (readonly)
Returns the value of attribute token_estimate.
755 756 757 |
# File 'lib/sendly/types.rb', line 755 def token_estimate @token_estimate end |
Instance Method Details
#to_h ⇒ Object
775 776 777 778 779 780 781 782 783 |
# File 'lib/sendly/types.rb', line 775 def to_h result = { context: context, conversation: conversation, token_estimate: token_estimate } result[:business] = business if business result end |