Module: BookingSync::API::Client::RatesRules

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

Instance Method Summary collapse

Instance Method Details

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

Create a new rates_rule

Parameters:

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

    RatesTable or ID of the rates_table for which rates_rule will be created.

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

    RatesRule’s attributes.

Returns:



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

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

#delete_rates_rule(rates_rule) ⇒ NilClass

Delete a rates_rule

Parameters:

Returns:

  • (NilClass)

    Returns nil on success.



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

def delete_rates_rule(rates_rule)
  delete "rates_rules/#{rates_rule}"
end

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

Edit a rates_rule

Examples:

rates_rule = @api.rates_rules.first
@api.edit_rates_rule(rates_rule, { percentage: 10 })

Parameters:

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

    RatesRule or ID of the rates_rule to be updated.

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

    RatesRule attributes to be updated.

Returns:



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

def edit_rates_rule(rates_rule, options = {})
  put("rates_rules/#{rates_rule}", rates_rules: [options]).pop
end

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

Get a single rates_rule

Parameters:

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

    RatesRule or ID of the rates_rule.

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

def rates_rule(rates_rule, options = {})
  get("rates_rules/#{rates_rule}", options).pop
end

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

List rates rules

Returns rates rules for the account user is authenticated with.

Examples:

Get the list of rates rules for the current account

rates_rules = @api.rates_rules
rates_rules.first.always_applied # => true

Get the list of rates rules only with always_applied and kind for smaller response

@api.rates_rules(fields: [:always_applied, :kind])

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

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