bookingsync-api 0.0.6 → 0.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (106) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +1 -1
  3. data/Gemfile +2 -1
  4. data/Guardfile +3 -6
  5. data/README.md +11 -3
  6. data/bookingsync-api.gemspec +2 -2
  7. data/lib/bookingsync/api.rb +0 -2
  8. data/lib/bookingsync/api/client.rb +151 -54
  9. data/lib/bookingsync/api/client/amenities.rb +22 -0
  10. data/lib/bookingsync/api/client/billing_addresses.rb +22 -0
  11. data/lib/bookingsync/api/client/bookings.rb +7 -9
  12. data/lib/bookingsync/api/client/bookings_payments.rb +22 -0
  13. data/lib/bookingsync/api/client/clients.rb +43 -0
  14. data/lib/bookingsync/api/client/destinations.rb +22 -0
  15. data/lib/bookingsync/api/client/inquiries.rb +2 -2
  16. data/lib/bookingsync/api/client/payments.rb +53 -0
  17. data/lib/bookingsync/api/client/periods.rb +54 -0
  18. data/lib/bookingsync/api/client/photos.rb +22 -0
  19. data/lib/bookingsync/api/client/rates.rb +23 -0
  20. data/lib/bookingsync/api/client/rates_rules.rb +22 -0
  21. data/lib/bookingsync/api/client/rates_tables.rb +53 -0
  22. data/lib/bookingsync/api/client/rental_agreements.rb +50 -0
  23. data/lib/bookingsync/api/client/rentals.rb +39 -1
  24. data/lib/bookingsync/api/client/reviews.rb +31 -0
  25. data/lib/bookingsync/api/client/seasons.rb +53 -0
  26. data/lib/bookingsync/api/client/special_offers.rb +54 -0
  27. data/lib/bookingsync/api/relation.rb +87 -0
  28. data/lib/bookingsync/api/resource.rb +58 -0
  29. data/lib/bookingsync/api/response.rb +79 -0
  30. data/lib/bookingsync/api/serializer.rb +100 -0
  31. data/lib/bookingsync/api/version.rb +1 -1
  32. data/spec/bookingsync/api/client/amenities_spec.rb +12 -0
  33. data/spec/bookingsync/api/client/billing_addresses_spec.rb +12 -0
  34. data/spec/bookingsync/api/client/billings_payments_spec.rb +12 -0
  35. data/spec/bookingsync/api/client/bookings_spec.rb +10 -8
  36. data/spec/bookingsync/api/client/clients_spec.rb +55 -0
  37. data/spec/bookingsync/api/client/destinations_spec.rb +12 -0
  38. data/spec/bookingsync/api/client/inquiries_spec.rb +1 -1
  39. data/spec/bookingsync/api/client/payments_spec.rb +56 -0
  40. data/spec/bookingsync/api/client/periods_spec.rb +61 -0
  41. data/spec/bookingsync/api/client/photos_spec.rb +12 -0
  42. data/spec/bookingsync/api/client/rates_rules_spec.rb +13 -0
  43. data/spec/bookingsync/api/client/rates_spec.rb +12 -0
  44. data/spec/bookingsync/api/client/rates_tables_spec.rb +59 -0
  45. data/spec/bookingsync/api/client/rental_agreements_spec.rb +64 -0
  46. data/spec/bookingsync/api/client/rentals_spec.rb +56 -6
  47. data/spec/bookingsync/api/client/reviews_spec.rb +33 -0
  48. data/spec/bookingsync/api/client/seasons_spec.rb +61 -0
  49. data/spec/bookingsync/api/client/special_offers_spec.rb +63 -0
  50. data/spec/bookingsync/api/client_spec.rb +31 -10
  51. data/spec/bookingsync/api/relation_spec.rb +72 -0
  52. data/spec/bookingsync/api/resource_spec.rb +79 -0
  53. data/spec/bookingsync/api/response_spec.rb +66 -0
  54. data/spec/cassettes/BookingSync_API_Client_Amenities/_amenities/returns_amenities.yml +72 -0
  55. data/spec/cassettes/BookingSync_API_Client_BillingAddresses/_billing_addresses/returns_billing_addresses.yml +65 -0
  56. data/spec/cassettes/BookingSync_API_Client_Bookings/_bookings/pagination/with_a_block/yields_block_with_batch_of_bookings.yml +12 -12
  57. data/spec/cassettes/BookingSync_API_Client_Bookings/_bookings/pagination/with_auto_paginate_true/returns_all_bookings_joined_from_many_requests.yml +12 -12
  58. data/spec/cassettes/BookingSync_API_Client_Bookings/_bookings/pagination/with_per_page_setting/returns_limited_number_of_bookings.yml +3 -3
  59. data/spec/cassettes/BookingSync_API_Client_Bookings/_clients/returns_clients.yml +66 -0
  60. data/spec/cassettes/BookingSync_API_Client_Bookings/_create_booking/creates_a_booking.yml +1 -1
  61. data/spec/cassettes/BookingSync_API_Client_Bookings/_create_client/creates_a_new_client.yml +64 -0
  62. data/spec/cassettes/BookingSync_API_Client_Bookings/_edit_booking/updates_given_booking_by_ID.yml +18 -14
  63. data/spec/cassettes/BookingSync_API_Client_Bookings/_edit_client/updates_given_client_by_ID.yml +62 -0
  64. data/spec/cassettes/BookingSync_API_Client_BookingsPayments/_bookings_payments/returns_bookings_payments.yml +65 -0
  65. data/spec/cassettes/BookingSync_API_Client_Destinations/_destinations/returns_destinations.yml +64 -0
  66. data/spec/cassettes/BookingSync_API_Client_Inquiries/_create_inquiry/creates_a_new_inquiry.yml +1 -1
  67. data/spec/cassettes/BookingSync_API_Client_Inquiries/_inquiries/returns_inquiries.yml +1 -1
  68. data/spec/cassettes/BookingSync_API_Client_Payments/_cancel_payment/cancels_given_payment.yml +57 -0
  69. data/spec/cassettes/BookingSync_API_Client_Payments/_create_payment/creates_a_new_payment.yml +63 -0
  70. data/spec/cassettes/BookingSync_API_Client_Payments/_edit_payment/updates_given_payment_by_ID.yml +61 -0
  71. data/spec/cassettes/BookingSync_API_Client_Payments/_payments/returns_payments.yml +64 -0
  72. data/spec/cassettes/BookingSync_API_Client_Periods/_create_period/creates_a_new_period.yml +63 -0
  73. data/spec/cassettes/BookingSync_API_Client_Periods/_delete_period/deletes_given_period.yml +70 -0
  74. data/spec/cassettes/BookingSync_API_Client_Periods/_edit_period/updates_given_period_by_ID.yml +61 -0
  75. data/spec/cassettes/BookingSync_API_Client_Periods/_periods/returns_periods.yml +64 -0
  76. data/spec/cassettes/BookingSync_API_Client_Photos/_photos/returns_photos.yml +72 -0
  77. data/spec/cassettes/BookingSync_API_Client_Rates/_rates/returns_rates.yml +64 -0
  78. data/spec/cassettes/BookingSync_API_Client_RatesRules/_rates_rules/returns_rates_rules.yml +64 -0
  79. data/spec/cassettes/BookingSync_API_Client_RatesTables/_create_rates_table/creates_a_new_rates_table.yml +64 -0
  80. data/spec/cassettes/BookingSync_API_Client_RatesTables/_delete_rates_table/deletes_given_rates_table.yml +57 -0
  81. data/spec/cassettes/BookingSync_API_Client_RatesTables/_edit_rates_table/updates_given_rates_table_by_ID.yml +62 -0
  82. data/spec/cassettes/BookingSync_API_Client_RatesTables/_rates_tables/returns_rates_tables.yml +74 -0
  83. data/spec/cassettes/BookingSync_API_Client_RentalAgreements/_create_rental_agreement/creates_a_new_rental_agreement.yml +63 -0
  84. data/spec/cassettes/BookingSync_API_Client_RentalAgreements/_create_rental_agreement_for_booking/creates_a_new_rental_agreement.yml +63 -0
  85. data/spec/cassettes/BookingSync_API_Client_RentalAgreements/_create_rental_agreement_for_rental/creates_a_new_rental_agreement.yml +63 -0
  86. data/spec/cassettes/BookingSync_API_Client_RentalAgreements/_rental_agreements/returns_rental_agreements.yml +64 -0
  87. data/spec/cassettes/BookingSync_API_Client_Rentals/_cancel_rental/cancels_given_rental.yml +57 -0
  88. data/spec/cassettes/BookingSync_API_Client_Rentals/_create_rental/creates_a_new_rental.yml +64 -0
  89. data/spec/cassettes/BookingSync_API_Client_Rentals/_edit_rental/updates_given_rental_by_ID.yml +64 -0
  90. data/spec/cassettes/BookingSync_API_Client_Rentals/_rental/returns_a_single_rental.yml +67 -0
  91. data/spec/cassettes/BookingSync_API_Client_Rentals/_rentals/links/returns_associated_photos.yml +152 -0
  92. data/spec/cassettes/BookingSync_API_Client_Rentals/_rentals/links/returns_links_to_associated_resources.yml +91 -0
  93. data/spec/cassettes/BookingSync_API_Client_Rentals/_rentals/returns_rentals.yml +45 -20
  94. data/spec/cassettes/BookingSync_API_Client_Reviews/_create_review/creates_a_new_review.yml +64 -0
  95. data/spec/cassettes/BookingSync_API_Client_Reviews/_reviews/returns_reviews.yml +83 -0
  96. data/spec/cassettes/BookingSync_API_Client_Seasons/_create_season/creates_a_new_season.yml +64 -0
  97. data/spec/cassettes/BookingSync_API_Client_Seasons/_delete_season/deletes_given_season.yml +57 -0
  98. data/spec/cassettes/BookingSync_API_Client_Seasons/_edit_season/updates_given_season_by_ID.yml +62 -0
  99. data/spec/cassettes/BookingSync_API_Client_Seasons/_seasons/returns_seasons.yml +74 -0
  100. data/spec/cassettes/BookingSync_API_Client_SpecialOffers/_create_special_offer/creates_a_new_special_offer.yml +63 -0
  101. data/spec/cassettes/BookingSync_API_Client_SpecialOffers/_delete_special_offer/deletes_given_special_offer.yml +57 -0
  102. data/spec/cassettes/BookingSync_API_Client_SpecialOffers/_edit_special_offer/updates_given_special_offer_by_ID.yml +61 -0
  103. data/spec/cassettes/{BookingSync_API_Client_Rentals/_rentals/with_specified_fields_in_options/returns_rentals_with_filtered_fields.yml → BookingSync_API_Client_SpecialOffers/_special_offers/returns_special_offers.yml} +17 -10
  104. data/spec/spec_helper.rb +1 -0
  105. metadata +143 -7
  106. data/lib/bookingsync/ext/resource.rb +0 -9
@@ -16,7 +16,7 @@ module BookingSync::API
16
16
  # @option options [Array] status: Array of booking states.
17
17
  # If specyfied bookings with given states are shown.
18
18
  # Possible statuses: `:booked`, `:unavailable` and `:tentative`
19
- # @return [Array<Sawyer::Resource>] Array of bookings.
19
+ # @return [Array<BookingSync::API::Resource>] Array of bookings.
20
20
  # @example
21
21
  # @api.bookings(months: 12, states: [:booked, :unavailable], include_canceled: true)
22
22
  #
@@ -30,32 +30,30 @@ module BookingSync::API
30
30
  paginate :bookings, options, &block
31
31
  end
32
32
 
33
-
34
33
  # Create a booking
35
34
  #
36
35
  # @param options [Hash] Booking attributes
37
- # @return <Sawyer::Resource> Newly create booking
36
+ # @return [BookingSync::API::Resource] Newly create booking
38
37
  def create_booking(options = {})
39
38
  post(:bookings, bookings: [options]).pop
40
39
  end
41
40
 
42
41
  # Edit a booking
43
42
  #
44
- # @param booking [Sawyer::Resource|Integer] Booking or ID of the booking
43
+ # @param booking [BookingSync::API::Resource|Integer] Booking or ID of the booking
45
44
  # to be updated
46
45
  # @param options [Hash] Booking attributes to be updated
47
- # FIXME: should be changed resource
48
- # @return [Array] An empty Array on success, exception is raised otherwise
46
+ # @return [BookingSync::API::Resource] Updated booking on success, exception is raised otherwise
49
47
  # @example
50
48
  # booking = @api.bookings.first
51
- # @api.edit_booking(booking, {adults: 1}) => []
49
+ # @api.edit_booking(booking, { adults: 1 })
52
50
  def edit_booking(booking, options = {})
53
- put "bookings/#{booking}", bookings: [options]
51
+ put("bookings/#{booking}", bookings: [options]).pop
54
52
  end
55
53
 
56
54
  # Cancel a booking
57
55
  #
58
- # @param booking [Sawyer::Resource|Integer] Booking or ID of the booking
56
+ # @param booking [BookingSync::API::Resource|Integer] Booking or ID of the booking
59
57
  # to be canceled
60
58
  # @return [Array] An empty Array on success, exception is raised otherwise
61
59
  def cancel_booking(booking, options = {})
@@ -0,0 +1,22 @@
1
+ module BookingSync::API
2
+ class Client
3
+ module BookingsPayments
4
+ # List bookings payments
5
+ #
6
+ # Returns bookings payments for the account user is authenticated with.
7
+ # @param options [Hash] A customizable set of options.
8
+ # @option options [Array] fields: List of fields to be fetched.
9
+ # @return [Array<BookingSync::API::Resource>] Array of bookings payments.
10
+ #
11
+ # @example Get the list of bookings payments for the current account
12
+ # bookings_payments = @api.bookings_payments
13
+ # bookings_payments.first.amount # => 200
14
+ # @example Get the list of bookings payments only with amount and currency for smaller response
15
+ # @api.bookings_payments(fields: [:amount, :currency])
16
+ # @see http://docs.api.bookingsync.com/reference/endpoints/bookings_payments/#list-bookings-payments
17
+ def bookings_payments(options = {}, &block)
18
+ paginate :bookings_payments, options, &block
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,43 @@
1
+ module BookingSync::API
2
+ class Client
3
+ module Clients
4
+ # List clients
5
+ #
6
+ # Returns clients for the account user is authenticated with.
7
+ # @param options [Hash] A customizable set of options.
8
+ # @option options [Array] fields: List of fields to be fetched.
9
+ # @return [Array<BookingSync::API::Resource>] Array of clients.
10
+ #
11
+ # @example Get the list of clients for the current account
12
+ # clients = @api.clients
13
+ # clients.first.fullname # => "John Smith"
14
+ # @example Get the list of clients only with fullname and phone for smaller response
15
+ # @api.clients(fields: [:fullname, :phone])
16
+ # @see http://docs.api.bookingsync.com/reference/endpoints/clients/#list-clients
17
+ def clients(options = {}, &block)
18
+ paginate :clients, options, &block
19
+ end
20
+
21
+ # Create a new client
22
+ #
23
+ # @param options [Hash] Client attributes
24
+ # @return [BookingSync::API::Resource] Newly created client
25
+ def create_client(options = {})
26
+ post(:clients, clients: [options]).pop
27
+ end
28
+
29
+ # Edit a client
30
+ #
31
+ # @param client [BookingSync::API::Resource|Integer] Client or ID of the client
32
+ # to be updated
33
+ # @param options [Hash] Client attributes to be updated
34
+ # @return [BookingSync::API::Resource] Updated client on success, exception is raised otherwise
35
+ # @example
36
+ # client = @api.clients.first
37
+ # @api.edit_client(client, { fullname: "Gary Smith" })
38
+ def edit_client(client, options = {})
39
+ put("clients/#{client}", clients: [options]).pop
40
+ end
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,22 @@
1
+ module BookingSync::API
2
+ class Client
3
+ module Destinations
4
+ # List destinations
5
+ #
6
+ # Returns destinations for the account user is authenticated with.
7
+ # @param options [Hash] A customizable set of options.
8
+ # @option options [Array] fields: List of fields to be fetched.
9
+ # @return [Array<BookingSync::API::Resource>] Array of destinations.
10
+ #
11
+ # @example Get the list of destinations for the current account
12
+ # destinations = @api.destinations
13
+ # destinations.first.fullname # => {"en":"Europe, World"}
14
+ # @example Get the list of destinations only with name and fullname for smaller response
15
+ # @api.destinations(fields: [:name, :fullname])
16
+ # @see http://docs.api.bookingsync.com/reference/endpoints/destinations/#list-destinations
17
+ def destinations(options = {}, &block)
18
+ paginate :destinations, options, &block
19
+ end
20
+ end
21
+ end
22
+ end
@@ -5,7 +5,7 @@ module BookingSync::API
5
5
  #
6
6
  # Return list of inquiries for current account.
7
7
  # @param options [Hash] A customizable set of query options.
8
- # @return [Array<Sawyer::Resource>] Array of inquiries.
8
+ # @return [Array<BookingSync::API::Resource>] Array of inquiries.
9
9
  # @see http://docs.api.bookingsync.com/reference/endpoints/inquiries/#list-inquiries
10
10
  def inquiries(options = {}, &block)
11
11
  paginate :inquiries, options, &block
@@ -14,7 +14,7 @@ module BookingSync::API
14
14
  # Create a new inquiry
15
15
  #
16
16
  # @param options [Hash] Inquiry attributes
17
- # @return <Sawyer::Resource> Newly create inquiry
17
+ # @return [BookingSync::API::Resource] Newly create inquiry
18
18
  def create_inquiry(options = {})
19
19
  post(:inquiries, inquiries: [options]).pop
20
20
  end
@@ -0,0 +1,53 @@
1
+ module BookingSync::API
2
+ class Client
3
+ module Payments
4
+ # List payments
5
+ #
6
+ # Returns payments for the account user is authenticated with.
7
+ # @param options [Hash] A customizable set of options.
8
+ # @option options [Array] fields: List of fields to be fetched.
9
+ # @return [Array<BookingSync::API::Resource>] Array of payments.
10
+ #
11
+ # @example Get the list of payments for the current account
12
+ # payments = @api.payments
13
+ # payments.first.kind # => "cash"
14
+ # @example Get the list of payments only with kind and currency for smaller response
15
+ # @api.payments(fields: [:kind, :currency])
16
+ # @see http://docs.api.bookingsync.com/reference/endpoints/payments/#list-payments
17
+ def payments(options = {}, &block)
18
+ paginate :payments, options, &block
19
+ end
20
+
21
+ # Create a new payment
22
+ #
23
+ # @param booking_id [Integer] ID of the booking
24
+ # @param options [Hash] payment attributes
25
+ # @return [BookingSync::API::Resource] Newly created payment
26
+ def create_payment(booking_id, options = {})
27
+ post(:payments, booking_id: booking_id, payments: [options]).pop
28
+ end
29
+
30
+ # Edit a payment
31
+ #
32
+ # @param payment [BookingSync::API::Resource|Integer] payment or ID of the payment
33
+ # to be updated
34
+ # @param options [Hash] payment attributes to be updated
35
+ # @return [BookingSync::API::Resource] Updated payment on success, exception is raised otherwise
36
+ # @example
37
+ # payment = @api.payments.first
38
+ # @api.edit_payment(payment, { currency: "EURO" })
39
+ def edit_payment(payment, options = {})
40
+ put("payments/#{payment}", payments: [options]).pop
41
+ end
42
+
43
+ # Cancel a payment
44
+ #
45
+ # @param payment [BookingSync::API::Resource|Integer] payment or ID of the payment
46
+ # to be canceled
47
+ # @return [Array] An empty Array on success, exception is raised otherwise
48
+ def cancel_payment(payment, options = {})
49
+ delete "payments/#{payment}"
50
+ end
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,54 @@
1
+ module BookingSync::API
2
+ class Client
3
+ module Periods
4
+ # List periods
5
+ #
6
+ # Returns periods for the account user is authenticated with.
7
+ # @param options [Hash] A customizable set of options.
8
+ # @option options [Array] fields: List of fields to be fetched.
9
+ # @return [Array<BookingSync::API::Resource>] Array of periods.
10
+ #
11
+ # @example Get the list of periods for the current account
12
+ # periods = @api.periods
13
+ # periods.first.start_at # => "2014-04-11"
14
+ # @example Get the list of periods only with start_at and end_at for smaller response
15
+ # @api.periods(fields: [:start_at, :end_at])
16
+ # @see http://docs.api.bookingsync.com/reference/endpoints/periods/#list-periods
17
+ def periods(options = {}, &block)
18
+ paginate :periods, options, &block
19
+ end
20
+
21
+ # Create a new period
22
+ #
23
+ # @param season_id [Integer] ID of the season
24
+ # @param options [Hash] period attributes
25
+ # @return [BookingSync::API::Resource] Newly created period
26
+ def create_period(season_id, options = {})
27
+ post(:periods, season_id: season_id, periods: [options]).pop
28
+ end
29
+
30
+ # Edit a period
31
+ #
32
+ # @param period [BookingSync::API::Resource|Integer] period or ID of the period
33
+ # to be updated
34
+ # @param options [Hash] period attributes to be updated
35
+ # @return [BookingSync::API::Resource] Updated period on success,
36
+ # exception is raised otherwise
37
+ # @example
38
+ # period = @api.periods.first
39
+ # @api.edit_period(period, { end_at: "2014-04-28" })
40
+ def edit_period(period, options = {})
41
+ put("periods/#{period}", periods: [options]).pop
42
+ end
43
+
44
+ # Delete a period
45
+ #
46
+ # @param period [BookingSync::API::Resource|Integer] period or ID of the period
47
+ # to be deleted
48
+ # @return [Array] An empty Array on success, exception is raised otherwise
49
+ def delete_period(period, options = {})
50
+ delete "periods/#{period}"
51
+ end
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,22 @@
1
+ module BookingSync::API
2
+ class Client
3
+ module Photos
4
+ # List photos
5
+ #
6
+ # Returns photos for the account user is authenticated with.
7
+ # @param options [Hash] A customizable set of options.
8
+ # @option options [Array] fields: List of fields to be fetched.
9
+ # @return [Array<BookingSync::API::Resource>] Array of photos.
10
+ #
11
+ # @example Get the list of photos for the current account
12
+ # photos = @api.photos
13
+ # photos.first.position # => 1
14
+ # @example Get the list of photos only with medium_url and position for smaller response
15
+ # @api.photos(fields: [:medium_url, :position])
16
+ # @see http://docs.api.bookingsync.com/reference/endpoints/photos/#list-photos
17
+ def photos(options = {}, &block)
18
+ paginate :photos, options, &block
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,23 @@
1
+ module BookingSync::API
2
+ class Client
3
+ module Rates
4
+ # List rates
5
+ #
6
+ # Returns rates for the rentals of the account user is authenticated with.
7
+ # @param options [Hash] A customizable set of options.
8
+ # @option options [Array] fields: List of fields to be fetched.
9
+ # @return [Array<BookingSync::API::Resource>] Array of rates.
10
+ #
11
+ # @example Get the list of rates for the current account
12
+ # rates = @api.rates
13
+ # rates.first.final_nightly_rate # => 700
14
+ # @example Get the list of rates only with final rates
15
+ # for smaller response
16
+ # @api.rates(fields: %w(final_nightly_rate final_weekely_rate final_monthly_rate))
17
+ # @see http://docs.api.bookingsync.com/reference/endpoints/rates/#list-rates
18
+ def rates(options = {}, &block)
19
+ paginate :rates, options, &block
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,22 @@
1
+ module BookingSync::API
2
+ class Client
3
+ module RatesRules
4
+ # List rates rules
5
+ #
6
+ # Returns rates rules for the account user is authenticated with.
7
+ # @param options [Hash] A customizable set of options.
8
+ # @option options [Array] fields: List of fields to be fetched.
9
+ # @return [Array<BookingSync::API::Resource>] Array of rates rules.
10
+ #
11
+ # @example Get the list of rates rules for the current account
12
+ # rates_rules = @api.rates_rules
13
+ # rates_rules.first.always_applied # => true
14
+ # @example Get the list of rates rules only with always_applied and kind for smaller response
15
+ # @api.rates_rules(fields: [:always_applied, :kind])
16
+ # @see http://docs.api.bookingsync.com/reference/endpoints/rates_rules/#list-rates-rules
17
+ def rates_rules(options = {}, &block)
18
+ paginate :rates_rules, options, &block
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,53 @@
1
+ module BookingSync::API
2
+ class Client
3
+ module RatesTables
4
+ # List rates table
5
+ #
6
+ # Returns rates tables for the account user is authenticated with.
7
+ # @param options [Hash] A customizable set of options.
8
+ # @option options [Array] fields: List of fields to be fetched.
9
+ # @return [Array<BookingSync::API::Resource>] Array of rates tables.
10
+ #
11
+ # @example Get the list of rates tables for the current account
12
+ # rates_tables = @api.rates_tables
13
+ # rates_tables.first.name # => "Rates table 2"
14
+ # @example Get the list of rates tables only with name and account_id for smaller response
15
+ # @api.rates_tables(fields: [:name, :account_id])
16
+ # @see http://docs.api.bookingsync.com/reference/endpoints/rates_tables/#list-rates-tables
17
+ def rates_tables(options = {}, &block)
18
+ paginate :rates_tables, options, &block
19
+ end
20
+
21
+ # Create a new rates_table
22
+ #
23
+ # @param options [Hash] rates_table attributes
24
+ # @return [BookingSync::API::Resource] Newly created rates table
25
+ def create_rates_table(options = {})
26
+ post(:rates_tables, rates_tables: [options]).pop
27
+ end
28
+
29
+ # Edit a rates_table
30
+ #
31
+ # @param rates_table [BookingSync::API::Resource|Integer] rates table or
32
+ # ID of the rates table to be updated
33
+ # @param options [Hash] rates table attributes to be updated
34
+ # @return [BookingSync::API::Resource] Updated rates table on success,
35
+ # exception is raised otherwise
36
+ # @example
37
+ # rates_table = @api.rates_tables.first
38
+ # @api.edit_rates_table(rates_table, { name: "Lorem" })
39
+ def edit_rates_table(rates_table, options = {})
40
+ put("rates_tables/#{rates_table}", rates_tables: [options]).pop
41
+ end
42
+
43
+ # delete a rates_table
44
+ #
45
+ # @param rates_table [BookingSync::API::Resource|Integer] rates table or
46
+ # ID of the rates table to be deleteed
47
+ # @return [Array] An empty Array on success, exception is raised otherwise
48
+ def delete_rates_table(rates_table, options = {})
49
+ delete "rates_tables/#{rates_table}"
50
+ end
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,50 @@
1
+ module BookingSync::API
2
+ class Client
3
+ module RentalAgreements
4
+ # List rental agreements
5
+ #
6
+ # Returns rental agreements for the rentals of the account user is authenticated with.
7
+ # @param options [Hash] A customizable set of options.
8
+ # @option options [Array] fields: List of fields to be fetched.
9
+ # @return [Array<BookingSync::API::Resource>] Array of rental agreements.
10
+ #
11
+ # @example Get the list of rental agreements for the current account
12
+ # agreement = @api.rental_agreements
13
+ # agreement.first.body # => "My rental agreement"
14
+ # @example Get the list of rental agreements only with body for smaller response
15
+ # @api.rentals(fields: :body)
16
+ # @see http://docs.api.bookingsync.com/reference/endpoints/rental_agreements/#list-rental_agreements
17
+ def rental_agreements(options = {}, &block)
18
+ paginate :rental_agreements, options, &block
19
+ end
20
+
21
+ # Create a new rental agreement for a booking
22
+ #
23
+ # @param booking_id [Integer] ID of the booking
24
+ # @param options [Hash] rental agreement attributes
25
+ # @return [BookingSync::API::Response] Newly created rental agreement
26
+ def create_rental_agreement_for_booking(booking_id, options = {})
27
+ post(:rental_agreements, booking_id: booking_id,
28
+ rental_agreements: [options]).pop
29
+ end
30
+
31
+ # Create a new rental agreement for a rental
32
+ #
33
+ # @param rental_id [Integer] ID of the rental
34
+ # @param options [Hash] rental agreement attributes
35
+ # @return [BookingSync::API::Response] Newly created rental agreement
36
+ def create_rental_agreement_for_rental(rental_id, options = {})
37
+ post(:rental_agreements, rental_id: rental_id,
38
+ rental_agreements: [options]).pop
39
+ end
40
+
41
+ # Create a new rental agreement for an account
42
+ #
43
+ # @param options [Hash] rental agreement attributes
44
+ # @return [BookingSync::API::Response] Newly created rental agreement
45
+ def create_rental_agreement(options = {})
46
+ post(:rental_agreements, rental_agreements: [options]).pop
47
+ end
48
+ end
49
+ end
50
+ end