Module: BookingSync::API::Client::BookingComments

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

Instance Method Summary collapse

Instance Method Details

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

Get a single booking_comment

@api.booking_comment(1)

> :links=>{:booking=>10, :id=>1, :content=>“comment 1”, :editable=>true, :created_at=>2016-04-18 12:06:15 UTC, :updated_at=>2016-04-18 12:06:15 UTC}

Examples:

Get single booking_comment

Parameters:

Returns:



30
31
32
# File 'lib/bookingsync/api/client/booking_comments.rb', line 30

def booking_comment(booking_comment, options = {})
  get("booking_comments/#{booking_comment}", options).pop
end

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

Returns booking comments for the account and rentals user is authenticated with.

> [:links=>{:booking=>10, :id=>1, :content=>“comment 1”, :editable=>true, :created_at=>2016-04-18 12:06:15 UTC, :updated_at=>2016-04-18 12:06:15 UTC},

{:links=>{:booking=>11}, :id=>2, :content=>"comment 2", :editable=>true, :created_at=>2016-04-18 12:06:25 UTC, :updated_at=>2016-04-18 12:06:25 UTC}]

> [:links=>{:booking=>10, :id=>1, :content=>“comment 1”, :editable=>true, :created_at=>2016-04-18 12:06:15 UTC, :updated_at=>2016-04-18 12:06:15 UTC}]

Examples:

Get the list of comments for the current account

@api.booking_comments

Get the list of comments only for specific rental

@api.booking_comments(rental_id: 1)

Parameters:

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

    A customizable set of options.

Options Hash (options):

  • rental_id: (Integer)

    Rental ID that booking is assiociated with.

Returns:



18
19
20
# File 'lib/bookingsync/api/client/booking_comments.rb', line 18

def booking_comments(options = {}, &block)
  paginate :booking_comments, options, &block
end

#create_booking_comment(booking, options = {}) ⇒ BookingSync::API::Resource

Create new booking_comment for a booking

ID of the Booking for which booking_comment will be created @api.create_booking_comment(1, content: “Hello!”)

> :links=>{:booking=>1, :id=>8, :content=>“Hello!”, :editable=>true, :created_at=>2016-04-18 13:31:40 UTC, :updated_at=>2016-04-18 13:46:06 UTC}

Examples:

Create bookings comment

Parameters:

Returns:



43
44
45
# File 'lib/bookingsync/api/client/booking_comments.rb', line 43

def create_booking_comment(booking, options = {})
  post("booking_comments", booking_id: booking, booking_comments: [options]).pop
end

#delete_booking_comment(booking_comment) ⇒ NilClass

Delete booking_comment

Parameters:

Returns:

  • (NilClass)

    Returns nil on success.



67
68
69
# File 'lib/bookingsync/api/client/booking_comments.rb', line 67

def delete_booking_comment(booking_comment)
  delete "booking_comments/#{booking_comment}"
end

#edit_booking_comment(booking_comment, options = {}) ⇒ BookingSync::API::Resource

Edit a booking_comment

> :links=>{:booking=>1, :id=>8, :content=>“New content”, :editable=>true, :created_at=>2016-04-18 13:31:40 UTC, :updated_at=>2016-04-18 13:46:06 UTC}

Examples:

booking_comment = @api.booking_comments.first
@api.edit_booking_comment(8, {content: "New content"})

Parameters:

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

    BookingComment or ID of the BookingComment to be updated.

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

    BookingComment attributes to be updated.

Returns:



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

def edit_booking_comment(booking_comment, options = {})
  put("booking_comments/#{booking_comment}", booking_comments: [options]).pop
end