bookingsync-api 0.1.5 → 0.1.6

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ce66e1f4e1cc24f2a8b0cef1b32a25aab9ff1d9a
4
- data.tar.gz: f47f52988544b9077a593b28608e64cc8c541c1c
3
+ metadata.gz: b4bdc178f4f613906121ad78aad98201367df968
4
+ data.tar.gz: 2b8d7e57f9214e6c95723e063214f32ce12f5fc6
5
5
  SHA512:
6
- metadata.gz: 25f4e1764280d93fef798b6d0e911f0f848d14858c2d3cedbf790671719b62a068ce5451fa2e67f7d934bd09d042f95ceb4de50b0fb8ec43bdc95056088bb8ae
7
- data.tar.gz: 459ee676056b24da21febbf25203c3b7537f0fdaa90721a7be4e979662d41ff4112b20ba0cfcb27cb66976242cc10da4c751e606722be6179866546312b7416a
6
+ metadata.gz: 62d73a7a7549eb864acdb2264704f773426a3846f39a3e614f5ba0faa7f3cb12422d570a7209d4b74b2c7f6b2f7bc697466e0c7a1d2c9d58c32018dfc7dae990
7
+ data.tar.gz: e34023ccf4e35aca1a5b1be1fa1e9f0deebb46e31cecf6e9dd965609e702923eb931722f7a4651e5ab28f8126749648ccc7bb4e125f372eda92322af12e583e9
@@ -2,6 +2,10 @@
2
2
 
3
3
  ## master
4
4
 
5
+ ## 0.1.6 - 2017-10-30
6
+
7
+ - Add support for addition and removal of bookings_fees
8
+
5
9
  ## 0.1.5
6
10
 
7
11
  - `Bookings#cancel_booking` supports passing attributes in body.
@@ -142,6 +142,15 @@ module BookingSync::API
142
142
  request :put, path, options
143
143
  end
144
144
 
145
+ # Make a HTTP PATCH request
146
+ #
147
+ # @param path [String] The path, relative to {#api_endpoint}
148
+ # @param options [Hash] Body params for the request
149
+ # @return [Array<BookingSync::API::Resource>]
150
+ def patch(path, options = {})
151
+ request :patch, path, options
152
+ end
153
+
145
154
  # Make a HTTP DELETE request
146
155
  #
147
156
  # @param path [String] The path, relative to {#api_endpoint}
@@ -82,6 +82,32 @@ module BookingSync::API
82
82
  options = { bookings: [options] } if options
83
83
  delete "bookings/#{booking}", options
84
84
  end
85
+
86
+ # Add a bookings_fee
87
+ #
88
+ # @param booking [BookingSync::API::Resource|Integer] Booking or ID of the booking
89
+ # for which the bookings fee should be added
90
+ # @param options [Hash] Bookings_fee attributes.
91
+ # @return [BookingSync::API::Resource] Booking attributes, bookings fees included
92
+ # @example
93
+ # booking = @api.bookings.first
94
+ # @api.add_bookings_fee(booking, { price: 100, times_booked: 1, name_en: "Cleaning Fee" })
95
+ def add_bookings_fee(booking, options = {})
96
+ patch("bookings/#{booking}/add_bookings_fee", bookings_fees: [options]).pop
97
+ end
98
+
99
+ # Remove a bookings_fee
100
+ #
101
+ # @param booking [BookingSync::API::Resource|Integer] Booking or ID of the booking
102
+ # for which the bookings fee should be removed
103
+ # @param options [Integer] ID of the bookings_fee to be removed.
104
+ # @return [BookingSync::API::Resource] Booking attributes, remaining bookings fees included
105
+ # @example
106
+ # booking = @api.bookings.first
107
+ # @api.remove_bookings_fee(booking, 1)
108
+ def remove_bookings_fee(booking, bookings_fee_id)
109
+ patch("bookings/#{booking}/remove_bookings_fee/#{bookings_fee_id}").pop
110
+ end
85
111
  end
86
112
  end
87
113
  end
@@ -1,5 +1,5 @@
1
1
  module BookingSync
2
2
  module API
3
- VERSION = "0.1.5"
3
+ VERSION = "0.1.6"
4
4
  end
5
5
  end
@@ -117,4 +117,42 @@ describe BookingSync::API::Client::Bookings do
117
117
  body: { bookings: [{ cancelation_reason: "payment_failed" }] }.to_json
118
118
  end
119
119
  end
120
+
121
+ describe ".add_bookings_fee_booking" do
122
+ let(:created_booking_id) {
123
+ find_resource("#{@casette_base_path}_create_booking/creates_a_booking.yml", "bookings")[:id]
124
+ }
125
+
126
+ around do |example|
127
+ VCR.use_cassette("BookingSync_API_Client_Bookings/_add_bookings_fee/adds_bookings_fee") do
128
+ example.run
129
+ end
130
+ end
131
+
132
+ it "returns with bookings_fee" do
133
+ booking = client.add_bookings_fee(created_booking_id, price: 50, times_booked: 1, name_en: "Airport transfer")
134
+ expect(booking).to be_kind_of(BookingSync::API::Resource)
135
+ expect(booking.bookings_fees).to eq(
136
+ [
137
+ {
138
+ id: 194398, booking_id: 840043, rentals_fee_id: nil, times_booked: 1, price: "50.0",
139
+ created_at: Time.parse("2017-10-29 10:16:57 UTC"), updated_at: Time.parse("2017-10-29 10:16:57 UTC"),
140
+ canceled_at: nil, commission: nil, payback_to_owner: nil, locked: nil,
141
+ name: "Airport transfer"
142
+ }
143
+ ]
144
+ )
145
+ end
146
+ end
147
+
148
+ describe ".remove_bookings_fee", :vcr do
149
+ let(:booking_id) { 840043 }
150
+ let(:bookings_fee_id) { 194396 }
151
+
152
+ it "removes bookings_fee and returns with booking" do
153
+ booking = client.remove_bookings_fee(booking_id, bookings_fee_id)
154
+ expect(booking).to be_kind_of(BookingSync::API::Resource)
155
+ expect(booking.bookings_fees).to eq([])
156
+ end
157
+ end
120
158
  end
@@ -30,7 +30,7 @@ describe BookingSync::API::Client::RentalsAmenities do
30
30
  }
31
31
 
32
32
  it "returns rentals_amenity" do
33
- amenity = client.rentals_amenity(prefetched_rentals_amenity_id)
33
+ client.rentals_amenity(prefetched_rentals_amenity_id)
34
34
  assert_requested :get, bs_url("rentals_amenities/#{prefetched_rentals_amenity_id}")
35
35
  end
36
36
  end
@@ -118,7 +118,7 @@ describe BookingSync::API::Client do
118
118
 
119
119
  it "requests with proper User-Agent" do
120
120
  stub_get("resource", body: {}.to_json)
121
- response = client.call(:get, "resource")
121
+ client.call(:get, "resource")
122
122
  assert_requested :get, bs_url("resource"),
123
123
  headers: { "User-Agent" =>
124
124
  "BookingSync API gem v#{BookingSync::API::VERSION}" }
@@ -29,7 +29,7 @@ describe BookingSync::API::Response do
29
29
  end
30
30
  end
31
31
  let(:response) do
32
- stubs = Faraday::Adapter::Test::Stubs.new
32
+ Faraday::Adapter::Test::Stubs.new
33
33
  client.call(:get, "/rentals")
34
34
  end
35
35
 
@@ -0,0 +1,75 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: patch
5
+ uri: https://www.bookingsync.com/api/v3/bookings/840043/add_bookings_fee
6
+ body:
7
+ encoding: UTF-8
8
+ string: '{"bookings_fees":[{"price":100,"times_booked":2,"name_en":"Cleaning Fee"}]}'
9
+ headers:
10
+ User-Agent:
11
+ - BookingSync API gem v0.1.5
12
+ Accept:
13
+ - application/vnd.api+json
14
+ Content-Type:
15
+ - application/vnd.api+json
16
+ Authorization:
17
+ - Bearer <<ACCESS_TOKEN>>
18
+ Accept-Encoding:
19
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
20
+ Connection:
21
+ - keep-alive
22
+ Keep-Alive:
23
+ - '30'
24
+ response:
25
+ status:
26
+ code: 200
27
+ message: OK
28
+ headers:
29
+ Server:
30
+ - nginx
31
+ Date:
32
+ - Sun, 29 Oct 2017 10:16:57 GMT
33
+ Content-Type:
34
+ - application/json; charset=utf-8
35
+ Transfer-Encoding:
36
+ - chunked
37
+ Connection:
38
+ - keep-alive
39
+ X-Frame-Options:
40
+ - SAMEORIGIN
41
+ X-Xss-Protection:
42
+ - 1; mode=block
43
+ X-Content-Type-Options:
44
+ - nosniff
45
+ X-Updated-Since-Request-Synced-At:
46
+ - 2017-10-29 10:16:57 UTC
47
+ X-Ratelimit-Limit:
48
+ - '100000'
49
+ X-Ratelimit-Reset:
50
+ - '1509274800'
51
+ X-Ratelimit-Remaining:
52
+ - '99995'
53
+ Cache-Control:
54
+ - max-age=0, private, must-revalidate
55
+ P3p:
56
+ - CP="OTI DSP COR CUR ADMo DEVo TAI PSAi PSDi IVAi IVDi CONi HISi TELi OTPi
57
+ OUR SAMi OTRo UNRo PUBi IND UNI STA"
58
+ Set-Cookie:
59
+ - ahoy_track=true; path=/; secure
60
+ - ahoy_visit=a6283719-06f8-4a28-b009-d4956eb857e4; path=/; expires=Sun, 05 Nov
61
+ 2017 10:16:57 -0000; secure
62
+ - ahoy_visitor=bf93817c-f70e-49c4-a062-b01dca375152; path=/; expires=Tue, 29
63
+ Oct 2019 10:16:57 -0000; secure
64
+ X-Request-Id:
65
+ - db7d67d5-19c2-438b-a9e1-16f861b9a4c4
66
+ X-Runtime:
67
+ - '0.130803'
68
+ Strict-Transport-Security:
69
+ - max-age=31536000
70
+ body:
71
+ encoding: ASCII-8BIT
72
+ string: '{"bookings":[{"id":840043,"start_at":"2017-01-03T00:00:00Z","end_at":"2019-03-25T21:45:00Z","booked":true,"unavailable":false,"tentative_expires_at":null,"rental_id":5116,"client_id":null,"initial_price":"200.0","discount":"","final_price":"600.0","notes":null,"adults":null,"children":null,"account_id":3837,"created_at":"2016-12-12T11:52:09Z","updated_at":"2017-10-29T10:16:57Z","canceled_at":"2016-12-12T12:13:16Z","downpayment":null,"currency":"USD","source_id":null,"damage_deposit":"0.0","reference":"00I06J","bookings_fees":[{"id":194398,"booking_id":840043,"rentals_fee_id":null,"times_booked":1,"price":"50.0","created_at":"2017-10-29T10:16:57Z","updated_at":"2017-10-29T10:16:57Z","canceled_at":null,"commission":null,"payback_to_owner":null,"locked":null,"name":"Airport transfer"}]}]}'
73
+ http_version:
74
+ recorded_at: Sun, 29 Oct 2017 10:16:57 GMT
75
+ recorded_with: VCR 3.0.3
@@ -0,0 +1,75 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: patch
5
+ uri: https://www.bookingsync.com/api/v3/bookings/840043/remove_bookings_fee/194396
6
+ body:
7
+ encoding: UTF-8
8
+ string: "{}"
9
+ headers:
10
+ User-Agent:
11
+ - BookingSync API gem v0.1.5
12
+ Accept:
13
+ - application/vnd.api+json
14
+ Content-Type:
15
+ - application/vnd.api+json
16
+ Authorization:
17
+ - Bearer <<ACCESS_TOKEN>>
18
+ Accept-Encoding:
19
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
20
+ Connection:
21
+ - keep-alive
22
+ Keep-Alive:
23
+ - '30'
24
+ response:
25
+ status:
26
+ code: 200
27
+ message: OK
28
+ headers:
29
+ Server:
30
+ - nginx
31
+ Date:
32
+ - Sun, 29 Oct 2017 10:43:52 GMT
33
+ Content-Type:
34
+ - application/json; charset=utf-8
35
+ Transfer-Encoding:
36
+ - chunked
37
+ Connection:
38
+ - keep-alive
39
+ X-Frame-Options:
40
+ - SAMEORIGIN
41
+ X-Xss-Protection:
42
+ - 1; mode=block
43
+ X-Content-Type-Options:
44
+ - nosniff
45
+ X-Updated-Since-Request-Synced-At:
46
+ - 2017-10-29 10:43:52 UTC
47
+ X-Ratelimit-Limit:
48
+ - '100000'
49
+ X-Ratelimit-Reset:
50
+ - '1509274800'
51
+ X-Ratelimit-Remaining:
52
+ - '99993'
53
+ Cache-Control:
54
+ - max-age=0, private, must-revalidate
55
+ P3p:
56
+ - CP="OTI DSP COR CUR ADMo DEVo TAI PSAi PSDi IVAi IVDi CONi HISi TELi OTPi
57
+ OUR SAMi OTRo UNRo PUBi IND UNI STA"
58
+ Set-Cookie:
59
+ - ahoy_track=true; path=/; secure
60
+ - ahoy_visit=95efe1f9-dd76-4436-91d2-99079a1d8618; path=/; expires=Sun, 05 Nov
61
+ 2017 10:43:52 -0000; secure
62
+ - ahoy_visitor=bd1c23be-fbc2-46e1-9afb-db65d5ba5fe3; path=/; expires=Tue, 29
63
+ Oct 2019 10:43:52 -0000; secure
64
+ X-Request-Id:
65
+ - b47cb7ec-be49-4c29-8d46-7960f0ea2e7c
66
+ X-Runtime:
67
+ - '0.128591'
68
+ Strict-Transport-Security:
69
+ - max-age=31536000
70
+ body:
71
+ encoding: ASCII-8BIT
72
+ string: '{"bookings":[{"id":840043,"start_at":"2017-01-03T00:00:00Z","end_at":"2019-03-25T21:45:00Z","booked":true,"unavailable":false,"tentative_expires_at":null,"rental_id":5116,"client_id":null,"initial_price":"200.0","discount":"","final_price":"200.0","notes":null,"adults":null,"children":null,"account_id":3837,"created_at":"2016-12-12T11:52:09Z","updated_at":"2017-10-29T10:43:52Z","canceled_at":"2016-12-12T12:13:16Z","downpayment":null,"currency":"USD","source_id":null,"damage_deposit":"0.0","reference":"00I06J","bookings_fees":[]}]}'
73
+ http_version:
74
+ recorded_at: Sun, 29 Oct 2017 10:43:53 GMT
75
+ recorded_with: VCR 3.0.3
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bookingsync-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sébastien Grosjean
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-06-21 00:00:00.000000000 Z
11
+ date: 2017-10-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -238,6 +238,7 @@ files:
238
238
  - spec/fixtures/cassettes/BookingSync_API_Client_BookingComments/_delete_booking_comment/deletes_given_booking_comment.yml
239
239
  - spec/fixtures/cassettes/BookingSync_API_Client_BookingComments/_edit_booking_comment/returns_updated_booking_comment.yml
240
240
  - spec/fixtures/cassettes/BookingSync_API_Client_BookingComments/_edit_booking_comment/updates_booking_comment.yml
241
+ - spec/fixtures/cassettes/BookingSync_API_Client_Bookings/_add_bookings_fee/adds_bookings_fee.yml
241
242
  - spec/fixtures/cassettes/BookingSync_API_Client_Bookings/_booking/returns_a_single_booking.yml
242
243
  - spec/fixtures/cassettes/BookingSync_API_Client_Bookings/_booking/returns_a_single_canceled_booking.yml
243
244
  - spec/fixtures/cassettes/BookingSync_API_Client_Bookings/_bookings/pagination/with_a_block/yields_block_with_batch_of_bookings.yml
@@ -247,6 +248,7 @@ files:
247
248
  - spec/fixtures/cassettes/BookingSync_API_Client_Bookings/_cancel_booking/cancels_given_booking_and_passes_options_along_as_bookings_payload.yml
248
249
  - spec/fixtures/cassettes/BookingSync_API_Client_Bookings/_create_booking/creates_a_booking.yml
249
250
  - spec/fixtures/cassettes/BookingSync_API_Client_Bookings/_edit_booking/updates_given_booking_by_ID.yml
251
+ - spec/fixtures/cassettes/BookingSync_API_Client_Bookings/_remove_bookings_fee/removes_bookings_fee_and_returns_with_booking.yml
250
252
  - spec/fixtures/cassettes/BookingSync_API_Client_BookingsFees/_bookings_fee/returns_a_single_bookings_fee.yml
251
253
  - spec/fixtures/cassettes/BookingSync_API_Client_BookingsFees/_bookings_fees/returns_bookings_fees.yml
252
254
  - spec/fixtures/cassettes/BookingSync_API_Client_BookingsPayments/_bookings_payment/returns_a_single_bookings_payment.yml
@@ -457,6 +459,7 @@ test_files:
457
459
  - spec/fixtures/cassettes/BookingSync_API_Client_BookingComments/_delete_booking_comment/deletes_given_booking_comment.yml
458
460
  - spec/fixtures/cassettes/BookingSync_API_Client_BookingComments/_edit_booking_comment/returns_updated_booking_comment.yml
459
461
  - spec/fixtures/cassettes/BookingSync_API_Client_BookingComments/_edit_booking_comment/updates_booking_comment.yml
462
+ - spec/fixtures/cassettes/BookingSync_API_Client_Bookings/_add_bookings_fee/adds_bookings_fee.yml
460
463
  - spec/fixtures/cassettes/BookingSync_API_Client_Bookings/_booking/returns_a_single_booking.yml
461
464
  - spec/fixtures/cassettes/BookingSync_API_Client_Bookings/_booking/returns_a_single_canceled_booking.yml
462
465
  - spec/fixtures/cassettes/BookingSync_API_Client_Bookings/_bookings/pagination/with_a_block/yields_block_with_batch_of_bookings.yml
@@ -466,6 +469,7 @@ test_files:
466
469
  - spec/fixtures/cassettes/BookingSync_API_Client_Bookings/_cancel_booking/cancels_given_booking_and_passes_options_along_as_bookings_payload.yml
467
470
  - spec/fixtures/cassettes/BookingSync_API_Client_Bookings/_create_booking/creates_a_booking.yml
468
471
  - spec/fixtures/cassettes/BookingSync_API_Client_Bookings/_edit_booking/updates_given_booking_by_ID.yml
472
+ - spec/fixtures/cassettes/BookingSync_API_Client_Bookings/_remove_bookings_fee/removes_bookings_fee_and_returns_with_booking.yml
469
473
  - spec/fixtures/cassettes/BookingSync_API_Client_BookingsFees/_bookings_fee/returns_a_single_bookings_fee.yml
470
474
  - spec/fixtures/cassettes/BookingSync_API_Client_BookingsFees/_bookings_fees/returns_bookings_fees.yml
471
475
  - spec/fixtures/cassettes/BookingSync_API_Client_BookingsPayments/_bookings_payment/returns_a_single_bookings_payment.yml