Module: BookingSync::API::Client::Conversations

Included in:
BookingSync::API::Client
Defined in:
lib/bookingsync/api/client/conversations.rb

Instance Method Summary collapse

Instance Method Details

#connect_booking_to_conversation(conversation, options) ⇒ BookingSync::API::Resource

Connect conversation with booking

Examples:

@api.connect_booking_to_conversation(conversation, { id: 5 })

Parameters:

  • conversation (BookingSync::API::Resource|Integer)

    Conversation or ID of the conversation to be connected to booking

  • options (Hash)

    Id of booking to be connected to conversation.

Returns:



58
59
60
# File 'lib/bookingsync/api/client/conversations.rb', line 58

def connect_booking_to_conversation(conversation, options)
  put("inbox/conversations/#{conversation}/connect_booking", bookings: [options]).pop
end

#conversation(conversation) ⇒ BookingSync::API::Resource

Get a single conversation

Parameters:

Returns:



24
25
26
# File 'lib/bookingsync/api/client/conversations.rb', line 24

def conversation(conversation)
  get("inbox/conversations/#{conversation}").pop
end

#conversations(options = {}, &block) ⇒ Array<BookingSync::API::Resource>

List conversations

Returns all conversations supported in BookingSync.

Examples:

Get the list of conversations for the current account

conversations = @api.conversations
conversations.first.subject # => "Question"

Parameters:

  • options (Hash) (defaults to: {})

    A customizable set of options.

Options Hash (options):

  • fields: (Array)

    List of fields to be fetched.

Returns:

See Also:



15
16
17
# File 'lib/bookingsync/api/client/conversations.rb', line 15

def conversations(options = {}, &block)
  paginate "inbox/conversations", options, &block
end

#create_conversation(options = {}) ⇒ BookingSync::API::Resource

Create a new conversation

Parameters:

  • options (Hash) (defaults to: {})

    Conversation’s attributes.

Returns:



32
33
34
# File 'lib/bookingsync/api/client/conversations.rb', line 32

def create_conversation(options = {})
  post("inbox/conversations", conversations: [options]).pop
end

#disconnect_booking_from_conversation(conversation, options) ⇒ BookingSync::API::Resource

Disconnect conversation from booking

Examples:

@api.disconnect_booking_from_conversation(conversation, { id: 5 })

Parameters:

  • conversation (BookingSync::API::Resource|Integer)

    Conversation or ID of the conversation connected to booking

  • options (Hash)

    Id of booking to be disconnected from conversation.

Returns:



70
71
72
# File 'lib/bookingsync/api/client/conversations.rb', line 70

def disconnect_booking_from_conversation(conversation, options)
  put("inbox/conversations/#{conversation}/disconnect_booking", bookings: [options]).pop
end

#edit_conversation(conversation, options = {}) ⇒ BookingSync::API::Resource

Edit a conversation

Examples:

conversation = @api.conversations.first
@api.edit_conversation(conversation, { closed: true })

Parameters:

  • conversation (BookingSync::API::Resource|Integer)

    Conversation or ID of the conversation to be updated.

  • options (Hash) (defaults to: {})

    Conversation attributes to be updated.

Returns:



46
47
48
# File 'lib/bookingsync/api/client/conversations.rb', line 46

def edit_conversation(conversation, options = {})
  put("inbox/conversations/#{conversation}", conversations: [options]).pop
end