bookingsync-api 1.0.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +10 -0
- data/lib/bookingsync/api/client/host_reviews.rb +95 -0
- data/lib/bookingsync/api/client/rental_urls.rb +10 -0
- data/lib/bookingsync/api/client/review_replies.rb +53 -0
- data/lib/bookingsync/api/client/reviews.rb +10 -0
- data/lib/bookingsync/api/client.rb +4 -0
- data/lib/bookingsync/api/version.rb +1 -1
- data/spec/bookingsync/api/client/host_reviews_spec.rb +150 -0
- data/spec/bookingsync/api/client/rental_urls_spec.rb +9 -0
- data/spec/bookingsync/api/client/review_replies_spec.rb +61 -0
- data/spec/bookingsync/api/client/reviews_spec.rb +21 -1
- data/spec/fixtures/cassettes/BookingSync_API_Client_ApplicationsPeriodsRentals/_applications_periods_rental/returns_applications_periods_rental.yml +5 -5
- data/spec/fixtures/cassettes/BookingSync_API_Client_ApplicationsPeriodsRentals/_applications_periods_rentals/returns_applications_periods_rentals.yml +5 -5
- data/spec/fixtures/cassettes/BookingSync_API_Client_ApplicationsPeriodsRentals/_create_applications_periods_rental/creates_a_applications_periods_rental.yml +3 -3
- data/spec/fixtures/cassettes/BookingSync_API_Client_ApplicationsPeriodsRentals/_edit_applications_periods_rental/returns_updated_applications_periods_rental.yml +2 -2
- data/spec/fixtures/cassettes/BookingSync_API_Client_ApplicationsPeriodsRentals/_edit_applications_periods_rental/updates_given_applications_periods_rental_by_ID.yml +2 -2
- data/spec/fixtures/cassettes/BookingSync_API_Client_Bookings/_create_applications_periods_rental/creates_an_applications_periods_rental.yml +3 -3
- data/spec/fixtures/cassettes/BookingSync_API_Client_HostReviews/_create_draft_host_review/creates_a_new_draft_review.yml +78 -0
- data/spec/fixtures/cassettes/BookingSync_API_Client_HostReviews/_create_submitted_host_review/creates_a_new_submitted_review.yml +78 -0
- data/spec/fixtures/cassettes/BookingSync_API_Client_HostReviews/_dismiss_host_review/dismisses_host_review.yml +76 -0
- data/spec/fixtures/cassettes/BookingSync_API_Client_HostReviews/_edit_draft_host_review/updates_given_host_review_by_ID.yml +77 -0
- data/spec/fixtures/cassettes/BookingSync_API_Client_HostReviews/_host_review/returns_a_single_host_review.yml +88 -0
- data/spec/fixtures/cassettes/BookingSync_API_Client_HostReviews/_host_reviews/returns_host_reviews.yml +87 -0
- data/spec/fixtures/cassettes/BookingSync_API_Client_HostReviews/_submit_draft_host_review/submits_given_host_review_by_ID.yml +77 -0
- data/spec/fixtures/cassettes/BookingSync_API_Client_Hosts/_hosts/returns_hosts.yml +1 -1
- data/spec/fixtures/cassettes/BookingSync_API_Client_RentalUrls/_rental_urls/links/returns_associated_rental.yml +3 -3
- data/spec/fixtures/cassettes/BookingSync_API_Client_RentalUrls/_restore_rental_url/restores_given_rental_url.yml +71 -0
- data/spec/fixtures/cassettes/BookingSync_API_Client_ReviewReplies/_create_guest_review_reply/creates_new_reply_to_a_guest_review.yml +77 -0
- data/spec/fixtures/cassettes/BookingSync_API_Client_ReviewReplies/_create_host_review_reply/creates_a_new_reply_to_host_review.yml +77 -0
- data/spec/fixtures/cassettes/BookingSync_API_Client_ReviewReplies/_review_replies/returns_review_replies.yml +86 -0
- data/spec/fixtures/cassettes/BookingSync_API_Client_ReviewReplies/_review_reply/returns_a_single_review_reply.yml +87 -0
- data/spec/fixtures/cassettes/BookingSync_API_Client_Reviews/_create_review/creates_a_new_review.yml +41 -50
- data/spec/fixtures/cassettes/BookingSync_API_Client_Reviews/_dismiss_review/dismisses_review.yml +126 -0
- metadata +35 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 77712b294f809ae4db266f8b9b86b413c37c5930867c41901c28b9ddeada66e4
|
4
|
+
data.tar.gz: cf83e35ff3ff5d828eedcc5b7b3a1a4d488365ee5a98ee5705c128742e184a13
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ea5aa7568560d912b3cb66afa0e5a179797666be9c42562a7408381e9922863afc4883a977a4cff749245e7e72f52608d5d1caeb2f0828f9b787ec9cf6e368a1
|
7
|
+
data.tar.gz: 2bf3db0f2b86e119712dac32d7ec3a47c60b1b32363b69d4bb95253f5d92ad6fda666be476bb60771ca8176d58fc76435daffd8548a52b3c904d4b848eacfa28
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,16 @@
|
|
2
2
|
|
3
3
|
# master
|
4
4
|
|
5
|
+
## 1.2.0
|
6
|
+
|
7
|
+
- Add support for `restore` action for `rental_urls`.
|
8
|
+
|
9
|
+
## 1.1.0
|
10
|
+
|
11
|
+
- Add support for `host_reviews` endpoint.
|
12
|
+
- Add support for `review_replies` endpoint.
|
13
|
+
- Add support for `dismiss_review` action.
|
14
|
+
|
5
15
|
## 1.0.0
|
6
16
|
|
7
17
|
- Drop support for ruby prior to 2.7
|
@@ -0,0 +1,95 @@
|
|
1
|
+
module BookingSync::API
|
2
|
+
class Client
|
3
|
+
module HostReviews
|
4
|
+
# List host reviews
|
5
|
+
#
|
6
|
+
# Returns host reviews 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 reviews.
|
10
|
+
#
|
11
|
+
# @example Get the list of host reviews for the current account
|
12
|
+
# host_reviews = @api.host_reviews
|
13
|
+
# host_reviews.first.is_guest_recommended # => true
|
14
|
+
# @example Get the list of host reviews only with submitted_at and comment for smaller response
|
15
|
+
# @api.host_reviews(fields: [:submitted_at, :comment])
|
16
|
+
# @see http://developers.bookingsync.com/reference/endpoints/host_reviews/#list-host-reviews
|
17
|
+
def host_reviews(options = {}, &block)
|
18
|
+
paginate :host_reviews, options, &block
|
19
|
+
end
|
20
|
+
|
21
|
+
# Get a single host review
|
22
|
+
#
|
23
|
+
# @param host review [BookingSync::API::Resource|String] HostReview or ID
|
24
|
+
# of the host review.
|
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 host_review(host_review, options = {})
|
29
|
+
get("host_reviews/#{host_review}", options).pop
|
30
|
+
end
|
31
|
+
|
32
|
+
# Create a new non-submitted host review
|
33
|
+
#
|
34
|
+
# @param booking [BookingSync::API::Resource|Integer] Booking or ID of
|
35
|
+
# the booking for which a host review will be created.
|
36
|
+
# @param options [Hash] Host Review's attributes.
|
37
|
+
# @return [BookingSync::API::Resource] Newly created host review.
|
38
|
+
def create_draft_host_review(booking, options = {})
|
39
|
+
post("bookings/#{booking}/host_reviews/draft", host_reviews: [options]).pop
|
40
|
+
end
|
41
|
+
|
42
|
+
# Create a new submitted host review
|
43
|
+
#
|
44
|
+
# @param booking [BookingSync::API::Resource|Integer] Booking or ID of
|
45
|
+
# the booking for which a host review will be created.
|
46
|
+
# @param options [Hash] Host Review's attributes.
|
47
|
+
# @return [BookingSync::API::Resource] Newly created host review.
|
48
|
+
def create_submitted_host_review(booking, options = {})
|
49
|
+
post("bookings/#{booking}/host_reviews", host_reviews: [options]).pop
|
50
|
+
end
|
51
|
+
|
52
|
+
# Edit a draft host review
|
53
|
+
#
|
54
|
+
# @param host review [BookingSync::API::Resource|String] Host Review or ID of
|
55
|
+
# the host review to be updated.
|
56
|
+
# @param options [Hash] Host review attributes to be updated.
|
57
|
+
# @return [BookingSync::API::Resource] Updated host review on success,
|
58
|
+
# exception is raised otherwise.
|
59
|
+
# @example
|
60
|
+
# host_review = @api.host_reviews.first
|
61
|
+
# @api.edit_host_review(host_review, { comment: "Thanks for being such a great guest!", submitted_at: "20201-03-22T12:00:00Z" })
|
62
|
+
def edit_draft_host_review(host_review, options = {})
|
63
|
+
put("host_reviews/draft/#{host_review}", host_reviews: [options]).pop
|
64
|
+
end
|
65
|
+
|
66
|
+
# Submit a draft host review
|
67
|
+
#
|
68
|
+
# @param host review [BookingSync::API::Resource|String] Host Review or ID of
|
69
|
+
# the host review to be updated.
|
70
|
+
# @param options [Hash] Host review attributes to be updated.
|
71
|
+
# @return [BookingSync::API::Resource] Updated host review on success,
|
72
|
+
# exception is raised otherwise.
|
73
|
+
# @example
|
74
|
+
# host_review = @api.host_reviews.first
|
75
|
+
# @api.edit_host_review(host_review, { comment: "Thanks for being such a great guest!", submitted_at: "20201-03-22T12:00:00Z" })
|
76
|
+
def submit_draft_host_review(host_review, options = {})
|
77
|
+
put("host_reviews/draft/#{host_review}/submit", host_reviews: [options]).pop
|
78
|
+
end
|
79
|
+
|
80
|
+
# Dismiss a host review
|
81
|
+
#
|
82
|
+
# @param host review [BookingSync::API::Resource|String] Host Review or ID of
|
83
|
+
# the host review to be dismissed.
|
84
|
+
# @param options [Hash] Host review dismissal attributes.
|
85
|
+
# @return [BookingSync::API::Resource] Dismissed host review on success,
|
86
|
+
# exception is raised otherwise.
|
87
|
+
# @example
|
88
|
+
# host_review = @api.host_reviews.first
|
89
|
+
# @api.dismiss_host_review(host_review, { dismissed_at: "20201-03-22T12:00:00Z" })
|
90
|
+
def dismiss_host_review(host_review, options = {})
|
91
|
+
put("host_reviews/#{host_review}/dismiss", host_reviews: [options]).pop
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
@@ -62,6 +62,16 @@ module BookingSync::API
|
|
62
62
|
delete "rental_urls/#{rental_url}"
|
63
63
|
end
|
64
64
|
|
65
|
+
# Restore a RentalUrl
|
66
|
+
#
|
67
|
+
# @param rental_url [BookingSync::API::Resource|Integer] RentalUrl or ID
|
68
|
+
# of the rental_url to be canceled.
|
69
|
+
# @return [BookingSync::API::Resource] Restored rental_url on success,
|
70
|
+
# exception is raised otherwise.
|
71
|
+
def restore_rental_url(rental_url)
|
72
|
+
put("rental_urls/#{rental_url}/restore").pop
|
73
|
+
end
|
74
|
+
|
65
75
|
private
|
66
76
|
|
67
77
|
def base_64_encode(file_path)
|
@@ -0,0 +1,53 @@
|
|
1
|
+
module BookingSync::API
|
2
|
+
class Client
|
3
|
+
module ReviewReplies
|
4
|
+
# List review replies
|
5
|
+
#
|
6
|
+
# Returns review replies 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 review replies.
|
10
|
+
#
|
11
|
+
# @example Get the list of review replies for the current account
|
12
|
+
# review_replies = @api.review_replies
|
13
|
+
# review_replies.first.message # => "Thanks for the feedback!"
|
14
|
+
# @example Get the list of review_replies only with message and submitted_at for smaller response
|
15
|
+
# @api.review_replies(fields: [:message, :submitted_at])
|
16
|
+
# @see http://developers.bookingsync.com/reference/endpoints/review_replies/#list-review-replies
|
17
|
+
def review_replies(options = {}, &block)
|
18
|
+
paginate :review_replies, options, &block
|
19
|
+
end
|
20
|
+
|
21
|
+
# Get a single review reply
|
22
|
+
#
|
23
|
+
# @param review reply [BookingSync::API::Resource|String] Review Reply or ID
|
24
|
+
# of the review reply.
|
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 review_reply(review_reply, options = {})
|
29
|
+
get("review_replies/#{review_reply}", options).pop
|
30
|
+
end
|
31
|
+
|
32
|
+
# Create a new review reply
|
33
|
+
#
|
34
|
+
# @param review [BookingSync::API::Resource|Integer] Review or ID of
|
35
|
+
# the review for which a reply will be created.
|
36
|
+
# @param options [Hash] Review's attributes.
|
37
|
+
# @return [BookingSync::API::Resource] Newly created review.
|
38
|
+
def create_guest_review_reply(review, options = {})
|
39
|
+
post("reviews/#{review}/reply", review_replies: [options]).pop
|
40
|
+
end
|
41
|
+
|
42
|
+
# Create a new host review reply
|
43
|
+
#
|
44
|
+
# @param host review [BookingSync::API::Resource|Integer] HostReview or ID of
|
45
|
+
# the host review for which a reply will be created.
|
46
|
+
# @param options [Hash] Review's attributes.
|
47
|
+
# @return [BookingSync::API::Resource] Newly created review.
|
48
|
+
def create_host_review_reply(host_review, options = {})
|
49
|
+
post("host_reviews/#{host_review}/reply", review_replies: [options]).pop
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -38,6 +38,16 @@ module BookingSync::API
|
|
38
38
|
def create_review(booking, options = {})
|
39
39
|
post("bookings/#{booking}/reviews", reviews: [options]).pop
|
40
40
|
end
|
41
|
+
|
42
|
+
# Dismiss a review
|
43
|
+
#
|
44
|
+
# @param booking [BookingSync::API::Resource|Integer] Review or ID of
|
45
|
+
# the review which you want to dismiss.
|
46
|
+
# @param options [Hash] Review's dismissal attributes.
|
47
|
+
# @return [BookingSync::API::Resource] Dismissed review.
|
48
|
+
def dismiss_review(review, options = {})
|
49
|
+
put("reviews/#{review}/dismiss", reviews: [options]).pop
|
50
|
+
end
|
41
51
|
end
|
42
52
|
end
|
43
53
|
end
|
@@ -18,6 +18,7 @@ require "bookingsync/api/client/clients"
|
|
18
18
|
require "bookingsync/api/client/contacts"
|
19
19
|
require "bookingsync/api/client/destinations"
|
20
20
|
require "bookingsync/api/client/fees"
|
21
|
+
require "bookingsync/api/client/host_reviews"
|
21
22
|
require "bookingsync/api/client/hosts"
|
22
23
|
require "bookingsync/api/client/inquiries"
|
23
24
|
require "bookingsync/api/client/living_rooms"
|
@@ -39,6 +40,7 @@ require "bookingsync/api/client/rental_cancelation_policies"
|
|
39
40
|
require "bookingsync/api/client/rental_cancelation_policy_items"
|
40
41
|
require "bookingsync/api/client/rentals_contents_overrides"
|
41
42
|
require "bookingsync/api/client/rental_urls"
|
43
|
+
require "bookingsync/api/client/review_replies"
|
42
44
|
require "bookingsync/api/client/reviews"
|
43
45
|
require "bookingsync/api/client/seasons"
|
44
46
|
require "bookingsync/api/client/special_offers"
|
@@ -79,6 +81,7 @@ module BookingSync::API
|
|
79
81
|
include BookingSync::API::Client::Destinations
|
80
82
|
include BookingSync::API::Client::Fees
|
81
83
|
include BookingSync::API::Client::Hosts
|
84
|
+
include BookingSync::API::Client::HostReviews
|
82
85
|
include BookingSync::API::Client::Inquiries
|
83
86
|
include BookingSync::API::Client::LivingRooms
|
84
87
|
include BookingSync::API::Client::Messages
|
@@ -101,6 +104,7 @@ module BookingSync::API
|
|
101
104
|
include BookingSync::API::Client::RentalCancelationPolicyItems
|
102
105
|
include BookingSync::API::Client::RentalsContentsOverrides
|
103
106
|
include BookingSync::API::Client::RentalUrls
|
107
|
+
include BookingSync::API::Client::ReviewReplies
|
104
108
|
include BookingSync::API::Client::Reviews
|
105
109
|
include BookingSync::API::Client::Seasons
|
106
110
|
include BookingSync::API::Client::SpecialOffers
|
@@ -0,0 +1,150 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe BookingSync::API::Client::HostReviews 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 ".host_reviews", :vcr do
|
9
|
+
it "returns host_reviews" do
|
10
|
+
expect(client.host_reviews).not_to be_empty
|
11
|
+
assert_requested :get, bs_url("host_reviews")
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
describe ".host_review", :vcr do
|
16
|
+
let(:prefetched_host_review_id) do
|
17
|
+
find_resource("#{@casette_base_path}_host_reviews/returns_host_reviews.yml", "host_reviews")[:id]
|
18
|
+
end
|
19
|
+
|
20
|
+
it "returns a single host_review" do
|
21
|
+
host_review = client.host_review(prefetched_host_review_id)
|
22
|
+
expect(host_review.id).to eq prefetched_host_review_id
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
describe ".create_draft_host_review", :vcr do
|
27
|
+
let(:attributes) { { comment: "Awesome guest", expires_at: "2045-06-07T12:00:00Z", shareable: false } }
|
28
|
+
let(:booking) { BookingSync::API::Resource.new(client, id: 228) }
|
29
|
+
|
30
|
+
it "creates a new draft review" do
|
31
|
+
client.create_draft_host_review(booking, attributes)
|
32
|
+
assert_requested :post, bs_url("bookings/#{booking}/host_reviews/draft"),
|
33
|
+
body: { host_reviews: [attributes] }.to_json
|
34
|
+
end
|
35
|
+
|
36
|
+
it "returns newly created review" do
|
37
|
+
VCR.use_cassette("BookingSync_API_Client_HostReviews/_create_draft_host_review/creates_a_new_draft_review") do
|
38
|
+
host_review = client.create_draft_host_review(booking, attributes)
|
39
|
+
expect(host_review.comment).to eq(attributes[:comment])
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
describe ".create_submitted_host_review", :vcr do
|
45
|
+
let(:attributes) do
|
46
|
+
{
|
47
|
+
comment: "Awesome guest",
|
48
|
+
submitted_at: "2020-06-06T12:00:00Z",
|
49
|
+
expires_at: "2020-06-07T12:00:00Z",
|
50
|
+
is_guest_recommended: true,
|
51
|
+
shareable: false,
|
52
|
+
source_id: source_id,
|
53
|
+
criteria: {
|
54
|
+
cleanliness: { rating: 5 },
|
55
|
+
respect_house_rules: { rating: 4 },
|
56
|
+
communication: { rating: 5 }
|
57
|
+
}
|
58
|
+
}
|
59
|
+
end
|
60
|
+
let(:booking) { BookingSync::API::Resource.new(client, id: 3) }
|
61
|
+
let(:source_id) { 2 }
|
62
|
+
|
63
|
+
it "creates a new submitted review" do
|
64
|
+
client.create_submitted_host_review(booking, attributes)
|
65
|
+
assert_requested :post, bs_url("bookings/#{booking}/host_reviews"),
|
66
|
+
body: { host_reviews: [attributes] }.to_json
|
67
|
+
end
|
68
|
+
|
69
|
+
it "returns newly created review" do
|
70
|
+
VCR.use_cassette("BookingSync_API_Client_HostReviews/_create_submitted_host_review/creates_a_new_submitted_review") do
|
71
|
+
host_review = client.create_submitted_host_review(booking, attributes)
|
72
|
+
expect(host_review.comment).to eq(attributes[:comment])
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
describe ".edit_draft_host_review", :vcr do
|
78
|
+
let(:attributes) { { comment: "Woops, not great after all, he emptied the fridge" } }
|
79
|
+
let(:created_host_review_id) do
|
80
|
+
find_resource("#{@casette_base_path}_create_draft_host_review/creates_a_new_draft_review.yml", "host_reviews")[:id]
|
81
|
+
end
|
82
|
+
|
83
|
+
it "updates given host review by ID" do
|
84
|
+
client.edit_draft_host_review(created_host_review_id, attributes)
|
85
|
+
assert_requested :put, bs_url("host_reviews/draft/#{created_host_review_id}"),
|
86
|
+
body: { host_reviews: [attributes] }.to_json
|
87
|
+
end
|
88
|
+
|
89
|
+
it "returns updated host review" do
|
90
|
+
VCR.use_cassette("BookingSync_API_Client_HostReviews/_edit_draft_host_review/updates_given_host_review_by_ID") do
|
91
|
+
host_review = client.edit_draft_host_review(created_host_review_id, attributes)
|
92
|
+
expect(host_review).to be_kind_of(BookingSync::API::Resource)
|
93
|
+
expect(host_review.comment).to eq("Woops, not great after all, he emptied the fridge")
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
describe ".submit_draft_host_review", :vcr do
|
99
|
+
let(:attributes) do
|
100
|
+
{
|
101
|
+
comment: "Woops, not great after all, he emptied the fridge",
|
102
|
+
submitted_at: "2021-06-06T12:00:00Z",
|
103
|
+
is_guest_recommended: false
|
104
|
+
}
|
105
|
+
end
|
106
|
+
let(:created_host_review_id) do
|
107
|
+
find_resource("#{@casette_base_path}_create_draft_host_review/creates_a_new_draft_review.yml", "host_reviews")[:id]
|
108
|
+
end
|
109
|
+
|
110
|
+
it "submits given host review by ID" do
|
111
|
+
client.submit_draft_host_review(created_host_review_id, attributes)
|
112
|
+
assert_requested :put, bs_url("host_reviews/draft/#{created_host_review_id}/submit"),
|
113
|
+
body: { host_reviews: [attributes] }.to_json
|
114
|
+
end
|
115
|
+
|
116
|
+
it "returns updated host review" do
|
117
|
+
VCR.use_cassette("BookingSync_API_Client_HostReviews/_submit_draft_host_review/submits_given_host_review_by_ID") do
|
118
|
+
host_review = client.submit_draft_host_review(created_host_review_id, attributes)
|
119
|
+
expect(host_review).to be_kind_of(BookingSync::API::Resource)
|
120
|
+
expect(
|
121
|
+
host_review.values_at(:comment, :submitted_at, :is_guest_recommended)
|
122
|
+
).to eq([
|
123
|
+
"Woops, not great after all, he emptied the fridge",
|
124
|
+
Time.parse("2021-06-06T12:00:00Z"),
|
125
|
+
false
|
126
|
+
])
|
127
|
+
end
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
describe ".dismiss_host_review", :vcr do
|
132
|
+
let(:attributes) { { dismissed_at: "2021-12-01T16:00:00Z" } }
|
133
|
+
let(:created_host_review_id) do
|
134
|
+
find_resource("#{@casette_base_path}_create_submitted_host_review/creates_a_new_submitted_review.yml", "host_reviews")[:id]
|
135
|
+
end
|
136
|
+
|
137
|
+
it "dismisses host review" do
|
138
|
+
client.dismiss_host_review(created_host_review_id, attributes)
|
139
|
+
assert_requested :put, bs_url("host_reviews/#{created_host_review_id}/dismiss"),
|
140
|
+
body: { host_reviews: [attributes] }.to_json
|
141
|
+
end
|
142
|
+
|
143
|
+
it "returns dismissed review" do
|
144
|
+
VCR.use_cassette("BookingSync_API_Client_HostReviews/_dismiss_host_review/dismisses_host_review") do
|
145
|
+
host_review = client.dismiss_host_review(created_host_review_id, attributes)
|
146
|
+
expect(host_review.dismissed_at).to eq(Time.parse(attributes[:dismissed_at]))
|
147
|
+
end
|
148
|
+
end
|
149
|
+
end
|
150
|
+
end
|
@@ -80,4 +80,13 @@ describe BookingSync::API::Client::RentalUrls do
|
|
80
80
|
assert_requested :delete, bs_url("rental_urls/#{created_rental_url_id}")
|
81
81
|
end
|
82
82
|
end
|
83
|
+
|
84
|
+
describe "#restore_rental_url", :vcr do
|
85
|
+
let(:rental_url_id) { "e3511ab6-0976-44a7-befe-3e1e08d6f924" }
|
86
|
+
|
87
|
+
it "restores given rental_url" do
|
88
|
+
client.restore_rental_url(rental_url_id)
|
89
|
+
assert_requested :put, bs_url("rental_urls/#{rental_url_id}/restore")
|
90
|
+
end
|
91
|
+
end
|
83
92
|
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe BookingSync::API::Client::ReviewReplies 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 ".review_replies", :vcr do
|
9
|
+
it "returns review_replies" do
|
10
|
+
expect(client.review_replies).not_to be_empty
|
11
|
+
assert_requested :get, bs_url("review_replies")
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
describe ".review_reply", :vcr do
|
16
|
+
let(:prefetched_review_reply_id) do
|
17
|
+
find_resource("#{@casette_base_path}_review_replies/returns_review_replies.yml", "review_replies")[:id]
|
18
|
+
end
|
19
|
+
|
20
|
+
it "returns a single review_reply" do
|
21
|
+
review_reply = client.review_reply(prefetched_review_reply_id)
|
22
|
+
expect(review_reply.id).to eq prefetched_review_reply_id
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
describe ".create_host_review_reply", :vcr do
|
27
|
+
let(:attributes) { { message: "Thanks!" } }
|
28
|
+
let(:host_review) { BookingSync::API::Resource.new(client, id: "04356dc9-1349-4e05-b818-09ccdac8d5dd") }
|
29
|
+
|
30
|
+
it "creates a new reply to host review" do
|
31
|
+
client.create_host_review_reply(host_review, attributes)
|
32
|
+
assert_requested :post, bs_url("host_reviews/#{host_review}/reply"),
|
33
|
+
body: { review_replies: [attributes] }.to_json
|
34
|
+
end
|
35
|
+
|
36
|
+
it "returns newly created review" do
|
37
|
+
VCR.use_cassette("BookingSync_API_Client_ReviewReplies/_create_host_review_reply/creates_a_new_reply_to_host_review") do
|
38
|
+
host_review_reply = client.create_host_review_reply(host_review, attributes)
|
39
|
+
expect(host_review_reply.message).to eq(attributes[:message])
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
describe ".create_guest_review_reply", :vcr do
|
45
|
+
let(:attributes) { { message: "Merci!" } }
|
46
|
+
let(:guest_review) { BookingSync::API::Resource.new(client, id: 34) }
|
47
|
+
|
48
|
+
it "creates new reply to a guest review" do
|
49
|
+
client.create_guest_review_reply(guest_review, attributes)
|
50
|
+
assert_requested :post, bs_url("reviews/#{guest_review}/reply"),
|
51
|
+
body: { review_replies: [attributes] }.to_json
|
52
|
+
end
|
53
|
+
|
54
|
+
it "returns newly created review" do
|
55
|
+
VCR.use_cassette("BookingSync_API_Client_ReviewReplies/_create_guest_review_reply/creates_new_reply_to_a_guest_review") do
|
56
|
+
guest_review_reply = client.create_guest_review_reply(guest_review, attributes)
|
57
|
+
expect(guest_review_reply.message).to eq(attributes[:message])
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
@@ -25,7 +25,7 @@ describe BookingSync::API::Client::Reviews do
|
|
25
25
|
|
26
26
|
describe ".create_review", :vcr do
|
27
27
|
let(:attributes) { { comment: "Awesome place", rating: 5 } }
|
28
|
-
let(:booking) { BookingSync::API::Resource.new(client, id:
|
28
|
+
let(:booking) { BookingSync::API::Resource.new(client, id: 3) }
|
29
29
|
|
30
30
|
it "creates a new review" do
|
31
31
|
client.create_review(booking, attributes)
|
@@ -41,4 +41,24 @@ describe BookingSync::API::Client::Reviews do
|
|
41
41
|
end
|
42
42
|
end
|
43
43
|
end
|
44
|
+
|
45
|
+
describe ".dismiss_review", :vcr do
|
46
|
+
let(:attributes) { { dismissed_at: "2021-12-01T16:00:00Z" } }
|
47
|
+
let(:created_review_id) do
|
48
|
+
find_resource("#{@casette_base_path}_create_review/creates_a_new_review.yml", "reviews")[:id]
|
49
|
+
end
|
50
|
+
|
51
|
+
it "dismisses review" do
|
52
|
+
client.dismiss_review(created_review_id, attributes)
|
53
|
+
assert_requested :put, bs_url("reviews/#{created_review_id}/dismiss"),
|
54
|
+
body: { reviews: [attributes] }.to_json
|
55
|
+
end
|
56
|
+
|
57
|
+
it "returns dismissed review" do
|
58
|
+
VCR.use_cassette("BookingSync_API_Client_Reviews/_dismiss_review/dismisses_review") do
|
59
|
+
review = client.dismiss_review(created_review_id, attributes)
|
60
|
+
expect(review.dismissed_at).to eq(Time.parse(attributes[:dismissed_at]))
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
44
64
|
end
|
@@ -2,7 +2,7 @@
|
|
2
2
|
http_interactions:
|
3
3
|
- request:
|
4
4
|
method: get
|
5
|
-
uri: https://bookingsync.
|
5
|
+
uri: https://www.bookingsync.com/api/v3/applications_periods_rentals/2
|
6
6
|
body:
|
7
7
|
encoding: UTF-8
|
8
8
|
string: "{}"
|
@@ -33,8 +33,8 @@ http_interactions:
|
|
33
33
|
Etag:
|
34
34
|
- W/"4f16e1fadf19018a8e568c8eccace925"
|
35
35
|
Link:
|
36
|
-
- <https://bookingsync.
|
37
|
-
<https://bookingsync.
|
36
|
+
- <https://www.bookingsync.com/api/v3/applications_periods_rentals/2?page=1>; rel="first",
|
37
|
+
<https://www.bookingsync.com/api/v3/applications_periods_rentals/2?page=1>; rel="last"
|
38
38
|
Set-Cookie:
|
39
39
|
- ahoy_visit=2d8fdbfb-1554-4133-9dee-7595b92d0d3b; path=/; expires=Tue, 19 Feb
|
40
40
|
2019 13:17:09 -0000
|
@@ -74,7 +74,7 @@ http_interactions:
|
|
74
74
|
- '353'
|
75
75
|
body:
|
76
76
|
encoding: UTF-8
|
77
|
-
string: '{"applications_periods_rentals":[{"id":2,"price_increase":"15.0","start_date":"2019-01-01","end_date":"2100-01-01"}],"meta":{"Link":{"first":"https://bookingsync.
|
78
|
-
http_version:
|
77
|
+
string: '{"applications_periods_rentals":[{"id":2,"price_increase":"15.0","start_date":"2019-01-01","end_date":"2100-01-01"}],"meta":{"Link":{"first":"https://www.bookingsync.com/api/v3/applications_periods_rentals/2?page=1","last":"https://www.bookingsync.com/api/v3/applications_periods_rentals/2?page=1"},"X-Total-Pages":"1","X-Total-Count":"1","X-Per-Page":"100"}}'
|
78
|
+
http_version:
|
79
79
|
recorded_at: Tue, 12 Feb 2019 13:17:09 GMT
|
80
80
|
recorded_with: VCR 4.0.0
|
@@ -2,7 +2,7 @@
|
|
2
2
|
http_interactions:
|
3
3
|
- request:
|
4
4
|
method: get
|
5
|
-
uri: https://bookingsync.
|
5
|
+
uri: https://www.bookingsync.com/api/v3/applications_periods_rentals
|
6
6
|
body:
|
7
7
|
encoding: UTF-8
|
8
8
|
string: "{}"
|
@@ -33,8 +33,8 @@ http_interactions:
|
|
33
33
|
Etag:
|
34
34
|
- W/"73df67a8f30027c62974163194dc023c"
|
35
35
|
Link:
|
36
|
-
- <https://bookingsync.
|
37
|
-
<https://bookingsync.
|
36
|
+
- <https://www.bookingsync.com/api/v3/applications_periods_rentals?page=1>; rel="first",
|
37
|
+
<https://www.bookingsync.com/api/v3/applications_periods_rentals?page=1>; rel="last"
|
38
38
|
Set-Cookie:
|
39
39
|
- ahoy_visit=9d96a1b7-8d2b-4eac-81a2-cbab3a49d139; path=/; expires=Tue, 19 Feb
|
40
40
|
2019 13:16:28 -0000
|
@@ -74,7 +74,7 @@ http_interactions:
|
|
74
74
|
- '349'
|
75
75
|
body:
|
76
76
|
encoding: UTF-8
|
77
|
-
string: '{"applications_periods_rentals":[{"id":2,"price_increase":"15.0","start_date":"2019-01-01","end_date":"2100-01-01"}],"meta":{"Link":{"first":"https://bookingsync.
|
78
|
-
http_version:
|
77
|
+
string: '{"applications_periods_rentals":[{"id":2,"price_increase":"15.0","start_date":"2019-01-01","end_date":"2100-01-01"}],"meta":{"Link":{"first":"https://www.bookingsync.com/api/v3/applications_periods_rentals?page=1","last":"https://www.bookingsync.com/api/v3/applications_periods_rentals?page=1"},"X-Total-Pages":"1","X-Total-Count":"1","X-Per-Page":"100"}}'
|
78
|
+
http_version:
|
79
79
|
recorded_at: Tue, 12 Feb 2019 13:16:29 GMT
|
80
80
|
recorded_with: VCR 4.0.0
|
@@ -2,7 +2,7 @@
|
|
2
2
|
http_interactions:
|
3
3
|
- request:
|
4
4
|
method: post
|
5
|
-
uri: https://bookingsync.
|
5
|
+
uri: https://www.bookingsync.com/api/v3/applications_periods_rentals
|
6
6
|
body:
|
7
7
|
encoding: UTF-8
|
8
8
|
string: '{"applications_periods_rental":{"rental_id":1,"application_id":9,"start_date":"2017-01-03","end_date":"2017-01-04","price_increase":15}}'
|
@@ -33,7 +33,7 @@ http_interactions:
|
|
33
33
|
Etag:
|
34
34
|
- W/"329930caf43d53b1d9585178f1d749c2"
|
35
35
|
Location:
|
36
|
-
- https://bookingsync.
|
36
|
+
- https://www.bookingsync.com/api/v3/applications_periods_rentals/3
|
37
37
|
Set-Cookie:
|
38
38
|
- ahoy_visit=4cb740ce-99ee-48b1-9999-5f87d415f164; path=/; expires=Tue, 19 Feb
|
39
39
|
2019 17:47:53 -0000
|
@@ -66,6 +66,6 @@ http_interactions:
|
|
66
66
|
body:
|
67
67
|
encoding: UTF-8
|
68
68
|
string: '{"applications_periods_rentals":[{"id":3,"price_increase":"15.0","start_date":"2017-01-03","end_date":"2017-01-04"}],"meta":{}}'
|
69
|
-
http_version:
|
69
|
+
http_version:
|
70
70
|
recorded_at: Tue, 12 Feb 2019 17:47:54 GMT
|
71
71
|
recorded_with: VCR 4.0.0
|
@@ -2,7 +2,7 @@
|
|
2
2
|
http_interactions:
|
3
3
|
- request:
|
4
4
|
method: put
|
5
|
-
uri: https://bookingsync.
|
5
|
+
uri: https://www.bookingsync.com/api/v3/applications_periods_rentals/2
|
6
6
|
body:
|
7
7
|
encoding: UTF-8
|
8
8
|
string: '{"applications_periods_rental":{"price_increase":3.1}}'
|
@@ -64,6 +64,6 @@ http_interactions:
|
|
64
64
|
body:
|
65
65
|
encoding: UTF-8
|
66
66
|
string: '{"applications_periods_rentals":[{"id":2,"price_increase":"3.1","start_date":"2019-01-01","end_date":"2100-01-01"}],"meta":{}}'
|
67
|
-
http_version:
|
67
|
+
http_version:
|
68
68
|
recorded_at: Tue, 12 Feb 2019 13:33:30 GMT
|
69
69
|
recorded_with: VCR 4.0.0
|
@@ -2,7 +2,7 @@
|
|
2
2
|
http_interactions:
|
3
3
|
- request:
|
4
4
|
method: put
|
5
|
-
uri: https://bookingsync.
|
5
|
+
uri: https://www.bookingsync.com/api/v3/applications_periods_rentals/2
|
6
6
|
body:
|
7
7
|
encoding: UTF-8
|
8
8
|
string: '{"applications_periods_rental":{"price_increase":3.1}}'
|
@@ -64,6 +64,6 @@ http_interactions:
|
|
64
64
|
body:
|
65
65
|
encoding: UTF-8
|
66
66
|
string: '{"applications_periods_rentals":[{"id":2,"price_increase":"3.1","start_date":"2019-01-01","end_date":"2100-01-01"}],"meta":{}}'
|
67
|
-
http_version:
|
67
|
+
http_version:
|
68
68
|
recorded_at: Tue, 12 Feb 2019 13:31:05 GMT
|
69
69
|
recorded_with: VCR 4.0.0
|