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, options = {}) ⇒ BookingSync::API::Resource

Create a new period

Parameters:

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

    Season or ID of the season for which period will be created.

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

    Period’s attributes.

Returns:



38
39
40
# File 'lib/bookingsync/api/client/periods.rb', line 38

def create_period(season, options = {})
  post("seasons/#{season}/periods", periods: [options]).pop
end

#delete_period(period) ⇒ NilClass

Delete a period

Parameters:

Returns:

  • (NilClass)

    Returns nil on success.



61
62
63
# File 'lib/bookingsync/api/client/periods.rb', line 61

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

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

Edit a period

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 to be updated.

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

    period attributes to be updated.

Returns:



52
53
54
# File 'lib/bookingsync/api/client/periods.rb', line 52

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

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

Get a single period

Parameters:

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

    Period or ID of the period.

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

    A customizable set of query options.

Options Hash (options):

  • fields: (Array)

    List of fields to be fetched.

Returns:



28
29
30
# File 'lib/bookingsync/api/client/periods.rb', line 28

def period(period, options = {})
  get("periods/#{period}", 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