Class: Mailchimp::Conversations

Inherits:
Object
  • Object
show all
Defined in:
lib/mailchimp/api.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(master) ⇒ Conversations

Returns a new instance of Conversations.



467
468
469
# File 'lib/mailchimp/api.rb', line 467

def initialize(master)
    @master = master
end

Instance Attribute Details

#masterObject

Returns the value of attribute master.



465
466
467
# File 'lib/mailchimp/api.rb', line 465

def master
  @master
end

Instance Method Details

#list(list_id = nil, leid = nil, campaign_id = nil, start = 0, limit = 25) ⇒ Hash

Retrieve conversation metadata, includes message data for the most recent message in the conversation

Parameters:

  • list_id (String) (defaults to: nil)

    optional the list id to connect to. Get by calling lists/list()

  • leid (String) (defaults to: nil)

    optional The member’s ‘leid’, as found by calling lists/member-info()

  • campaign_id (String) (defaults to: nil)

    the campaign id to get content for (can be gathered using campaigns/list())

  • start (Int) (defaults to: 0)

    optional - control paging, start results at this offset, defaults to 0 (1st page of data)

  • limit (Int) (defaults to: 25)

    optional - control paging, number of results to return with each call, defaults to 25 (max=100)

Returns:

  • (Hash)

    Conversation data and metadata

    • Int

      count Total number of conversations, irrespective of pagination.

    • Array

      data An array of structs representing individual conversations

      - [String] unique_id A string identifying this particular conversation
      - [Int] message_count The total number of messages in this conversation
      - [String] campaign_id The unique identifier of the campaign this conversation is associated with
      - [String] list_id The unique identifier of the list this conversation is associated with
      - [Int] unread_messages The number of messages in this conversation which have not yet been read.
      - [String] from_label A label representing the sender of this message.
      - [String] from_email The email address of the sender of this message.
      - [String] subject The subject of the message.
      - [String] timestamp Date the message was either sent or received.
      - [Hash] last_message The most recent message in the conversation
          - [String] from_label A label representing the sender of this message.
          - [String] from_email The email address of the sender of this message.
          - [String] subject The subject of the message.
          - [String] message The plain-text content of the message.
          - [Boolean] read Whether or not this message has been marked as read.
          - [String] timestamp Date the message was either sent or received.
      


496
497
498
499
# File 'lib/mailchimp/api.rb', line 496

def list(list_id=nil, leid=nil, campaign_id=nil, start=0, limit=25)
    _params = {:list_id => list_id, :leid => leid, :campaign_id => campaign_id, :start => start, :limit => limit}
    return @master.call 'conversations/list', _params
end

#messages(conversation_id, mark_as_read = false, start = 0, limit = 25) ⇒ Hash

Retrieve conversation messages

Parameters:

  • conversation_id (String)

    the unique_id of the conversation to retrieve the messages for, can be obtained by calling converstaions/list().

  • mark_as_read (Boolean) (defaults to: false)

    optional Whether or not the conversation ought to be marked as read (defaults to false).

  • start (Int) (defaults to: 0)

    optional - control paging, start results at this offset, defaults to 1st page of data (offset 0)

  • limit (Int) (defaults to: 25)

    optional - control paging, number of results to return with each call, defaults to 25 (max=100)

Returns:

  • (Hash)

    Message data and metadata

    • Int

      count The number of messages in this conversation, irrespective of paging.

    • Array

      data An array of structs representing each message in a conversation

      - [String] from_label A label representing the sender of this message.
      - [String] from_email The email address of the sender of this message.
      - [String] subject The subject of the message.
      - [String] message The plain-text content of the message.
      - [Boolean] read Whether or not this message has been marked as read.
      - [String] timestamp Date the message was either sent or received.
      


515
516
517
518
# File 'lib/mailchimp/api.rb', line 515

def messages(conversation_id, mark_as_read=false, start=0, limit=25)
    _params = {:conversation_id => conversation_id, :mark_as_read => mark_as_read, :start => start, :limit => limit}
    return @master.call 'conversations/messages', _params
end

#reply(conversation_id, message) ⇒ Hash

Retrieve conversation messages

Parameters:

  • conversation_id (String)

    the unique_id of the conversation to retrieve the messages for, can be obtained by calling converstaions/list().

  • message (String)

    the text of the message you want to send.

Returns:

  • (Hash)

    Message data from the created message

    • String

      from_label A label representing the sender of this message.

    • String

      from_email The email address of the sender of this message.

    • String

      subject The subject of the message.

    • String

      message The plain-text content of the message.

    • Boolean

      read Whether or not this message has been marked as read.

    • String

      timestamp Date the message was either sent or received.



530
531
532
533
# File 'lib/mailchimp/api.rb', line 530

def reply(conversation_id, message)
    _params = {:conversation_id => conversation_id, :message => message}
    return @master.call 'conversations/reply', _params
end