Module: BookingSync::API::Client::Messages

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

Instance Method Summary collapse

Instance Method Details

#add_attachment_to_message(message, options) ⇒ BookingSync::API::Resource

Add attachment to message

Examples:

@api.add_attachment_to_message(message, { id: 5 })

Parameters:

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

    Message or ID of the message to which we are adding attachment

  • options (Hash)

    Id of attachment to be added to message.

Returns:



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

def add_attachment_to_message(message, options)
  put("inbox/messages/#{message}/add_attachment", attachments: [options]).pop
end

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

Create a new message

Parameters:

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

    Message’s attributes.

Returns:



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

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

#edit_message(message, options = {}) ⇒ BookingSync::API::Resource

Edit a message

Examples:

message = @api.messages.first
@api.edit_message(message, { content: "Updated message content" })

Parameters:

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

    Message or ID of the message to be updated.

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

    Message attributes to be updated.

Returns:



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

def edit_message(message, options = {})
  put("inbox/messages/#{message}", messages: [options]).pop
end

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

Get a single message

Parameters:

Returns:



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

def message(message)
  get("inbox/messages/#{message}").pop
end

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

List messages

Returns all messages supported in BookingSync.

Examples:

Get the list of messages for the current account

messages = @api.messages
messages.first.content # => "Message content"

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/messages.rb', line 15

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