bookingsync-api 0.2.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +25 -0
- data/CHANGELOG.md +12 -0
- data/README.md +1 -1
- data/bookingsync-api.gemspec +2 -1
- data/lib/bookingsync/api/client/host_reviews.rb +95 -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 +10 -6
- data/lib/bookingsync/api/version.rb +1 -1
- data/lib/bookingsync/api.rb +1 -0
- data/spec/bookingsync/api/client/host_reviews_spec.rb +150 -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_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 +50 -6
- data/.travis.yml +0 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 19a563dd183bbdcdfbceb5be9665ef5a2671e8b3ab48bc2f4ae364ebc263450b
|
4
|
+
data.tar.gz: 4b816566334c7c60da5433815cb9f8014448914d7f0560aa87b650432c109928
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c1bbbecf812ca989b599a76062e983f6745f80ca02b74e81ecea4665bbc2736369fa68f3b491c68a913370251c589125ee1ceeceb75fa3e96097567be088d457
|
7
|
+
data.tar.gz: 8c7236ad450eb3c7c94dba200bcd8458a1bfb157c731f483f8f2ebf09a7611698377f54d4b37fc59b4bec9430aee9843176c9b6a7150d748672f51d1570b5753
|
@@ -0,0 +1,25 @@
|
|
1
|
+
name: CI
|
2
|
+
on:
|
3
|
+
push:
|
4
|
+
branches:
|
5
|
+
- master
|
6
|
+
pull_request:
|
7
|
+
jobs:
|
8
|
+
rspec:
|
9
|
+
strategy:
|
10
|
+
fail-fast: false
|
11
|
+
matrix:
|
12
|
+
include:
|
13
|
+
- { ruby: '2.7' }
|
14
|
+
- { ruby: '3.0' }
|
15
|
+
- { ruby: '3.1' }
|
16
|
+
runs-on: ubuntu-latest
|
17
|
+
env:
|
18
|
+
BUNDLE_GEMFILE: ${{ github.workspace }}/Gemfile
|
19
|
+
steps:
|
20
|
+
- uses: actions/checkout@v2
|
21
|
+
- uses: ruby/setup-ruby@v1
|
22
|
+
with:
|
23
|
+
ruby-version: ${{ matrix.ruby }}
|
24
|
+
bundler-cache: true
|
25
|
+
- run: bundle exec rspec
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,18 @@
|
|
2
2
|
|
3
3
|
# master
|
4
4
|
|
5
|
+
## 1.1.0
|
6
|
+
|
7
|
+
- Add support for `host_reviews` endpoint.
|
8
|
+
- Add support for `review_replies` endpoint.
|
9
|
+
- Add support for `dismiss_review` action.
|
10
|
+
|
11
|
+
## 1.0.0
|
12
|
+
|
13
|
+
- Drop support for ruby prior to 2.7
|
14
|
+
- Add support for ruby 3.0 and 3.1
|
15
|
+
- Update and lock faraday at `~> 2`
|
16
|
+
|
5
17
|
## 0.2.0 - 2022-01-10
|
6
18
|
- upgrade net-http-persistent to be ruby 3 ready
|
7
19
|
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
[![Build Status](https://
|
1
|
+
[![Build Status](https://github.com/BookingSync/bookingsync-api/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/BookingSync/bookingsync-api/actions/workflows/ci.yml)
|
2
2
|
[![Code Climate](https://codeclimate.com/github/BookingSync/bookingsync-api.png)](https://codeclimate.com/github/BookingSync/bookingsync-api)
|
3
3
|
|
4
4
|
# BookingSync::API
|
data/bookingsync-api.gemspec
CHANGED
@@ -18,7 +18,8 @@ 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", "
|
21
|
+
spec.add_dependency "faraday", "~> 2"
|
22
|
+
spec.add_dependency "faraday-net_http_persistent", ">= 2.0.2"
|
22
23
|
spec.add_dependency "net-http-persistent", [">= 4.0.1", "< 5.0"]
|
23
24
|
spec.add_dependency "hashie"
|
24
25
|
spec.add_dependency "addressable"
|
@@ -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
|
@@ -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
|
@@ -129,7 +133,7 @@ module BookingSync::API
|
|
129
133
|
@instrumenter = options[:instrumenter] || NoopInstrumenter
|
130
134
|
@base_url = options[:base_url]
|
131
135
|
@serializer = Serializer.new
|
132
|
-
@conn =
|
136
|
+
@conn = build_connection
|
133
137
|
@conn.headers[:accept] = MEDIA_TYPE
|
134
138
|
@conn.headers[:content_type] = MEDIA_TYPE
|
135
139
|
@conn.headers[:user_agent] = user_agent
|
@@ -306,15 +310,15 @@ module BookingSync::API
|
|
306
310
|
|
307
311
|
private
|
308
312
|
|
309
|
-
def
|
310
|
-
Faraday
|
311
|
-
|
312
|
-
|
313
|
+
def build_connection
|
314
|
+
Faraday.new(**faraday_options) do |f|
|
315
|
+
f.use :logger, logger
|
316
|
+
f.adapter :net_http_persistent
|
313
317
|
end
|
314
318
|
end
|
315
319
|
|
316
320
|
def faraday_options
|
317
|
-
{
|
321
|
+
{ ssl: { verify: verify_ssl? } }
|
318
322
|
end
|
319
323
|
|
320
324
|
# Return BookingSync base URL. Default is https://www.bookingsync.com
|
data/lib/bookingsync/api.rb
CHANGED
@@ -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
|
@@ -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
|