bookingsync-api 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (54) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +3 -0
  3. data/CHANGELOG.md +5 -0
  4. data/Gemfile +11 -11
  5. data/Guardfile +1 -1
  6. data/README.md +1 -0
  7. data/Rakefile +13 -3
  8. data/bookingsync-api.gemspec +3 -3
  9. data/lib/bookingsync-api.rb +1 -1
  10. data/lib/bookingsync/api/client.rb +7 -4
  11. data/lib/bookingsync/api/client/booking_comments.rb +1 -1
  12. data/lib/bookingsync/api/client/living_rooms.rb +65 -0
  13. data/lib/bookingsync/api/error.rb +1 -1
  14. data/lib/bookingsync/api/middleware/logger.rb +6 -6
  15. data/lib/bookingsync/api/resource.rb +1 -1
  16. data/lib/bookingsync/api/response.rb +2 -2
  17. data/lib/bookingsync/api/serializer.rb +5 -5
  18. data/lib/bookingsync/api/version.rb +1 -1
  19. data/spec/bookingsync/api/client/bathrooms_spec.rb +10 -9
  20. data/spec/bookingsync/api/client/bedrooms_spec.rb +10 -9
  21. data/spec/bookingsync/api/client/bookings_spec.rb +13 -13
  22. data/spec/bookingsync/api/client/clients_spec.rb +13 -11
  23. data/spec/bookingsync/api/client/fees_spec.rb +2 -2
  24. data/spec/bookingsync/api/client/inquiries_spec.rb +12 -10
  25. data/spec/bookingsync/api/client/living_rooms_spec.rb +62 -0
  26. data/spec/bookingsync/api/client/nightly_rate_maps_spec.rb +1 -1
  27. data/spec/bookingsync/api/client/payments_spec.rb +8 -11
  28. data/spec/bookingsync/api/client/periods_spec.rb +5 -5
  29. data/spec/bookingsync/api/client/photos_spec.rb +6 -6
  30. data/spec/bookingsync/api/client/preferences_general_settings_spec.rb +1 -1
  31. data/spec/bookingsync/api/client/preferences_payments_spec.rb +0 -1
  32. data/spec/bookingsync/api/client/rates_rules_spec.rb +3 -4
  33. data/spec/bookingsync/api/client/rates_tables_spec.rb +4 -5
  34. data/spec/bookingsync/api/client/rental_agreements_spec.rb +5 -5
  35. data/spec/bookingsync/api/client/rentals_amenities_spec.rb +4 -4
  36. data/spec/bookingsync/api/client/rentals_fees_spec.rb +1 -1
  37. data/spec/bookingsync/api/client/rentals_spec.rb +7 -10
  38. data/spec/bookingsync/api/client/reviews_spec.rb +3 -6
  39. data/spec/bookingsync/api/client/seasons_spec.rb +4 -9
  40. data/spec/bookingsync/api/client/sources_spec.rb +4 -5
  41. data/spec/bookingsync/api/client/special_offers_spec.rb +6 -6
  42. data/spec/bookingsync/api/client/strict_bookings_spec.rb +8 -8
  43. data/spec/bookingsync/api/client_spec.rb +29 -15
  44. data/spec/bookingsync/api/error_spec.rb +3 -3
  45. data/spec/bookingsync/api/relation_spec.rb +8 -6
  46. data/spec/bookingsync/api/resource_spec.rb +29 -26
  47. data/spec/bookingsync/api/response_spec.rb +16 -15
  48. data/spec/fixtures/cassettes/BookingSync_API_Client_LivingRooms/_cancel_living_room/cancels_given_living_room.yml +69 -0
  49. data/spec/fixtures/cassettes/BookingSync_API_Client_LivingRooms/_create_living_room/creates_a_new_living_room.yml +82 -0
  50. data/spec/fixtures/cassettes/BookingSync_API_Client_LivingRooms/_edit_living_room/updates_given_living_room_by_ID.yml +75 -0
  51. data/spec/fixtures/cassettes/BookingSync_API_Client_LivingRooms/_living_room/returns_a_single_living_room.yml +84 -0
  52. data/spec/fixtures/cassettes/BookingSync_API_Client_LivingRooms/_living_rooms/returns_living_rooms.yml +84 -0
  53. data/spec/spec_helper.rb +12 -12
  54. metadata +29 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 04de12efdd7a62fc9a6d1de8f9f164355733e3aa
4
- data.tar.gz: 6891716665121a8822573a79018782c38260c9ec
3
+ metadata.gz: 6915dfa213253a45f23f6ce051ac640ced0823b7
4
+ data.tar.gz: a799e2b306a6adb73939bab9ea6aa2ab63693a9f
5
5
  SHA512:
6
- metadata.gz: 2961489c9f1829c1dec6d2dde5570d7033074a3105f28104d4660080906ae2915c1638047a91f71a9c97c3dc499c82540b3e8ed145cc91bea84d6fb6b5514014
7
- data.tar.gz: 95d4bd74aaef2f441d0f6154ae77f267c98d05da2a1d3a70e3e8b65a7a131d7924617f569f8e5070f172c2bd467b460488ff4cd5147334bf18cb64d2e929a27e
6
+ metadata.gz: af88da09b10078bb703df8da722f11cac55cde73df7982400c84d1912642d1726717be0210a235048dc1a1d704d6533eb632daa35ca1d55484d0c2dafa45a084
7
+ data.tar.gz: 2629e80e6e1461153041c3920d73ac6ae0b8f42eedad7ef4bbbd1645f4014182543e825c3de25c295a03d3af4030de00d1536f1e63e0dad3a5c5d134eb49f0ef
data/.travis.yml CHANGED
@@ -4,3 +4,6 @@ rvm:
4
4
  - "2.2"
5
5
  before_install:
6
6
  - gem install bundler -v 1.12.5
7
+ script:
8
+ - bundle exec rake style:rubocop:without_auto_correct
9
+ - bundle exec rake spec
data/CHANGELOG.md CHANGED
@@ -2,6 +2,11 @@
2
2
 
3
3
  ## master
4
4
 
5
+ ## 0.1.3
6
+
7
+ - Expose pagination_first_request to easily retrieve right timestamps for updated since syncs.
8
+ - Add support for `living_rooms`.
9
+
5
10
  ## 0.1.2
6
11
 
7
12
  - Add support for `payment_gateways`.
data/Gemfile CHANGED
@@ -1,17 +1,17 @@
1
- source 'https://rubygems.org'
1
+ source "https://rubygems.org"
2
2
 
3
3
  # Specify your gem's dependencies in bookingsync-api.gemspec
4
4
 
5
- group 'test' do
6
- gem 'rspec'
7
- gem 'vcr'
8
- gem 'webmock'
9
- gem 'guard'
10
- gem 'guard-rspec'
11
- gem 'yard'
12
- gem 'ruby_gntp'
13
- gem 'pry'
14
- gem 'listen', '~> 3.0.0'
5
+ group "test" do
6
+ gem "rspec"
7
+ gem "vcr"
8
+ gem "webmock"
9
+ gem "guard"
10
+ gem "guard-rspec"
11
+ gem "yard"
12
+ gem "ruby_gntp"
13
+ gem "pry"
14
+ gem "listen", "~> 3.0.0"
15
15
  end
16
16
 
17
17
  gemspec
data/Guardfile CHANGED
@@ -3,5 +3,5 @@ guard :rspec, cmd: "bundle exec rspec --format p" do
3
3
  watch(%r{^lib/bookingsync/(.+)\.rb$}) { |m| "spec/bookingsync/#{m[1]}_spec.rb" }
4
4
  watch(%r{^lib/bookingsync/api/client/(.+)\.rb$}) { |m| "spec/bookingsync/api/client/#{m[1]}_spec.rb" }
5
5
  watch(%r{^lib/bookingsync/api/(.+)\.rb$}) { |m| "spec" }
6
- watch('spec/spec_helper.rb') { "spec" }
6
+ watch("spec/spec_helper.rb") { "spec" }
7
7
  end
data/README.md CHANGED
@@ -67,6 +67,7 @@ access last response.
67
67
  ```ruby
68
68
  api.rentals(updated_since: "2014-01-01 15:43:96 UTC") # => [BookingSync::API::Resource, BookingSync::API::Resource, ...]
69
69
  api.last_response.meta # => {"deleted_ids" => [1, 3, 4]}
70
+ api.pagination_first_response.meta # => {"deleted_ids" => [1, 3, 4]}
70
71
  ```
71
72
 
72
73
  ### Logging
data/Rakefile CHANGED
@@ -1,4 +1,14 @@
1
- require "bundler/gem_tasks"
2
- require 'rspec/core/rake_task'
3
- task :default => :spec
1
+ begin
2
+ require "bundler/setup"
3
+ rescue LoadError
4
+ puts "You must `gem install bundler` and `bundle install` to run rake tasks"
5
+ end
6
+
7
+ Bundler::GemHelper.install_tasks
8
+
9
+ require "rspec/core/rake_task"
10
+ task default: :spec
4
11
  RSpec::Core::RakeTask.new
12
+
13
+ require "bookingsync/stylecheck"
14
+ load "bookingsync/tasks/stylecheck.rake"
@@ -1,7 +1,6 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
1
+ lib = File.expand_path("../lib", __FILE__)
3
2
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'bookingsync/api/version'
3
+ require "bookingsync/api/version"
5
4
 
6
5
  Gem::Specification.new do |spec|
7
6
  spec.name = "bookingsync-api"
@@ -23,4 +22,5 @@ Gem::Specification.new do |spec|
23
22
  spec.add_dependency "addressable"
24
23
  spec.add_development_dependency "bundler", "~> 1.5"
25
24
  spec.add_development_dependency "rake"
25
+ spec.add_development_dependency "bookingsync-stylecheck"
26
26
  end
@@ -1 +1 @@
1
- require 'bookingsync/api'
1
+ require "bookingsync/api"
@@ -14,6 +14,7 @@ require "bookingsync/api/client/clients"
14
14
  require "bookingsync/api/client/destinations"
15
15
  require "bookingsync/api/client/fees"
16
16
  require "bookingsync/api/client/inquiries"
17
+ require "bookingsync/api/client/living_rooms"
17
18
  require "bookingsync/api/client/nightly_rate_maps"
18
19
  require "bookingsync/api/client/strict_bookings"
19
20
  require "bookingsync/api/client/periods"
@@ -62,6 +63,7 @@ module BookingSync::API
62
63
  include BookingSync::API::Client::Destinations
63
64
  include BookingSync::API::Client::Fees
64
65
  include BookingSync::API::Client::Inquiries
66
+ include BookingSync::API::Client::LivingRooms
65
67
  include BookingSync::API::Client::NightlyRateMaps
66
68
  include BookingSync::API::Client::StrictBookings
67
69
  include BookingSync::API::Client::Periods
@@ -87,7 +89,7 @@ module BookingSync::API
87
89
 
88
90
  MEDIA_TYPE = "application/vnd.api+json"
89
91
 
90
- attr_reader :token, :logger, :last_response
92
+ attr_reader :token, :logger, :pagination_first_response, :last_response
91
93
 
92
94
  def_delegator :@instrumenter, :instrument
93
95
 
@@ -208,9 +210,10 @@ module BookingSync::API
208
210
  else
209
211
  response = call(request_method, path, options)
210
212
  end
213
+ @pagination_first_response = response
211
214
  data = response.resources.dup
212
215
 
213
- if (block_given? or auto_paginate) && response.relations[:next]
216
+ if (block_given? || auto_paginate) && response.relations[:next]
214
217
  first_request = true
215
218
  loop do
216
219
  if block_given?
@@ -220,7 +223,7 @@ module BookingSync::API
220
223
  first_request = false
221
224
  end
222
225
  break unless response.relations[:next]
223
- response = response.relations[:next].call({}, method: request_method)
226
+ response = response.relations[:next].call({}, { method: request_method })
224
227
  end
225
228
  end
226
229
 
@@ -248,7 +251,7 @@ module BookingSync::API
248
251
 
249
252
  if options.has_key?(:query)
250
253
  if options[:query].has_key?(:ids)
251
- ids = Array(options[:query].delete(:ids)).join(',')
254
+ ids = Array(options[:query].delete(:ids)).join(",")
252
255
  path = "#{path}/#{ids}"
253
256
  end
254
257
  options[:query].keys.each do |key|
@@ -41,7 +41,7 @@ module BookingSync::API
41
41
  # @api.create_booking_comment(1, content: "Hello!")
42
42
  # => {:links=>{:booking=>1}, :id=>8, :content=>"Hello!", :editable=>true, :created_at=>2016-04-18 13:31:40 UTC, :updated_at=>2016-04-18 13:46:06 UTC}
43
43
  def create_booking_comment(booking, options = {})
44
- post("booking_comments", { booking_id: booking, booking_comments: [options] }).pop
44
+ post("booking_comments", booking_id: booking, booking_comments: [options]).pop
45
45
  end
46
46
 
47
47
  # Edit a booking_comment
@@ -0,0 +1,65 @@
1
+ module BookingSync::API
2
+ class Client
3
+ module LivingRooms
4
+ # List living_rooms
5
+ #
6
+ # Returns living_rooms 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 living_rooms.
10
+ #
11
+ # @example Get the list of living_rooms for the current account
12
+ # living_rooms = @api.living_rooms
13
+ # living_rooms.first.bunk_beds_count # => 2
14
+ # @example Get the list of living_rooms only with bunk_beds_count for smaller response
15
+ # @api.living_rooms(fields: [:bunk_beds_count])
16
+ def living_rooms(options = {}, &block)
17
+ paginate :living_rooms, options, &block
18
+ end
19
+
20
+ # Get a single living_room
21
+ #
22
+ # @param living_room [BookingSync::API::Resource|Integer] LivingRoom or ID
23
+ # of the living_room.
24
+ # @param options [Hash] A customizable set of query options.
25
+ # @option options [Array] fields: List of fields to be fetched.
26
+ # @return [BookingSync::API::Resource]
27
+ def living_room(living_room, options = {})
28
+ get("living_rooms/#{living_room}", options).pop
29
+ end
30
+
31
+ # Create a new living_room
32
+ #
33
+ # @param rental [BookingSync::API::Resource|Integer] Rental or ID of
34
+ # the rental for which living_room will be created.
35
+ # @param options [Hash] LivingRoom's attributes.
36
+ # @return [BookingSync::API::Resource] Newly created living_room.
37
+ def create_living_room(rental, options = {})
38
+ post("rentals/#{rental}/living_rooms", living_rooms: [options]).pop
39
+ end
40
+
41
+ # Edit a living_room
42
+ #
43
+ # @param living_room [BookingSync::API::Resource|Integer] LivingRoom or ID of
44
+ # the living_room to be updated.
45
+ # @param options [Hash] LivingRoom attributes to be updated.
46
+ # @return [BookingSync::API::Resource] Updated living_room on success,
47
+ # exception is raised otherwise.
48
+ # @example
49
+ # living_room = @api.living_rooms.first
50
+ # @api.edit_living_room(living_room, { bunk_beds_count: 3 })
51
+ def edit_living_room(living_room, options = {})
52
+ put("living_rooms/#{living_room}", living_rooms: [options]).pop
53
+ end
54
+
55
+ # Cancel a living_room
56
+ #
57
+ # @param living_room [BookingSync::API::Resource|Integer] LivingRoom or ID
58
+ # of the living_room to be canceled.
59
+ # @return [NilClass] Returns nil on success.
60
+ def cancel_living_room(living_room)
61
+ delete "living_rooms/#{living_room}"
62
+ end
63
+ end
64
+ end
65
+ end
@@ -10,7 +10,7 @@ module BookingSync::API
10
10
  end
11
11
 
12
12
  def message(message = self.class)
13
- %Q{#{message}
13
+ %{#{message}
14
14
  HTTP status code : #{status}
15
15
  Headers : #{headers}
16
16
  Body : #{body}}
@@ -1,4 +1,4 @@
1
- require 'forwardable'
1
+ require "forwardable"
2
2
 
3
3
  module BookingSync::API::Middleware
4
4
  # Provides logger for request and responses made by API Client.
@@ -20,13 +20,13 @@ module BookingSync::API::Middleware
20
20
 
21
21
  def call(env)
22
22
  info "Request #{env.method.upcase} #{env.url.to_s}"
23
- debug('Request headers') { dump_headers env.request_headers }
24
- debug('Request body') { dump_body env.body }
23
+ debug("Request headers") { dump_headers env.request_headers }
24
+ debug("Request body") { dump_body env.body }
25
25
  @app.call(env).tap do |response|
26
26
  info "Response X-Request-Id: #{env.response_headers['X-Request-Id']} #{env.method.upcase} #{env.url.to_s}"
27
- debug('Response headers') { dump_headers response.env.response_headers }
28
- debug('Response status') { response.env.status }
29
- debug('Response body') { dump_body response.env.body }
27
+ debug("Response headers") { dump_headers response.env.response_headers }
28
+ debug("Response status") { response.env.status }
29
+ debug("Response body") { dump_body response.env.body }
30
30
  end
31
31
  end
32
32
 
@@ -69,7 +69,7 @@ module BookingSync::API
69
69
 
70
70
  def extract_resources(ids, association_key, uri_association_key, *args)
71
71
  return [] if ids.empty?
72
- options = {uri: {uri_association_key => ids}}
72
+ options = { uri: { uri_association_key => ids } }
73
73
  options.merge!(query: args.first) if args.first.is_a?(Hash)
74
74
  @_rels[association_key].get(options).resources
75
75
  end
@@ -76,9 +76,9 @@ module BookingSync::API
76
76
  end
77
77
 
78
78
  def process_rels
79
- links = ( @headers["Link"] || "" ).split(', ').map do |link|
79
+ links = (@headers["Link"] || "").split(", ").map do |link|
80
80
  href, name = link.match(/<(.*?)>; rel="(\w+)"/).captures
81
- [name.to_sym, Relation.from_link(@client, name, :href => href)]
81
+ [name.to_sym, Relation.from_link(@client, name, href: href)]
82
82
  end
83
83
  Hash[*links.flatten]
84
84
  end
@@ -1,6 +1,6 @@
1
- require 'date'
2
- require 'time'
3
- require 'json'
1
+ require "date"
2
+ require "time"
3
+ require "json"
4
4
 
5
5
  module BookingSync::API
6
6
  class Serializer
@@ -22,7 +22,7 @@ module BookingSync::API
22
22
  @dump.call(encode_object(data))
23
23
  end
24
24
 
25
- alias dump encode
25
+ alias_method :dump, :encode
26
26
 
27
27
  # Public: Decodes a String into an Object (usually a Hash or Array of
28
28
  # Hashes).
@@ -35,7 +35,7 @@ module BookingSync::API
35
35
  decode_object(@load.call(data))
36
36
  end
37
37
 
38
- alias load decode
38
+ alias_method :load, :decode
39
39
 
40
40
  def encode_object(data)
41
41
  case data
@@ -1,5 +1,5 @@
1
1
  module BookingSync
2
2
  module API
3
- VERSION = "0.1.2"
3
+ VERSION = "0.1.3"
4
4
  end
5
5
  end
@@ -1,7 +1,6 @@
1
1
  require "spec_helper"
2
2
 
3
3
  describe BookingSync::API::Client::Bathrooms do
4
-
5
4
  let(:client) { BookingSync::API::Client.new(test_access_token) }
6
5
 
7
6
  describe ".bathrooms", :vcr do
@@ -19,10 +18,12 @@ describe BookingSync::API::Client::Bathrooms do
19
18
  end
20
19
 
21
20
  describe ".create_bathroom", :vcr do
22
- let(:attributes) {{
23
- name_en: "New bathroom",
24
- wc: true
25
- }}
21
+ let(:attributes) do
22
+ {
23
+ name_en: "New bathroom",
24
+ wc: true
25
+ }
26
+ end
26
27
  let(:rental) { BookingSync::API::Resource.new(client, id: 5116) }
27
28
 
28
29
  it "creates a new bathroom" do
@@ -32,9 +33,9 @@ describe BookingSync::API::Client::Bathrooms do
32
33
  end
33
34
 
34
35
  it "returns newly created bathroom" do
35
- VCR.use_cassette('BookingSync_API_Client_Bathrooms/_create_bathroom/creates_a_new_bathroom') do
36
+ VCR.use_cassette("BookingSync_API_Client_Bathrooms/_create_bathroom/creates_a_new_bathroom") do
36
37
  bathroom = client.create_bathroom(rental, attributes)
37
- expect(bathroom.name).to eql({ en: "New bathroom" })
38
+ expect(bathroom.name).to eql(en: "New bathroom")
38
39
  expect(bathroom.wc).to eql(attributes[:wc])
39
40
  end
40
41
  end
@@ -52,10 +53,10 @@ describe BookingSync::API::Client::Bathrooms do
52
53
  end
53
54
 
54
55
  it "returns updated bathroom" do
55
- VCR.use_cassette('BookingSync_API_Client_Bathrooms/_edit_bathroom/updates_given_bathroom_by_ID') do
56
+ VCR.use_cassette("BookingSync_API_Client_Bathrooms/_edit_bathroom/updates_given_bathroom_by_ID") do
56
57
  bathroom = client.edit_bathroom(729, attributes)
57
58
  expect(bathroom).to be_kind_of(BookingSync::API::Resource)
58
- expect(bathroom.name).to eq({ en: "Updated bathroom", fr: "Salle de bain 1" })
59
+ expect(bathroom.name).to eq(en: "Updated bathroom", fr: "Salle de bain 1")
59
60
  end
60
61
  end
61
62
  end
@@ -1,7 +1,6 @@
1
1
  require "spec_helper"
2
2
 
3
3
  describe BookingSync::API::Client::Bedrooms do
4
-
5
4
  let(:client) { BookingSync::API::Client.new(test_access_token) }
6
5
 
7
6
  describe ".bedrooms", :vcr do
@@ -19,10 +18,12 @@ describe BookingSync::API::Client::Bedrooms do
19
18
  end
20
19
 
21
20
  describe ".create_bedroom", :vcr do
22
- let(:attributes) {{
23
- name_en: "New bedroom",
24
- sofa_beds_count: 2
25
- }}
21
+ let(:attributes) do
22
+ {
23
+ name_en: "New bedroom",
24
+ sofa_beds_count: 2
25
+ }
26
+ end
26
27
  let(:rental) { BookingSync::API::Resource.new(client, id: 5116) }
27
28
 
28
29
  it "creates a new bedroom" do
@@ -32,9 +33,9 @@ describe BookingSync::API::Client::Bedrooms do
32
33
  end
33
34
 
34
35
  it "returns newly created bedroom" do
35
- VCR.use_cassette('BookingSync_API_Client_Bedrooms/_create_bedroom/creates_a_new_bedroom') do
36
+ VCR.use_cassette("BookingSync_API_Client_Bedrooms/_create_bedroom/creates_a_new_bedroom") do
36
37
  bedroom = client.create_bedroom(rental, attributes)
37
- expect(bedroom.name).to eql({ en: "New bedroom" })
38
+ expect(bedroom.name).to eql(en: "New bedroom")
38
39
  expect(bedroom.sofa_beds_count).to eql(attributes[:sofa_beds_count])
39
40
  end
40
41
  end
@@ -52,10 +53,10 @@ describe BookingSync::API::Client::Bedrooms do
52
53
  end
53
54
 
54
55
  it "returns updated bedroom" do
55
- VCR.use_cassette('BookingSync_API_Client_Bedrooms/_edit_bedroom/updates_given_bedroom_by_ID') do
56
+ VCR.use_cassette("BookingSync_API_Client_Bedrooms/_edit_bedroom/updates_given_bedroom_by_ID") do
56
57
  bedroom = client.edit_bedroom(944, attributes)
57
58
  expect(bedroom).to be_kind_of(BookingSync::API::Resource)
58
- expect(bedroom.name).to eq({ en: "Updated bedroom", fr: "Chambre 1" })
59
+ expect(bedroom.name).to eq(en: "Updated bedroom", fr: "Chambre 1")
59
60
  end
60
61
  end
61
62
  end
@@ -44,26 +44,26 @@ describe BookingSync::API::Client::Bookings do
44
44
  end
45
45
 
46
46
  it "returns a single canceled booking" do
47
- booking = client.booking(114760, { include_canceled: true })
47
+ booking = client.booking(114760, include_canceled: true)
48
48
  expect(booking.status).to eq "Canceled"
49
49
  end
50
50
  end
51
51
 
52
52
  describe ".create_booking", :vcr do
53
53
  let(:attributes) {
54
- {start_at: '2014-01-03', end_at: '2014-01-04',
55
- booked: true}
54
+ { start_at: "2014-01-03", end_at: "2014-01-04",
55
+ booked: true }
56
56
  }
57
57
  let(:rental) { BookingSync::API::Resource.new(client, id: 20) }
58
58
 
59
59
  it "creates a booking" do
60
60
  client.create_booking(rental, attributes)
61
61
  assert_requested :post, bs_url("rentals/20/bookings"),
62
- body: {bookings: [attributes]}.to_json
62
+ body: { bookings: [attributes] }.to_json
63
63
  end
64
64
 
65
65
  it "returns newly created booking" do
66
- VCR.use_cassette('BookingSync_API_Client_Bookings/_create_booking/creates_a_booking') do
66
+ VCR.use_cassette("BookingSync_API_Client_Bookings/_create_booking/creates_a_booking") do
67
67
  booking = client.create_booking(rental, attributes)
68
68
  expect(booking.account_id).to eql(1)
69
69
  expect(booking.rental_id).to eql(20)
@@ -73,25 +73,25 @@ describe BookingSync::API::Client::Bookings do
73
73
 
74
74
  describe ".edit_booking", :vcr do
75
75
  it "updates given booking by ID" do
76
- client.edit_booking(50, {end_at: "2019-03-25 21:45:00 UTC"})
76
+ client.edit_booking(50, end_at: "2019-03-25 21:45:00 UTC")
77
77
  assert_requested :put, bs_url("bookings/50"),
78
- body: {bookings: [{end_at: "2019-03-25 21:45:00 UTC"}]}.to_json
78
+ body: { bookings: [{ end_at: "2019-03-25 21:45:00 UTC" }] }.to_json
79
79
  end
80
80
 
81
81
  it "returns updated booking" do
82
- VCR.use_cassette('BookingSync_API_Client_Bookings/_edit_booking/updates_given_booking_by_ID') do
83
- booking = client.edit_booking(50, {end_at: "2019-03-25 21:45:00 UTC"})
82
+ VCR.use_cassette("BookingSync_API_Client_Bookings/_edit_booking/updates_given_booking_by_ID") do
83
+ booking = client.edit_booking(50, end_at: "2019-03-25 21:45:00 UTC")
84
84
  expect(booking).to be_kind_of(BookingSync::API::Resource)
85
85
  expect(booking.end_at).to eq(Time.parse("2019-03-25 21:45:00 UTC"))
86
86
  end
87
87
  end
88
88
 
89
89
  it "updates given booking by Resource object" do
90
- VCR.use_cassette('BookingSync_API_Client_Bookings/_edit_booking/updates_given_booking_by_ID') do
91
- resource = BookingSync::API::Resource.new(nil, {id: 50})
92
- client.edit_booking(resource, {end_at: "2019-03-25 21:45:00 UTC"})
90
+ VCR.use_cassette("BookingSync_API_Client_Bookings/_edit_booking/updates_given_booking_by_ID") do
91
+ resource = BookingSync::API::Resource.new(nil, id: 50)
92
+ client.edit_booking(resource, end_at: "2019-03-25 21:45:00 UTC")
93
93
  assert_requested :put, bs_url("bookings/50"),
94
- body: {bookings: [{end_at: "2019-03-25 21:45:00 UTC"}]}.to_json
94
+ body: { bookings: [{ end_at: "2019-03-25 21:45:00 UTC" }] }.to_json
95
95
  end
96
96
  end
97
97
  end