module BookingSync::API::Client::RatesRules
Public Instance Methods
Create a new rates_rule
@param rates_table [BookingSync::API::Resource|Integer] RatesTable or ID of
the rates_table for which rates_rule will be created.
@param options [Hash] RatesRule’s attributes. @return [BookingSync::API::Resource] Newly created rates_rule.
# 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 a rates_rule
@param rates_rule
[BookingSync::API::Resource|Integer] RatesRule or ID
of the rates_rule to be deleted.
@return [NilClass] Returns nil on success.
# File lib/bookingsync/api/client/rates_rules.rb, line 61 def delete_rates_rule(rates_rule) delete "rates_rules/#{rates_rule}" end
Edit a rates_rule
@param rates_rule
[BookingSync::API::Resource|Integer] RatesRule or ID of
the rates_rule to be updated.
@param options [Hash] RatesRule attributes to be updated. @return [BookingSync::API::Resource] Updated rates_rule
on success,
exception is raised otherwise.
@example
rates_rule = @api.rates_rules.first @api.edit_rates_rule(rates_rule, { percentage: 10 })
# 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
Get a single rates_rule
@param rates_rule
[BookingSync::API::Resource|Integer] RatesRule or ID
of the rates_rule.
@param options [Hash] A customizable set of query options. @option options [Array] fields: List of fields to be fetched. @return [BookingSync::API::Resource]
# File lib/bookingsync/api/client/rates_rules.rb, line 28 def rates_rule(rates_rule, options = {}) get("rates_rules/#{rates_rule}", options).pop end
List rates rules
Returns rates rules for the account user is authenticated with. @param options [Hash] A customizable set of options. @option options [Array] fields: List of fields to be fetched. @return [Array<BookingSync::API::Resource>] Array of rates rules.
@example Get the list of rates rules for the current account
rates_rules = @api.rates_rules rates_rules.first.always_applied # => true
@example Get the list of rates rules only with always_applied and kind for smaller response
@api.rates_rules(fields: [:always_applied, :kind])
@see docs.api.bookingsync.com/reference/endpoints/rates_rules/#list-rates-rules
# File lib/bookingsync/api/client/rates_rules.rb, line 17 def rates_rules(options = {}, &block) paginate :rates_rules, options, &block end