bookingsync-api 0.1.11 → 0.2.0
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 +5 -5
- data/.gitignore +1 -0
- data/.travis.yml +3 -1
- data/CHANGELOG.md +12 -0
- data/bookingsync-api.gemspec +3 -3
- data/lib/bookingsync/api/client/applications.rb +43 -0
- data/lib/bookingsync/api/client/applications_periods_rentals.rb +49 -0
- data/lib/bookingsync/api/client/booking_comments.rb +1 -1
- data/lib/bookingsync/api/client/contacts.rb +63 -0
- data/lib/bookingsync/api/client/rental_urls.rb +72 -0
- data/lib/bookingsync/api/client/rentals.rb +3 -2
- data/lib/bookingsync/api/client.rb +12 -2
- data/lib/bookingsync/api/version.rb +1 -1
- data/spec/bookingsync/api/client/applications_periods_rentals_spec.rb +70 -0
- data/spec/bookingsync/api/client/applications_spec.rb +44 -0
- data/spec/bookingsync/api/client/contacts_spec.rb +116 -0
- data/spec/bookingsync/api/client/rental_urls_spec.rb +83 -0
- data/spec/fixtures/cassettes/BookingSync_API_Client_Applications/_application/returns_a_single_application.yml +84 -0
- data/spec/fixtures/cassettes/BookingSync_API_Client_Applications/_applications/returns_applications.yml +85 -0
- data/spec/fixtures/cassettes/BookingSync_API_Client_Applications/_edit_application/returns_updated_application.yml +73 -0
- data/spec/fixtures/cassettes/BookingSync_API_Client_Applications/_edit_application/updates_given_application_by_ID.yml +73 -0
- data/spec/fixtures/cassettes/BookingSync_API_Client_ApplicationsPeriodsRentals/_applications_periods_rental/returns_applications_periods_rental.yml +80 -0
- data/spec/fixtures/cassettes/BookingSync_API_Client_ApplicationsPeriodsRentals/_applications_periods_rentals/returns_applications_periods_rentals.yml +80 -0
- data/spec/fixtures/cassettes/BookingSync_API_Client_ApplicationsPeriodsRentals/_create_applications_periods_rental/creates_a_applications_periods_rental.yml +71 -0
- data/spec/fixtures/cassettes/BookingSync_API_Client_ApplicationsPeriodsRentals/_edit_applications_periods_rental/returns_updated_applications_periods_rental.yml +69 -0
- data/spec/fixtures/cassettes/BookingSync_API_Client_ApplicationsPeriodsRentals/_edit_applications_periods_rental/updates_given_applications_periods_rental_by_ID.yml +69 -0
- data/spec/fixtures/cassettes/BookingSync_API_Client_Bookings/_create_applications_periods_rental/creates_an_applications_periods_rental.yml +71 -0
- data/spec/fixtures/cassettes/BookingSync_API_Client_Contacts/_contact/returns_a_single_contact.yml +99 -0
- data/spec/fixtures/cassettes/BookingSync_API_Client_Contacts/_contact/returns_contact.yml +99 -0
- data/spec/fixtures/cassettes/BookingSync_API_Client_Contacts/_contacts/returns_contacts.yml +99 -0
- data/spec/fixtures/cassettes/BookingSync_API_Client_Contacts/_contacts/returns_contacts_by_ids.yml +99 -0
- data/spec/fixtures/cassettes/BookingSync_API_Client_Contacts/_create_contact/creates_a_new_contact.yml +74 -0
- data/spec/fixtures/cassettes/BookingSync_API_Client_Contacts/_delete_contact/deletes_given_contact.yml +63 -0
- data/spec/fixtures/cassettes/BookingSync_API_Client_Contacts/_edit_contact/updates_given_contact_by_ID.yml +71 -0
- data/spec/fixtures/cassettes/BookingSync_API_Client_RentalUrls/_cancel_rental_url/cancels_given_rental_url.yml +63 -0
- data/spec/fixtures/cassettes/BookingSync_API_Client_RentalUrls/_create_rental_url/creates_a_new_rental_url.yml +71 -0
- data/spec/fixtures/cassettes/BookingSync_API_Client_RentalUrls/_edit_rental_url/updates_given_rental_url_by_ID.yml +69 -0
- data/spec/fixtures/cassettes/BookingSync_API_Client_RentalUrls/_rental_url/returns_rental_url.yml +81 -0
- data/spec/fixtures/cassettes/BookingSync_API_Client_RentalUrls/_rental_urls/links/returns_associated_rental.yml +166 -0
- data/spec/fixtures/cassettes/BookingSync_API_Client_RentalUrls/_rental_urls/returns_rental_urls.yml +80 -0
- data/spec/fixtures/cassettes/BookingSync_API_Client_RentalsAmenities/_create_rental_url/creates_a_new_rental_url.yml +71 -0
- data/spec/fixtures/cassettes/BookingSync_API_Client_RentalsAmenities/_edit_rental_url/updates_given_rentals_url.yml +69 -0
- data/spec/fixtures/cassettes/BookingSync_API_Client_RentalsAmenities/_edit_rental_url/updates_given_rentals_url_by_ID.yml +69 -0
- metadata +88 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 97439dc793ee31707c3bf1e4f99eff2af5cb365ad02e68db12d313c98c9272da
|
4
|
+
data.tar.gz: c1119cf2b6665d5ba31b44ae2285d2d71303df40d0659f8eab3877fd07df6bcf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 48d1876b9c1f5fadf469415015f4cd869c727a0ffade3901d4aa3fcf858aafefa0173c62dee4e3ef72fa3db33fb092d180f3192e1442958d6142c0e84e48e3e4
|
7
|
+
data.tar.gz: 72d793dc6bf7b4bd85ca5b773a9e03025f020cbc1cc23c694fbb5cb7a788df1dd7f09e5b51d6ac59b5231d58026e72ebfb14e52b3cb390c9ebdd05a191a5d5ed
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
@@ -2,8 +2,10 @@ language: ruby
|
|
2
2
|
rvm:
|
3
3
|
- "2.1"
|
4
4
|
- "2.2"
|
5
|
+
- "2.4.4"
|
6
|
+
- "2.5.1"
|
5
7
|
before_install:
|
6
8
|
- gem install bundler -v 1.12.5
|
7
9
|
script:
|
8
|
-
- bundle exec rake style:rubocop:without_auto_correct
|
10
|
+
- bundle exec rake style:rubocop:without_auto_correct
|
9
11
|
- bundle exec rake spec
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,18 @@
|
|
2
2
|
|
3
3
|
# master
|
4
4
|
|
5
|
+
## 0.2.0 - 2022-01-10
|
6
|
+
- upgrade net-http-persistent to be ruby 3 ready
|
7
|
+
|
8
|
+
## 0.1.14 - 2019-10-15
|
9
|
+
- Add supports for `rental_urls` endpoint.
|
10
|
+
|
11
|
+
## 0.1.13 - 2019-10-08
|
12
|
+
- Add supports for `contacts` endpoint.
|
13
|
+
|
14
|
+
## 0.1.12 - 2018-05-25
|
15
|
+
- updated Faraday and Net HTTP Persistent gem to remove workaround
|
16
|
+
|
5
17
|
## 0.1.11 - 2018-05-18
|
6
18
|
- Added `add_attachment_to_message`.
|
7
19
|
|
data/bookingsync-api.gemspec
CHANGED
@@ -18,11 +18,11 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
|
-
spec.add_dependency "faraday", "
|
22
|
-
spec.add_dependency "net-http-persistent", "
|
21
|
+
spec.add_dependency "faraday", ">= 0.15.2"
|
22
|
+
spec.add_dependency "net-http-persistent", [">= 4.0.1", "< 5.0"]
|
23
23
|
spec.add_dependency "hashie"
|
24
24
|
spec.add_dependency "addressable"
|
25
|
-
spec.add_development_dependency "bundler"
|
25
|
+
spec.add_development_dependency "bundler"
|
26
26
|
spec.add_development_dependency "rake"
|
27
27
|
spec.add_development_dependency "bookingsync-stylecheck"
|
28
28
|
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
module BookingSync::API
|
2
|
+
class Client
|
3
|
+
module Applications
|
4
|
+
# List applications
|
5
|
+
#
|
6
|
+
# Returns all applications supported in BookingSync.
|
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 applications.
|
10
|
+
#
|
11
|
+
# @example Get the list of applications for the current account
|
12
|
+
# applications = @api.applications
|
13
|
+
# applications.first.title # => "Internet"
|
14
|
+
# @see http://developers.bookingsync.com/reference/endpoints/applications/#list-applications
|
15
|
+
def applications(options = {}, &block)
|
16
|
+
paginate :applications, options, &block
|
17
|
+
end
|
18
|
+
|
19
|
+
# Get a single application
|
20
|
+
#
|
21
|
+
# @param application [BookingSync::API::Resource|Integer] application or ID
|
22
|
+
# of the application.
|
23
|
+
# @return [BookingSync::API::Resource]
|
24
|
+
# @see http://developers.bookingsync.com/reference/endpoints/applications/#get-a-single-application
|
25
|
+
def application(application)
|
26
|
+
get("applications/#{application}").pop
|
27
|
+
end
|
28
|
+
|
29
|
+
# Edit an application
|
30
|
+
#
|
31
|
+
# @param application [BookingSync::API::Resource|Integer] application or ID of the application
|
32
|
+
# to be updated
|
33
|
+
# @param options [Hash] application attributes to be updated
|
34
|
+
# @return [BookingSync::API::Resource] Updated application on success, exception is raised otherwise
|
35
|
+
# @example
|
36
|
+
# application = @api.applications.first
|
37
|
+
# @api.edit_application(application, { default_price_increase: 3 })
|
38
|
+
def edit_application(application, options = {})
|
39
|
+
put("applications/#{application}", applications: [options]).pop
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
module BookingSync::API
|
2
|
+
class Client
|
3
|
+
module ApplicationsPeriodsRentals
|
4
|
+
# List applications_periods_rentals
|
5
|
+
#
|
6
|
+
# Returns all applications_periods_rentals supported in BookingSync.
|
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 applications_periods_rentals.
|
10
|
+
#
|
11
|
+
# @example Get the list of applications_periods_rentals for the current account
|
12
|
+
# applications_periods_rentals = @api.applications_periods_rentals
|
13
|
+
# applications_periods_rentals.first.title # => "Internet"
|
14
|
+
def applications_periods_rentals(options = {}, &block)
|
15
|
+
paginate :applications_periods_rentals, options, &block
|
16
|
+
end
|
17
|
+
|
18
|
+
# Create a applications_periods_rental
|
19
|
+
#
|
20
|
+
# @param options [Hash] applications_periods_rental attributes.
|
21
|
+
# @return [BookingSync::API::Resource] Newly created applications_periods_rental.
|
22
|
+
def create_applications_periods_rental(options = {})
|
23
|
+
post("applications_periods_rentals", applications_periods_rental: options).pop
|
24
|
+
end
|
25
|
+
|
26
|
+
# Get a single applications_periods_rental
|
27
|
+
#
|
28
|
+
# @param applications_periods_rental [BookingSync::API::Resource|Integer] applications_periods_rental or ID
|
29
|
+
# of the applications_periods_rental.
|
30
|
+
# @return [BookingSync::API::Resource]
|
31
|
+
def applications_periods_rental(applications_periods_rental)
|
32
|
+
get("applications_periods_rentals/#{applications_periods_rental}").pop
|
33
|
+
end
|
34
|
+
|
35
|
+
# Edit an applications_periods_rental
|
36
|
+
#
|
37
|
+
# @param applications_periods_rental [BookingSync::API::Resource|Integer] applications_periods_rental or ID of the applications_periods_rental
|
38
|
+
# to be updated
|
39
|
+
# @param options [Hash] applications_periods_rental attributes to be updated
|
40
|
+
# @return [BookingSync::API::Resource] Updated applications_periods_rental on success, exception is raised otherwise
|
41
|
+
# @example
|
42
|
+
# applications_periods_rental = @api.applications_periods_rentals.first
|
43
|
+
# @api.edit_application(applications_periods_rental, { default_price_increase: 3 })
|
44
|
+
def edit_applications_periods_rental(applications_periods_rental, options = {})
|
45
|
+
put("applications_periods_rentals/#{applications_periods_rental}", applications_periods_rental: options).pop
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -53,7 +53,7 @@ module BookingSync::API
|
|
53
53
|
# exception is raised otherwise.
|
54
54
|
# @example
|
55
55
|
# booking_comment = @api.booking_comments.first
|
56
|
-
# @api.edit_booking_comment(8, {
|
56
|
+
# @api.edit_booking_comment(8, {content: "New content"})
|
57
57
|
# => {:links=>{:booking=>1}, :id=>8, :content=>"New content", :editable=>true, :created_at=>2016-04-18 13:31:40 UTC, :updated_at=>2016-04-18 13:46:06 UTC}
|
58
58
|
def edit_booking_comment(booking_comment, options = {})
|
59
59
|
put("booking_comments/#{booking_comment}", booking_comments: [options]).pop
|
@@ -0,0 +1,63 @@
|
|
1
|
+
module BookingSync::API
|
2
|
+
class Client
|
3
|
+
module Contacts
|
4
|
+
# List contacts
|
5
|
+
#
|
6
|
+
# Returns contacts 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 contacts.
|
10
|
+
#
|
11
|
+
# @example Get the list of contacts for the current account
|
12
|
+
# contacts = @api.contacts
|
13
|
+
# contacts.first.fullname # => "John Smith"
|
14
|
+
# @example Get the list of contacts only with fullname and phone for smaller response
|
15
|
+
# @api.contacts(fields: [:fullname, :phone])
|
16
|
+
# @see http://developers.bookingsync.com/reference/endpoints/contacts/#list-contacts
|
17
|
+
def contacts(options = {}, &block)
|
18
|
+
paginate :contacts, options, &block
|
19
|
+
end
|
20
|
+
|
21
|
+
# Get a single contact
|
22
|
+
#
|
23
|
+
# @param contact [BookingSync::API::Resource|Integer] Contact or ID
|
24
|
+
# of the contact.
|
25
|
+
# @param options [Hash] A customizable set of query options.
|
26
|
+
# @option options [Array] fields: List of fields to be fetched.
|
27
|
+
# @return [BookingSync::API::Resource]
|
28
|
+
def contact(contact, options = {})
|
29
|
+
get("contacts/#{contact}", options).pop
|
30
|
+
end
|
31
|
+
|
32
|
+
# Create a new contact
|
33
|
+
#
|
34
|
+
# @param options [Hash] Contact attributes
|
35
|
+
# @return [BookingSync::API::Resource] Newly created contact
|
36
|
+
def create_contact(options = {})
|
37
|
+
post(:contacts, contacts: [options]).pop
|
38
|
+
end
|
39
|
+
|
40
|
+
# Edit a contact
|
41
|
+
#
|
42
|
+
# @param contact [BookingSync::API::Resource|Integer] Contact or ID of the contact
|
43
|
+
# to be updated
|
44
|
+
# @param options [Hash] Contact attributes to be updated
|
45
|
+
# @return [BookingSync::API::Resource] Updated contact on success, exception is raised otherwise
|
46
|
+
# @example
|
47
|
+
# contact = @api.contacts.first
|
48
|
+
# @api.edit_contact(contact, { fullname: "Gary Smith" })
|
49
|
+
def edit_contact(contact, options = {})
|
50
|
+
put("contacts/#{contact}", contacts: [options]).pop
|
51
|
+
end
|
52
|
+
|
53
|
+
# Delete a contact
|
54
|
+
#
|
55
|
+
# @param contact [BookingSync::API::Resource|Integer] Contact or ID
|
56
|
+
# of the contact to be deleted.
|
57
|
+
# @return [NilClass] Returns nil on success.
|
58
|
+
def delete_contact(contact)
|
59
|
+
delete "contacts/#{contact}"
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,72 @@
|
|
1
|
+
module BookingSync::API
|
2
|
+
class Client
|
3
|
+
module RentalUrls
|
4
|
+
# List rental_urls
|
5
|
+
#
|
6
|
+
# Returns rental_urls 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 rental_urls.
|
10
|
+
#
|
11
|
+
# @example Get the list of rental_urls for the current account
|
12
|
+
# rental_urls = @api.rental_urls
|
13
|
+
# rental_urls.first.label # => "HomeAway"
|
14
|
+
# @see http://developers.bookingsync.com/reference/endpoints/rental_urls/#list-rental_urls
|
15
|
+
def rental_urls(options = {}, &block)
|
16
|
+
paginate :rental_urls, options, &block
|
17
|
+
end
|
18
|
+
|
19
|
+
# Get a single rental_url
|
20
|
+
#
|
21
|
+
# @param rental_url [BookingSync::API::Resource|Integer] RentalUrl or ID
|
22
|
+
# of the rental_url.
|
23
|
+
# @return [BookingSync::API::Resource]
|
24
|
+
def rental_url(rental_url)
|
25
|
+
get("rental_urls/#{rental_url}").pop
|
26
|
+
end
|
27
|
+
|
28
|
+
# Create a new rental_url
|
29
|
+
#
|
30
|
+
# @param options [Hash] RentalUrl's attributes.
|
31
|
+
# @return [BookingSync::API::Resource] Newly created rental_url.
|
32
|
+
def create_rental_url(rental, options = {})
|
33
|
+
if file_path = options.delete(:file_path)
|
34
|
+
options[:file] ||= base_64_encode(file_path)
|
35
|
+
end
|
36
|
+
post("rentals/#{rental}/rental_urls", rental_urls: options).pop
|
37
|
+
end
|
38
|
+
|
39
|
+
# Edit a rental_url
|
40
|
+
#
|
41
|
+
# @param rental_url [BookingSync::API::Resource|Integer] RentalUrl or ID of
|
42
|
+
# the rental_url to be updated.
|
43
|
+
# @param options [Hash] RentalUrl attributes to be updated.
|
44
|
+
# @return [BookingSync::API::Resource] Updated rental_url on success,
|
45
|
+
# exception is raised otherwise.
|
46
|
+
# @example
|
47
|
+
# rental_url = @api.rental_urls.first
|
48
|
+
# @api.edit_rental_url(rental_url, { label: "Airbnb" })
|
49
|
+
def edit_rental_url(rental_url, options = {})
|
50
|
+
if file_path = options.delete(:file_path)
|
51
|
+
options[:file] ||= base_64_encode(file_path)
|
52
|
+
end
|
53
|
+
put("rental_urls/#{rental_url}", rental_urls: options).pop
|
54
|
+
end
|
55
|
+
|
56
|
+
# Cancel a RentalUrl
|
57
|
+
#
|
58
|
+
# @param rental_url [BookingSync::API::Resource|Integer] RentalUrl or ID
|
59
|
+
# of the rental_url to be canceled.
|
60
|
+
# @return [NilClass] Returns nil on success.
|
61
|
+
def cancel_rental_url(rental_url)
|
62
|
+
delete "rental_urls/#{rental_url}"
|
63
|
+
end
|
64
|
+
|
65
|
+
private
|
66
|
+
|
67
|
+
def base_64_encode(file_path)
|
68
|
+
Base64.encode64(File.read(file_path))
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
@@ -30,7 +30,7 @@ module BookingSync::API
|
|
30
30
|
# villas = @api.rentals_search(rental_type: "villa")
|
31
31
|
def rentals_search(options = {}, &block)
|
32
32
|
ids = Array(options.delete(:ids))
|
33
|
-
path = ["rentals", ids.join(","), "search"].
|
33
|
+
path = reject_blank_values(["rentals", ids.join(","), "search"]).join("/")
|
34
34
|
defaults = { request_method: :post }
|
35
35
|
paginate path, defaults.merge(options), &block
|
36
36
|
end
|
@@ -79,7 +79,8 @@ module BookingSync::API
|
|
79
79
|
# @param rentals [Array] IDs of Rentals, leave empty for all account's rentals
|
80
80
|
# @return [BookingSync::API::Resource]
|
81
81
|
def rentals_meta(rentals = nil)
|
82
|
-
|
82
|
+
path = reject_blank_values(["rentals", Array(rentals).join(","), "meta"]).join("/")
|
83
|
+
get(path).pop
|
83
84
|
end
|
84
85
|
end
|
85
86
|
end
|
@@ -1,6 +1,8 @@
|
|
1
1
|
require "bookingsync/api/middleware/logger"
|
2
2
|
require "bookingsync/api/client/accounts"
|
3
3
|
require "bookingsync/api/client/amenities"
|
4
|
+
require "bookingsync/api/client/applications"
|
5
|
+
require "bookingsync/api/client/applications_periods_rentals"
|
4
6
|
require "bookingsync/api/client/attachments"
|
5
7
|
require "bookingsync/api/client/availabilities"
|
6
8
|
require "bookingsync/api/client/bathrooms"
|
@@ -13,6 +15,7 @@ require "bookingsync/api/client/bookings_tags"
|
|
13
15
|
require "bookingsync/api/client/bookings_taxes"
|
14
16
|
require "bookingsync/api/client/change_overs"
|
15
17
|
require "bookingsync/api/client/clients"
|
18
|
+
require "bookingsync/api/client/contacts"
|
16
19
|
require "bookingsync/api/client/destinations"
|
17
20
|
require "bookingsync/api/client/fees"
|
18
21
|
require "bookingsync/api/client/hosts"
|
@@ -35,6 +38,7 @@ require "bookingsync/api/client/rental_agreements"
|
|
35
38
|
require "bookingsync/api/client/rental_cancelation_policies"
|
36
39
|
require "bookingsync/api/client/rental_cancelation_policy_items"
|
37
40
|
require "bookingsync/api/client/rentals_contents_overrides"
|
41
|
+
require "bookingsync/api/client/rental_urls"
|
38
42
|
require "bookingsync/api/client/reviews"
|
39
43
|
require "bookingsync/api/client/seasons"
|
40
44
|
require "bookingsync/api/client/special_offers"
|
@@ -50,13 +54,14 @@ require "bookingsync/api/resource"
|
|
50
54
|
require "bookingsync/api/serializer"
|
51
55
|
require "logger"
|
52
56
|
require "addressable/template"
|
53
|
-
require "net/http/persistent"
|
54
57
|
|
55
58
|
module BookingSync::API
|
56
59
|
class Client
|
57
60
|
extend Forwardable
|
58
61
|
include BookingSync::API::Client::Accounts
|
59
62
|
include BookingSync::API::Client::Amenities
|
63
|
+
include BookingSync::API::Client::Applications
|
64
|
+
include BookingSync::API::Client::ApplicationsPeriodsRentals
|
60
65
|
include BookingSync::API::Client::Attachments
|
61
66
|
include BookingSync::API::Client::Availabilities
|
62
67
|
include BookingSync::API::Client::Bathrooms
|
@@ -70,6 +75,7 @@ module BookingSync::API
|
|
70
75
|
include BookingSync::API::Client::ChangeOvers
|
71
76
|
include BookingSync::API::Client::Conversations
|
72
77
|
include BookingSync::API::Client::Clients
|
78
|
+
include BookingSync::API::Client::Contacts
|
73
79
|
include BookingSync::API::Client::Destinations
|
74
80
|
include BookingSync::API::Client::Fees
|
75
81
|
include BookingSync::API::Client::Hosts
|
@@ -94,6 +100,7 @@ module BookingSync::API
|
|
94
100
|
include BookingSync::API::Client::RentalCancelationPolicies
|
95
101
|
include BookingSync::API::Client::RentalCancelationPolicyItems
|
96
102
|
include BookingSync::API::Client::RentalsContentsOverrides
|
103
|
+
include BookingSync::API::Client::RentalUrls
|
97
104
|
include BookingSync::API::Client::Reviews
|
98
105
|
include BookingSync::API::Client::Seasons
|
99
106
|
include BookingSync::API::Client::SpecialOffers
|
@@ -301,7 +308,6 @@ module BookingSync::API
|
|
301
308
|
|
302
309
|
def middleware
|
303
310
|
Faraday::RackBuilder.new do |builder|
|
304
|
-
builder.use ::Faraday::Request::Retry, max: 1, exceptions: [::Net::HTTP::Persistent::Error]
|
305
311
|
builder.use :logger, logger
|
306
312
|
builder.adapter :net_http_persistent
|
307
313
|
end
|
@@ -417,5 +423,9 @@ module BookingSync::API
|
|
417
423
|
def next_page(response, request_settings)
|
418
424
|
response.relations[:next].call({}, { method: request_settings[:request_method] })
|
419
425
|
end
|
426
|
+
|
427
|
+
def reject_blank_values(array)
|
428
|
+
array.reject { |value| value.nil? || value == "" }
|
429
|
+
end
|
420
430
|
end
|
421
431
|
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe BookingSync::API::Client::ApplicationsPeriodsRentals do
|
4
|
+
let(:client) { BookingSync::API::Client.new(test_access_token) }
|
5
|
+
|
6
|
+
before { |ex| @casette_base_path = casette_path(casette_dir, ex.metadata) }
|
7
|
+
|
8
|
+
describe ".applications_periods_rentals", :vcr do
|
9
|
+
it "returns applications_periods_rentals" do
|
10
|
+
expect(client.applications_periods_rentals).not_to be_empty
|
11
|
+
assert_requested :get, bs_url("applications_periods_rentals")
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
describe ".applications_periods_rental", :vcr do
|
16
|
+
let(:prefetched_applications_periods_rental) {
|
17
|
+
find_resource("#{@casette_base_path}_applications_periods_rentals/returns_applications_periods_rentals.yml", "applications_periods_rentals")
|
18
|
+
}
|
19
|
+
|
20
|
+
it "returns applications_periods_rental" do
|
21
|
+
applications_periods_rental = client.applications_periods_rental(prefetched_applications_periods_rental[:id])
|
22
|
+
expect(applications_periods_rental.price_increase).to eq(prefetched_applications_periods_rental[:price_increase])
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
describe ".create_applications_periods_rental", :vcr do
|
27
|
+
let(:attributes) {
|
28
|
+
{
|
29
|
+
rental_id: 1,
|
30
|
+
application_id: 9,
|
31
|
+
start_date: "2017-01-03",
|
32
|
+
end_date: "2017-01-04",
|
33
|
+
price_increase: 15.0
|
34
|
+
}
|
35
|
+
}
|
36
|
+
|
37
|
+
it "creates a applications_periods_rental" do
|
38
|
+
client.create_applications_periods_rental(attributes)
|
39
|
+
assert_requested :post, bs_url("applications_periods_rentals"),
|
40
|
+
body: { applications_periods_rental: attributes }.to_json
|
41
|
+
end
|
42
|
+
|
43
|
+
it "returns newly created applications_periods_rental" do
|
44
|
+
VCR.use_cassette("BookingSync_API_Client_Bookings/_create_applications_periods_rental/creates_an_applications_periods_rental") do
|
45
|
+
applications_periods_rental = client.create_applications_periods_rental(attributes)
|
46
|
+
expect(applications_periods_rental).to be_kind_of(BookingSync::API::Resource)
|
47
|
+
expect(applications_periods_rental.price_increase).to eq(attributes[:price_increase].to_s)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
describe ".edit_applications_periods_rental", :vcr do
|
53
|
+
let(:prefetched_edit_applications_periods_rental) {
|
54
|
+
find_resource("#{@casette_base_path}_applications_periods_rentals/returns_applications_periods_rentals.yml", "applications_periods_rentals")
|
55
|
+
}
|
56
|
+
let(:price_increase) { 3.1 }
|
57
|
+
|
58
|
+
it "updates given applications_periods_rental by ID" do
|
59
|
+
client.edit_applications_periods_rental(prefetched_edit_applications_periods_rental, price_increase: price_increase)
|
60
|
+
assert_requested :put, bs_url("applications_periods_rentals/#{prefetched_edit_applications_periods_rental}"),
|
61
|
+
body: { applications_periods_rental: { price_increase: price_increase } }.to_json
|
62
|
+
end
|
63
|
+
|
64
|
+
it "returns updated applications_periods_rental" do
|
65
|
+
applications_periods_rental = client.edit_applications_periods_rental(prefetched_edit_applications_periods_rental, price_increase: price_increase)
|
66
|
+
expect(applications_periods_rental).to be_kind_of(BookingSync::API::Resource)
|
67
|
+
expect(applications_periods_rental.price_increase).to eq(price_increase.to_s)
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe BookingSync::API::Client::Applications do
|
4
|
+
let(:client) { BookingSync::API::Client.new(test_access_token) }
|
5
|
+
|
6
|
+
before { |ex| @casette_base_path = casette_path(casette_dir, ex.metadata) }
|
7
|
+
|
8
|
+
describe ".applications", :vcr do
|
9
|
+
it "returns applications" do
|
10
|
+
expect(client.applications).not_to be_empty
|
11
|
+
assert_requested :get, bs_url("applications")
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
describe ".application", :vcr do
|
16
|
+
let(:prefetched_application_id) {
|
17
|
+
find_resource("#{@casette_base_path}_applications/returns_applications.yml", "applications")[:id]
|
18
|
+
}
|
19
|
+
|
20
|
+
it "returns a single application" do
|
21
|
+
application = client.application(prefetched_application_id)
|
22
|
+
expect(application.id).to eq prefetched_application_id
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
describe ".edit_application", :vcr do
|
27
|
+
let(:prefetched_application_id) {
|
28
|
+
find_resource("#{@casette_base_path}_applications/returns_applications.yml", "applications")[:id]
|
29
|
+
}
|
30
|
+
let(:default_price_increase) { 1.1 }
|
31
|
+
|
32
|
+
it "updates given application by ID" do
|
33
|
+
client.edit_application(prefetched_application_id, default_price_increase: default_price_increase)
|
34
|
+
assert_requested :put, bs_url("applications/#{prefetched_application_id}"),
|
35
|
+
body: { applications: [{ default_price_increase: default_price_increase }] }.to_json
|
36
|
+
end
|
37
|
+
|
38
|
+
it "returns updated application" do
|
39
|
+
application = client.edit_application(prefetched_application_id, default_price_increase: default_price_increase)
|
40
|
+
expect(application).to be_kind_of(BookingSync::API::Resource)
|
41
|
+
expect(application.default_price_increase).to eq(default_price_increase.to_s)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,116 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe BookingSync::API::Client::Contacts do
|
4
|
+
let(:api) { BookingSync::API::Client.new(test_access_token) }
|
5
|
+
|
6
|
+
before { |ex| @casette_base_path = casette_path(casette_dir, ex.metadata) }
|
7
|
+
|
8
|
+
describe ".contacts", :vcr do
|
9
|
+
subject(:contacts) { api.contacts }
|
10
|
+
subject(:contacts_by_ids) { api.contacts(ids: contact_ids) }
|
11
|
+
let(:contact_ids) do
|
12
|
+
find_resources("#{@casette_base_path}_contacts/returns_contacts.yml", "contacts").map { |r| r["id"] }[0..1]
|
13
|
+
end
|
14
|
+
|
15
|
+
it "returns contacts" do
|
16
|
+
expect(contacts).not_to be_empty
|
17
|
+
assert_requested :get, bs_url("contacts")
|
18
|
+
end
|
19
|
+
|
20
|
+
it "returns contacts by ids" do
|
21
|
+
expect(contacts_by_ids.size).to eq(1)
|
22
|
+
assert_requested :get, bs_url("contacts/#{contact_ids.join(',')}")
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
describe ".contact", :vcr do
|
27
|
+
subject(:contact) { api.contact(1) }
|
28
|
+
|
29
|
+
it "returns contact" do
|
30
|
+
expect(contact).not_to be_empty
|
31
|
+
assert_requested :get, bs_url("contacts/1")
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
describe ".contact", :vcr do
|
36
|
+
subject(:contact) { api.contact(prefetched_contact_id) }
|
37
|
+
|
38
|
+
let(:prefetched_contact_id) {
|
39
|
+
find_resource("#{@casette_base_path}_contacts/returns_contacts.yml", "contacts")[:id]
|
40
|
+
}
|
41
|
+
|
42
|
+
it "returns a single contact" do
|
43
|
+
expect(contact.id).to eq prefetched_contact_id
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
describe ".create_contact", :vcr do
|
48
|
+
subject(:create_contact) { api.create_contact(attributes) }
|
49
|
+
|
50
|
+
let(:attributes) do
|
51
|
+
{
|
52
|
+
firstname: "John",
|
53
|
+
lastname: "Doe",
|
54
|
+
email: "halldor@example.com",
|
55
|
+
website: "http://www.demo.com",
|
56
|
+
address1: "Demo address",
|
57
|
+
gender: "male",
|
58
|
+
phones: [{ label: "default", number: "123456789" }],
|
59
|
+
country_code: "IS",
|
60
|
+
city: "Reykjavik",
|
61
|
+
zip: "33209",
|
62
|
+
state: "Demo",
|
63
|
+
spoken_languages: [:en]
|
64
|
+
}
|
65
|
+
end
|
66
|
+
|
67
|
+
it "creates a new contact" do
|
68
|
+
create_contact
|
69
|
+
assert_requested :post, bs_url("contacts"),
|
70
|
+
body: { contacts: [attributes] }.to_json
|
71
|
+
end
|
72
|
+
|
73
|
+
it "returns newly created contact" do
|
74
|
+
VCR.use_cassette("BookingSync_API_Client_Contacts/_create_contact/creates_a_new_contact") do
|
75
|
+
contact = create_contact
|
76
|
+
expect(contact.email).to eq "halldor@example.com"
|
77
|
+
expect(contact.fullname).to eq ("John Doe")
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
describe ".edit_contact", :vcr do
|
83
|
+
subject(:edit_contact) { api.edit_contact(created_contact_id, firstname: "Knut", lastname: "Eljassen") }
|
84
|
+
|
85
|
+
let(:created_contact_id) {
|
86
|
+
find_resource("#{@casette_base_path}_create_contact/creates_a_new_contact.yml", "contacts")[:id]
|
87
|
+
}
|
88
|
+
|
89
|
+
it "updates given contact by ID" do
|
90
|
+
edit_contact
|
91
|
+
assert_requested :put, bs_url("contacts/#{created_contact_id}"),
|
92
|
+
body: { contacts: [{ firstname: "Knut", lastname: "Eljassen" }] }.to_json
|
93
|
+
end
|
94
|
+
|
95
|
+
it "returns updated contact" do
|
96
|
+
VCR.use_cassette("BookingSync_API_Client_Contacts/_edit_contact/updates_given_contact_by_ID") do
|
97
|
+
contact = edit_contact
|
98
|
+
expect(contact).to be_kind_of(BookingSync::API::Resource)
|
99
|
+
expect(contact.fullname).to eq("Knut Eljassen")
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
describe ".delete_contact", :vcr do
|
105
|
+
subject(:delete_contact) { api.delete_contact(created_contact_id) }
|
106
|
+
|
107
|
+
let(:created_contact_id) {
|
108
|
+
find_resource("#{casette_dir}/BookingSync_API_Client_Contacts/_create_contact/creates_a_new_contact.yml", "contacts")[:id]
|
109
|
+
}
|
110
|
+
|
111
|
+
it "deletes given contact" do
|
112
|
+
delete_contact
|
113
|
+
assert_requested :delete, bs_url("contacts/#{created_contact_id}")
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|