Module: BookingSync::API::Client::Seasons

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

Instance Method Summary collapse

Instance Method Details

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

Create a new season

Parameters:

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

    Rates table or ID of the rates table for which a season will be created.

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

    Season’s attributes.

Returns:



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

def create_season(rates_table, options = {})
  post("rates_tables/#{rates_table}/seasons", seasons: [options]).pop
end

#delete_season(season) ⇒ NilClass

Delete a season

Parameters:

Returns:

  • (NilClass)

    Returns nil on success.



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

def delete_season(season)
  delete "seasons/#{season}"
end

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

Edit a season

Examples:

season = @api.seasons.first
@api.edit_season(season, { name: "Some season" })

Parameters:

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

    Season or ID of the season to be updated.

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

    Season attributes to be updated.

Returns:



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

def edit_season(season, options = {})
  put("seasons/#{season}", seasons: [options]).pop
end

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

Get a single season

Parameters:

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

    Season or ID of the season.

  • 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/seasons.rb', line 28

def season(season, options = {})
  get("seasons/#{season}", options).pop
end

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

List seasons

Returns seasons for the account user is authenticated with.

Examples:

Get the list of seasons for the current account

seasons = @api.seasons
seasons.first.name # => "Season 2"

Get the list of seasons only with name and ratio for smaller response

@api.seasons(fields: [:name, :ratio])

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/seasons.rb', line 17

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