Class: Posthubify::InboxResource

Inherits:
Object
  • Object
show all
Defined in:
lib/posthubify/resources/messaging.rb

Overview

Inbox — conversations + messages (Node sdk .inbox).

Instance Method Summary collapse

Constructor Details

#initialize(http) ⇒ InboxResource

Returns a new instance of InboxResource.



6
7
8
# File 'lib/posthubify/resources/messaging.rb', line 6

def initialize(http)
  @http = http
end

Instance Method Details

#conversations(platform: nil, account_id: nil, limit: nil, cursor: nil, sort_order: nil) ⇒ Object

Conversation list (paginated envelope; req → returns data+pagination together).



11
12
13
14
15
16
# File 'lib/posthubify/resources/messaging.rb', line 11

def conversations(platform: nil, account_id: nil, limit: nil, cursor: nil, sort_order: nil)
  @http.req('GET', '/inbox/conversations', query: {
    'platform' => platform, 'accountId' => , 'limit' => limit,
    'cursor' => cursor, 'sortOrder' => sort_order
  })
end

#messages(conversation_id) ⇒ Object

Messages in a conversation.



19
20
21
# File 'lib/posthubify/resources/messaging.rb', line 19

def messages(conversation_id)
  @http.data('GET', "/inbox/conversations/#{conversation_id}/messages")
end

#send_message(conversation_id, text) ⇒ Object

Send a message to a conversation.



24
25
26
# File 'lib/posthubify/resources/messaging.rb', line 24

def send_message(conversation_id, text)
  @http.data('POST', "/inbox/conversations/#{conversation_id}/messages", body: { 'text' => text })
end

#start_conversation(input) ⇒ Object

Start a new conversation (recipientId = PSID/IGSID/convoId/handle).



29
30
31
# File 'lib/posthubify/resources/messaging.rb', line 29

def start_conversation(input)
  @http.data('POST', '/inbox/conversations', body: input)
end