Class: Zavudev::Resources::Conversations
- Inherits:
-
Object
- Object
- Zavudev::Resources::Conversations
- Defined in:
- lib/zavudev/resources/conversations.rb,
sig/zavudev/resources/conversations.rbs
Instance Method Summary collapse
-
#initialize(client:) ⇒ Conversations
constructor
private
A new instance of Conversations.
-
#list(channel: nil, cursor: nil, limit: nil, search: nil, sender_id: nil, request_options: {}) ⇒ Zavudev::Internal::Cursor<Zavudev::Models::ConversationListResponse>
Some parameter documentations has been truncated, see Models::ConversationListParams for more details.
-
#list_messages(conversation_id, cursor: nil, limit: nil, request_options: {}) ⇒ Zavudev::Internal::Cursor<Zavudev::Models::Message>
Messages in this thread, newest first, across every channel it has carried.
-
#mark_as_read(conversation_id, request_options: {}) ⇒ Zavudev::Models::ConversationMarkAsReadResponse
Reset the thread's
unreadCountto zero. -
#retrieve(conversation_id, request_options: {}) ⇒ Zavudev::Models::ConversationRetrieveResponse
Get conversation.
Constructor Details
#initialize(client:) ⇒ Conversations
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Conversations.
119 120 121 |
# File 'lib/zavudev/resources/conversations.rb', line 119 def initialize(client:) @client = client end |
Instance Method Details
#list(channel: nil, cursor: nil, limit: nil, search: nil, sender_id: nil, request_options: {}) ⇒ Zavudev::Internal::Cursor<Zavudev::Models::ConversationListResponse>
Some parameter documentations has been truncated, see Models::ConversationListParams for more details.
List inbox threads, most recently active first. A conversation groups every
message with one contact across channels, which is what you need to build an
inbox: GET /v1/messages returns a flat log with no thread to hang it on.
Use senderId to scope the list to a single number, and channel to keep only
threads that have carried that channel.
52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/zavudev/resources/conversations.rb', line 52 def list(params = {}) parsed, = Zavudev::ConversationListParams.dump_request(params) query = Zavudev::Internal::Util.encode_query_params(parsed) @client.request( method: :get, path: "v1/conversations", query: query.transform_keys(sender_id: "senderId"), page: Zavudev::Internal::Cursor, model: Zavudev::Models::ConversationListResponse, options: ) end |
#list_messages(conversation_id, cursor: nil, limit: nil, request_options: {}) ⇒ Zavudev::Internal::Cursor<Zavudev::Models::Message>
Messages in this thread, newest first, across every channel it has carried.
Reply with POST /v1/messages, passing the conversation's senderId as the
Zavu-Sender header so the answer leaves from the number the contact already
knows.
83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/zavudev/resources/conversations.rb', line 83 def (conversation_id, params = {}) parsed, = Zavudev::ConversationListMessagesParams.dump_request(params) query = Zavudev::Internal::Util.encode_query_params(parsed) @client.request( method: :get, path: ["v1/conversations/%1$s/messages", conversation_id], query: query, page: Zavudev::Internal::Cursor, model: Zavudev::Message, options: ) end |
#mark_as_read(conversation_id, request_options: {}) ⇒ Zavudev::Models::ConversationMarkAsReadResponse
Reset the thread's unreadCount to zero. Marks the thread read in your own
inbox only: it does not send a read receipt to the contact.
107 108 109 110 111 112 113 114 |
# File 'lib/zavudev/resources/conversations.rb', line 107 def mark_as_read(conversation_id, params = {}) @client.request( method: :post, path: ["v1/conversations/%1$s/read", conversation_id], model: Zavudev::Models::ConversationMarkAsReadResponse, options: params[:request_options] ) end |
#retrieve(conversation_id, request_options: {}) ⇒ Zavudev::Models::ConversationRetrieveResponse
Get conversation
16 17 18 19 20 21 22 23 |
# File 'lib/zavudev/resources/conversations.rb', line 16 def retrieve(conversation_id, params = {}) @client.request( method: :get, path: ["v1/conversations/%1$s", conversation_id], model: Zavudev::Models::ConversationRetrieveResponse, options: params[:request_options] ) end |