bookingsync-api 0.0.30 → 0.0.31

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: e684e01278017c058321923e665bf96ba3caa420
4
- data.tar.gz: 6a2121dd54961a277ae61b9bf5d7f23ef8519e58
3
+ metadata.gz: 29fe2938d76ac10f4caa4acd50999ef657b2dba6
4
+ data.tar.gz: cf7ccaec405c817390aee0848ccad6de6ff8ae4b
5
5
  SHA512:
6
- metadata.gz: cd3d7e0824cb828a2b384c7288e5f347d1208439703892aeffb3a60cc216570d17f6479fd1b702624ac1529ba51d57f48272a1f4581d5961aab4fd229b6d3a44
7
- data.tar.gz: decd8c0854ee18f3f5cd9e9cb3c1989712cd0ec95d5d43f5f38ef0fa0225e9c7c353bbc83faaf27dec6e73671527fe0f75367f1eebcda96d39622e881aeb54b8
6
+ metadata.gz: 39eed57dc0615325520f718c4e2b2fbd34d04997f51a6e148270e3f3dec0cb1f46375020807059fd4f0b6754ec4fd1721ce8b7a0292f9ccc941f7dcd672a6fb1
7
+ data.tar.gz: 9defc13f184204034eebcf7e0b0d4e005318e95840acb42f8aab9a85709e177de826f2ee9e2d8c07d1c80f52ffe2cbebc3e1b4c59ee430d896cec95a14efd366
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.0.31
4
+
5
+ - Add support for fees and rentals_fees creation.
6
+
3
7
  ## 0.0.30
4
8
 
5
9
  - Add missing CRUD actions to existing endpoints.
@@ -28,6 +28,14 @@ module BookingSync::API
28
28
  def fee(fee, options = {})
29
29
  get("fees/#{fee}", options).pop
30
30
  end
31
+
32
+ # Create a new fee
33
+ #
34
+ # @param options [Hash] Fee's attributes.
35
+ # @return [BookingSync::API::Resource] Newly created fee.
36
+ def create_fee(options = {})
37
+ post(:fees, fees: [options]).pop
38
+ end
31
39
  end
32
40
  end
33
41
  end
@@ -28,6 +28,16 @@ module BookingSync::API
28
28
  def rentals_fee(rentals_fee, options = {})
29
29
  get("rentals_fees/#{rentals_fee}", options).pop
30
30
  end
31
+
32
+ # Create a new rentals_fee
33
+ #
34
+ # @param rental [BookingSync::API::Resource|Integer] Rental or ID of
35
+ # the rental for which rentals_fee will be created.
36
+ # @param options [Hash] RentalsFee's attributes.
37
+ # @return [BookingSync::API::Resource] Newly created rentals_fee.
38
+ def create_rentals_fee(rental, options = {})
39
+ post("rentals/#{rental}/rentals_fees", rentals_fees: [options]).pop
40
+ end
31
41
  end
32
42
  end
33
43
  end
@@ -1,5 +1,5 @@
1
1
  module BookingSync
2
2
  module API
3
- VERSION = "0.0.30"
3
+ VERSION = "0.0.31"
4
4
  end
5
5
  end
@@ -16,4 +16,31 @@ describe BookingSync::API::Client::Fees do
16
16
  expect(fee.id).to eq 474
17
17
  end
18
18
  end
19
+
20
+ describe ".create_fee", :vcr do
21
+ let(:attributes) do
22
+ {
23
+ name_en: "New fee",
24
+ rate: 10,
25
+ rate_kind: "fixed",
26
+ downpayment_percentage: 10
27
+ }
28
+ end
29
+
30
+ it "creates a new fee" do
31
+ client.create_fee(attributes)
32
+ assert_requested :post, bs_url("fees"),
33
+ body: { fees: [attributes] }.to_json
34
+ end
35
+
36
+ it "returns newly created fee" do
37
+ VCR.use_cassette('BookingSync_API_Client_Fees/_create_fee/creates_a_new_fee') do
38
+ fee = client.create_fee(attributes)
39
+ expect(fee.name).to eq({ en: "New fee" })
40
+ expect(fee.rate).to eq "10.0"
41
+ expect(fee.rate_kind).to eq "fixed"
42
+ expect(fee.downpayment_percentage).to eq "10.0"
43
+ end
44
+ end
45
+ end
19
46
  end
@@ -16,4 +16,30 @@ describe BookingSync::API::Client::RentalsFees do
16
16
  expect(rentals_fee.id).to eq 3306
17
17
  end
18
18
  end
19
+
20
+ describe ".create_rentals_fee", :vcr do
21
+ let(:attributes) do
22
+ {
23
+ fee_id: 659,
24
+ maximum_bookable: 10,
25
+ always_applied: true
26
+ }
27
+ end
28
+ let(:rental) { BookingSync::API::Resource.new(client, id: 5116) }
29
+
30
+ it "creates a new rentals_fee" do
31
+ client.create_rentals_fee(rental, attributes)
32
+ assert_requested :post, bs_url("rentals/5116/rentals_fees"),
33
+ body: { rentals_fees: [attributes] }.to_json
34
+ end
35
+
36
+ it "returns newly created rentals_fee" do
37
+ VCR.use_cassette('BookingSync_API_Client_RentalsFees/_create_rentals_fee/creates_a_new_rentals_fee') do
38
+ rentals_fee = client.create_rentals_fee(rental, attributes)
39
+ expect(rentals_fee.links.fee).to eq 659
40
+ expect(rentals_fee.maximum_bookable).to eq 10
41
+ expect(rentals_fee.always_applied).to eq true
42
+ end
43
+ end
44
+ end
19
45
  end
@@ -0,0 +1,76 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://www.bookingsync.com/api/v3/fees
6
+ body:
7
+ encoding: UTF-8
8
+ string: '{"fees":[{"name_en":"New fee","rate":10,"rate_kind":"fixed","downpayment_percentage":10}]}'
9
+ headers:
10
+ User-Agent:
11
+ - BookingSync API gem v0.0.30
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
+ response:
21
+ status:
22
+ code: 201
23
+ message: Created
24
+ headers:
25
+ Server:
26
+ - nginx
27
+ Date:
28
+ - Tue, 17 Nov 2015 16:53:16 GMT
29
+ Content-Type:
30
+ - application/vnd.api+json; charset=utf-8
31
+ Transfer-Encoding:
32
+ - chunked
33
+ Connection:
34
+ - keep-alive
35
+ Status:
36
+ - 201 Created
37
+ Strict-Transport-Security:
38
+ - max-age=31536000
39
+ X-Frame-Options:
40
+ - SAMEORIGIN
41
+ X-Xss-Protection:
42
+ - 1; mode=block
43
+ X-Content-Type-Options:
44
+ - nosniff
45
+ X-Ratelimit-Limit:
46
+ - '1000'
47
+ X-Ratelimit-Reset:
48
+ - '1447779600'
49
+ X-Ratelimit-Remaining:
50
+ - '990'
51
+ Location:
52
+ - https://www.bookingsync.com/api/v3/fees/659
53
+ Etag:
54
+ - '"7973edf46d882d4f7336dba2d03eb135"'
55
+ Cache-Control:
56
+ - max-age=0, private, must-revalidate
57
+ P3p:
58
+ - CP="OTI DSP COR CUR ADMo DEVo TAI PSAi PSDi IVAi IVDi CONi HISi TELi OTPi
59
+ OUR SAMi OTRo UNRo PUBi IND UNI STA"
60
+ Set-Cookie:
61
+ - ahoy_track=true; path=/; secure
62
+ - ahoy_visit=4d235f6e-32ab-4a02-b267-0985996204e7; path=/; expires=Tue, 24 Nov
63
+ 2015 16:53:15 -0000; secure
64
+ - ahoy_visitor=33d62abe-186a-40aa-ab46-87b5d12e219c; path=/; expires=Fri, 17
65
+ Nov 2017 16:53:15 -0000; secure
66
+ X-Request-Id:
67
+ - 53e8f4b6-16dc-4a8e-9097-6ace3e12719a
68
+ X-Runtime:
69
+ - '0.320559'
70
+ body:
71
+ encoding: UTF-8
72
+ string: '{"links":{"fees.account":"https://www.bookingsync.com/api/v3/accounts/{fees.account}"},"fees":[{"links":{"account":3837},"id":659,"name":{"en":"New
73
+ fee"},"rate":"10.0","rate_kind":"fixed","created_at":"2015-11-17T16:53:15Z","updated_at":"2015-11-17T16:53:15Z","downpayment_percentage":"10.0","kind":"other"}]}'
74
+ http_version:
75
+ recorded_at: Tue, 17 Nov 2015 16:53:17 GMT
76
+ recorded_with: VCR 2.9.2
@@ -0,0 +1,76 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://www.bookingsync.com/api/v3/rentals/5116/rentals_fees
6
+ body:
7
+ encoding: UTF-8
8
+ string: '{"rentals_fees":[{"fee_id":659,"maximum_bookable":10,"always_applied":true}]}'
9
+ headers:
10
+ User-Agent:
11
+ - BookingSync API gem v0.0.30
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
+ response:
21
+ status:
22
+ code: 201
23
+ message: Created
24
+ headers:
25
+ Server:
26
+ - nginx
27
+ Date:
28
+ - Tue, 17 Nov 2015 17:02:44 GMT
29
+ Content-Type:
30
+ - application/vnd.api+json; charset=utf-8
31
+ Transfer-Encoding:
32
+ - chunked
33
+ Connection:
34
+ - keep-alive
35
+ Status:
36
+ - 201 Created
37
+ Strict-Transport-Security:
38
+ - max-age=31536000
39
+ X-Frame-Options:
40
+ - SAMEORIGIN
41
+ X-Xss-Protection:
42
+ - 1; mode=block
43
+ X-Content-Type-Options:
44
+ - nosniff
45
+ X-Ratelimit-Limit:
46
+ - '1000'
47
+ X-Ratelimit-Reset:
48
+ - '1447783200'
49
+ X-Ratelimit-Remaining:
50
+ - '999'
51
+ Location:
52
+ - https://www.bookingsync.com/api/v3/rentals_fees/4060
53
+ Etag:
54
+ - '"60a033367353e5fa9e12a2a3d2d8e2d6"'
55
+ Cache-Control:
56
+ - max-age=0, private, must-revalidate
57
+ P3p:
58
+ - CP="OTI DSP COR CUR ADMo DEVo TAI PSAi PSDi IVAi IVDi CONi HISi TELi OTPi
59
+ OUR SAMi OTRo UNRo PUBi IND UNI STA"
60
+ Set-Cookie:
61
+ - ahoy_track=true; path=/; secure
62
+ - ahoy_visit=c0f9c5f9-dfa0-4fb3-9625-d40ce6f6572a; path=/; expires=Tue, 24 Nov
63
+ 2015 17:02:44 -0000; secure
64
+ - ahoy_visitor=6348c1c0-e2b7-4b99-942d-d599d3fc808a; path=/; expires=Fri, 17
65
+ Nov 2017 17:02:44 -0000; secure
66
+ X-Request-Id:
67
+ - bb07b81c-5b52-4589-891a-66b2789471c0
68
+ X-Runtime:
69
+ - '0.117708'
70
+ body:
71
+ encoding: UTF-8
72
+ string: '{"links":{"rentals_fees.fee":"https://www.bookingsync.com/api/v3/fees/{rentals_fees.fee}","rentals_fees.rental":"https://www.bookingsync.com/api/v3/rentals/{rentals_fees.rental}","rentals_fees.seasons":"https://www.bookingsync.com/api/v3/seasons/{rentals_fees.seasons}"},"rentals_fees":[{"links":{"fee":659,"rental":5116,"seasons":[]},"id":4060,"always_applied":true,"end_date":null,"maximum_bookable":10,"public":false,"required":false,"start_date":null,"created_at":"2015-11-17T17:02:44Z","updated_at":"2015-11-17T17:02:44Z","name":{"en":"New
73
+ fee"},"rate":"10.0","rate_kind":"fixed","archived_at":null}]}'
74
+ http_version:
75
+ recorded_at: Tue, 17 Nov 2015 17:02:45 GMT
76
+ recorded_with: VCR 2.9.2
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.0.30
4
+ version: 0.0.31
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: 2015-11-16 00:00:00.000000000 Z
11
+ date: 2015-11-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -208,6 +208,7 @@ files:
208
208
  - spec/fixtures/cassettes/BookingSync_API_Client_Clients/_edit_client/updates_given_client_by_ID.yml
209
209
  - spec/fixtures/cassettes/BookingSync_API_Client_Destinations/_destination/returns_a_single_destination.yml
210
210
  - spec/fixtures/cassettes/BookingSync_API_Client_Destinations/_destinations/returns_destinations.yml
211
+ - spec/fixtures/cassettes/BookingSync_API_Client_Fees/_create_fee/creates_a_new_fee.yml
211
212
  - spec/fixtures/cassettes/BookingSync_API_Client_Fees/_fee/returns_a_single_fee.yml
212
213
  - spec/fixtures/cassettes/BookingSync_API_Client_Fees/_fees/returns_fees.yml
213
214
  - spec/fixtures/cassettes/BookingSync_API_Client_Inquiries/_create_inquiry/creates_a_new_inquiry.yml
@@ -269,6 +270,7 @@ files:
269
270
  - spec/fixtures/cassettes/BookingSync_API_Client_RentalsAmenities/_rentals_amenities/links/returns_associated_rental.yml
270
271
  - spec/fixtures/cassettes/BookingSync_API_Client_RentalsAmenities/_rentals_amenities/returns_rentals_amenities.yml
271
272
  - spec/fixtures/cassettes/BookingSync_API_Client_RentalsAmenities/_rentals_amenity/returns_rentals_amenity.yml
273
+ - spec/fixtures/cassettes/BookingSync_API_Client_RentalsFees/_create_rentals_fee/creates_a_new_rentals_fee.yml
272
274
  - spec/fixtures/cassettes/BookingSync_API_Client_RentalsFees/_rentals_fee/returns_a_single_rentals_fee.yml
273
275
  - spec/fixtures/cassettes/BookingSync_API_Client_RentalsFees/_rentals_fees/returns_rentals_fees.yml
274
276
  - spec/fixtures/cassettes/BookingSync_API_Client_Reviews/_create_review/creates_a_new_review.yml
@@ -390,6 +392,7 @@ test_files:
390
392
  - spec/fixtures/cassettes/BookingSync_API_Client_Clients/_edit_client/updates_given_client_by_ID.yml
391
393
  - spec/fixtures/cassettes/BookingSync_API_Client_Destinations/_destination/returns_a_single_destination.yml
392
394
  - spec/fixtures/cassettes/BookingSync_API_Client_Destinations/_destinations/returns_destinations.yml
395
+ - spec/fixtures/cassettes/BookingSync_API_Client_Fees/_create_fee/creates_a_new_fee.yml
393
396
  - spec/fixtures/cassettes/BookingSync_API_Client_Fees/_fee/returns_a_single_fee.yml
394
397
  - spec/fixtures/cassettes/BookingSync_API_Client_Fees/_fees/returns_fees.yml
395
398
  - spec/fixtures/cassettes/BookingSync_API_Client_Inquiries/_create_inquiry/creates_a_new_inquiry.yml
@@ -451,6 +454,7 @@ test_files:
451
454
  - spec/fixtures/cassettes/BookingSync_API_Client_RentalsAmenities/_rentals_amenities/links/returns_associated_rental.yml
452
455
  - spec/fixtures/cassettes/BookingSync_API_Client_RentalsAmenities/_rentals_amenities/returns_rentals_amenities.yml
453
456
  - spec/fixtures/cassettes/BookingSync_API_Client_RentalsAmenities/_rentals_amenity/returns_rentals_amenity.yml
457
+ - spec/fixtures/cassettes/BookingSync_API_Client_RentalsFees/_create_rentals_fee/creates_a_new_rentals_fee.yml
454
458
  - spec/fixtures/cassettes/BookingSync_API_Client_RentalsFees/_rentals_fee/returns_a_single_rentals_fee.yml
455
459
  - spec/fixtures/cassettes/BookingSync_API_Client_RentalsFees/_rentals_fees/returns_rentals_fees.yml
456
460
  - spec/fixtures/cassettes/BookingSync_API_Client_Reviews/_create_review/creates_a_new_review.yml