Module: BookingSync::API::Client::Periods

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

Instance Method Summary collapse

Instance Method Details

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

Create a new period

Parameters:

  • season_id (Integer) —

    ID of the season

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

    period attributes

Returns:



26
27
28
# File 'lib/bookingsync/api/client/periods.rb', line 26

def create_period(season_id, options = {})
  post(:periods, season_id: season_id, periods: [options]).pop
end

#delete_period(period, options = {}) ⇒ Array

Delete a period

to be deleted

Parameters:

Returns:

  • (Array) —

    An empty Array on success, exception is raised otherwise



49
50
51
# File 'lib/bookingsync/api/client/periods.rb', line 49

def delete_period(period, options = {})
  delete "periods/#{period}"
end

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

Edit a period

to be updated exception is raised otherwise

Examples:

period = @api.periods.first
@api.edit_period(period, { end_at: "2014-04-28" })

Parameters:

  • period (BookingSync::API::Resource|Integer) —

    period or ID of the period

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

    period attributes to be updated

Returns:



40
41
42
# File 'lib/bookingsync/api/client/periods.rb', line 40

def edit_period(period, options = {})
  put("periods/#{period}", periods: [options]).pop
end

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

List periods

Returns periods for the account user is authenticated with.

Examples:

Get the list of periods for the current account

periods = @api.periods
periods.first.start_at # => "2014-04-11"

Get the list of periods only with start_at and end_at for smaller response

@api.periods(fields: [:start_at, :end_at])

Parameters:

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

    A customizable set of options.

Options Hash (options):

  • fields: (Array) —

    List of fields to be fetched.

Returns:

See Also:



17
18
19
# File 'lib/bookingsync/api/client/periods.rb', line 17

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