guesty-client 0.1.0 → 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.
Files changed (63) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +59 -1
  3. data/README.md +2 -3
  4. data/lib/guesty/access_tokens/upsert.rb +8 -34
  5. data/lib/guesty/api_error.rb +8 -16
  6. data/lib/guesty/client.rb +6 -12
  7. data/lib/guesty/config.rb +1 -16
  8. data/lib/guesty/conversations/attachments/index.rb +2 -6
  9. data/lib/guesty/conversations/index.rb +14 -32
  10. data/lib/guesty/conversations/messages/reply.rb +2 -24
  11. data/lib/guesty/conversations/posts/index.rb +5 -22
  12. data/lib/guesty/conversations/posts/since.rb +0 -1
  13. data/lib/guesty/conversations/search.rb +2 -5
  14. data/lib/guesty/conversations/show.rb +1 -10
  15. data/lib/guesty/conversations.rb +5 -1
  16. data/lib/guesty/error.rb +0 -4
  17. data/lib/guesty/guest_folio/invoice_items/index.rb +2 -6
  18. data/lib/guesty/guests/profiles/create.rb +1 -5
  19. data/lib/guesty/guests/profiles/show.rb +1 -8
  20. data/lib/guesty/guests/profiles/update.rb +2 -7
  21. data/lib/guesty/homes/calendars/show.rb +29 -68
  22. data/lib/guesty/homes/search.rb +4 -23
  23. data/lib/guesty/memory_rate_limiter.rb +0 -3
  24. data/lib/guesty/memory_token_store.rb +0 -8
  25. data/lib/guesty/operation.rb +5 -3
  26. data/lib/guesty/payments/index.rb +14 -0
  27. data/lib/guesty/payments/record.rb +59 -0
  28. data/lib/guesty/rate_limiter_middleware.rb +2 -15
  29. data/lib/guesty/reservations/accommodation_fare/update.rb +4 -5
  30. data/lib/guesty/reservations/approve.rb +2 -8
  31. data/lib/guesty/reservations/booking_date/update.rb +19 -0
  32. data/lib/guesty/reservations/confirmation_code/update.rb +22 -0
  33. data/lib/guesty/reservations/create.rb +1 -8
  34. data/lib/guesty/reservations/custom_fields/update.rb +2 -11
  35. data/lib/guesty/reservations/dates/update.rb +2 -8
  36. data/lib/guesty/reservations/decline.rb +1 -11
  37. data/lib/guesty/reservations/guests/update.rb +43 -0
  38. data/lib/guesty/reservations/index.rb +18 -0
  39. data/lib/guesty/reservations/pre_approve.rb +2 -8
  40. data/lib/guesty/reservations/recover.rb +3 -11
  41. data/lib/guesty/reservations/relocate.rb +18 -0
  42. data/lib/guesty/reservations/reviews/extractors/airbnb.rb +0 -1
  43. data/lib/guesty/reservations/reviews/index.rb +17 -42
  44. data/lib/guesty/reservations/search.rb +58 -35
  45. data/lib/guesty/reservations/show.rb +7 -16
  46. data/lib/guesty/reservations/source/update.rb +19 -0
  47. data/lib/guesty/reservations/status/update.rb +1 -3
  48. data/lib/guesty/reviews/respond.rb +1 -3
  49. data/lib/guesty/version.rb +1 -1
  50. data/lib/guesty/views/create.rb +1 -5
  51. data/lib/guesty/views/update.rb +1 -19
  52. data/lib/guesty/webhooks/create.rb +1 -7
  53. data/lib/guesty/webhooks/index.rb +1 -7
  54. data/lib/guesty/webhooks/signatures/verify.rb +3 -6
  55. data/lib/guesty/webhooks/sync.rb +0 -3
  56. data/lib/guesty/webhooks/update.rb +1 -7
  57. data/lib/guesty.rb +8 -4
  58. data/sig/guesty.rbs +52 -30
  59. metadata +9 -5
  60. data/lib/guesty/reservations/flags/update.rb +0 -33
  61. data/lib/guesty/reservations/payments/create.rb +0 -72
  62. data/lib/guesty/reservations/stays/update.rb +0 -42
  63. data/lib/guesty/reservations/update.rb +0 -19
@@ -0,0 +1,18 @@
1
+ module Guesty
2
+ module Reservations
3
+ class Relocate
4
+ include Guesty::Operation
5
+
6
+ # @rbs (reservation_id: ::String, listing_id: ::String, ?ignore_calendar: bool?, ?ignore_terms: bool?, ?ignore_blocks: bool?) -> Dry::Monads::Result[bool]
7
+ def call(reservation_id:, listing_id:, ignore_calendar: nil, ignore_terms: nil, ignore_blocks: nil)
8
+ argument! reservation_id: :required if reservation_id.blank?
9
+ argument! listing_id: :required if listing_id.blank?
10
+
11
+ body = { listingId: listing_id, ignoreCalendar: ignore_calendar, ignoreTerms: ignore_terms, ignoreBlocks: ignore_blocks }.compact
12
+ request(:put, "reservations-v3/#{reservation_id}/relocate", body)
13
+
14
+ Success(true)
15
+ end
16
+ end
17
+ end
18
+ end
@@ -2,7 +2,6 @@ module Guesty
2
2
  module Reservations
3
3
  module Reviews
4
4
  module Extractors
5
- # Airbnb raw reviews carry category_ratings[].review_category_tags.
6
5
  class Airbnb < Base
7
6
  POSITIVE_TAG = 'GUEST_REVIEW_HOST_POSITIVE_'.freeze #: ::String
8
7
  NEGATIVE_TAG = 'GUEST_REVIEW_HOST_NEGATIVE_'.freeze #: ::String
@@ -1,7 +1,7 @@
1
1
  module Guesty
2
2
  module Reservations
3
3
  module Reviews
4
- # startDate/endDate filter on the review's updatedAt, newest update first.
4
+ # startDate filters on the review's updatedAt.
5
5
  class Index
6
6
  include Guesty::Operation
7
7
 
@@ -9,56 +9,31 @@ module Guesty
9
9
  def call(since:, skip: 0, take: 100)
10
10
  argument! take: :invalid if take.blank? || take <= 0
11
11
 
12
- response = Guesty.do_request(:get, 'reviews', query(since, skip, take))
12
+ reviews = request(:get, 'reviews', { startDate: since.utc.iso8601, skip:, limit: take })[:data]
13
+ return Success([]) unless reviews.is_a?(Array)
13
14
 
14
- return response unless response.success?
15
-
16
- reviews = parse_reviews(response.value!.body[:data])
17
-
18
- Success(reviews)
15
+ Success(reviews.filter_map { |review| parse(review) })
19
16
  end
20
17
 
21
18
  private
22
19
 
23
- # @rbs (::Time since, ::Integer skip, ::Integer take) -> ::Hash[::Symbol, untyped]
24
- def query(since, skip, take)
25
- {
26
- startDate: since.utc.iso8601,
27
- skip:,
28
- limit: take
29
- }
30
- end
31
-
32
- # @rbs (::Array[::Hash[::Symbol, untyped]] guesty_reviews_data) -> ::Array[::Hash[::Symbol, untyped]]
33
- def parse_reviews(guesty_reviews_data)
34
- return [] unless guesty_reviews_data.is_a?(Array)
35
-
36
- guesty_reviews_data.map do |review_data|
37
- next unless review_data[:rawReview].is_a?(Hash)
20
+ # @rbs (::Hash[::Symbol, untyped] review) -> ::Hash[::Symbol, untyped]?
21
+ def parse(review)
22
+ return unless review[:rawReview].is_a?(Hash)
38
23
 
39
- extractor = get_extractor_for_channel(review_data[:channelId]&.downcase)
40
- result = extractor.new.call(raw_review: review_data[:rawReview])
41
- next unless result.success?
24
+ result = extractor_for(review[:channelId]).new.call(raw_review: review[:rawReview])
25
+ return if result.failure?
42
26
 
43
- result.value!.merge(
44
- created_at: review_data[:createdAt],
45
- guesty_review_id: review_data[:_id],
46
- guesty_reservation_id: review_data[:reservationId]
47
- )
48
- end.compact
27
+ result.value!.merge(created_at: review[:createdAt], guesty_review_id: review[:_id], guesty_reservation_id: review[:reservationId])
49
28
  end
50
29
 
51
- # @rbs (::String? channel) -> untyped
52
- def get_extractor_for_channel(channel)
53
- case channel.to_s.downcase
54
- when /airbnb/i
55
- Extractors::Airbnb
56
- when /booking/i
57
- Extractors::BookingCom
58
- when /vrbo|homeaway/i
59
- Extractors::Vrbo
60
- else
61
- error! "Unsupported channel: #{channel}"
30
+ # @rbs (::String? channel_id) -> untyped
31
+ def extractor_for(channel_id)
32
+ case (channel = channel_id.to_s.downcase)
33
+ when /airbnb/ then Extractors::Airbnb
34
+ when /booking/ then Extractors::BookingCom
35
+ when /vrbo|homeaway/ then Extractors::Vrbo
36
+ else error! "Unsupported channel: #{channel}"
62
37
  end
63
38
  end
64
39
  end
@@ -1,62 +1,85 @@
1
1
  module Guesty
2
2
  module Reservations
3
- # Searches the legacy /reservations index (deprecated, switching off at the
4
- # end of 2026 — new reservation calls use reservations-v3).
3
+ # Rows are lean, keyed by reservationId. There is no lastUpdatedAt filter:
4
+ # follow updates through the reservation.updated.v2 webhook.
5
5
  class Search
6
6
  include Guesty::Operation
7
7
 
8
8
  FILTER_MAPPINGS = {
9
- ids: { field: '_id', operator: '$in' },
10
- updated_at: { field: 'lastUpdatedAt', operator: '$gt' },
11
- conversation_id: { field: 'conversationId', operator: '$eq' },
12
- status: { field: 'status', operator: '$eq' },
13
- confirmation_code: { field: 'confirmationCode', operator: '$eq' }
9
+ status: { field: 'status' },
10
+ confirmation_code: { field: 'confirmationCode' },
11
+ listing_id: { field: 'listingId' },
12
+ source: { field: 'source' },
13
+ check_in: { field: 'checkIn', range: :date },
14
+ check_out: { field: 'checkOut', range: :date },
15
+ created_at: { field: 'createdAt', range: :datetime }
14
16
  }.freeze
15
17
 
16
- # @rbs (::Hash[::Symbol, untyped] attributes) -> ::Array[::Hash[::Symbol, untyped]]
18
+ SORTS = %w[_id -_id checkIn -checkIn checkOut -checkOut createdAt -createdAt].freeze #: ::Array[::String]
19
+ TAKE = 100 #: ::Integer # Max allowed by the Guesty API
20
+
21
+ # @rbs (::Hash[::Symbol, untyped] attributes) -> ::Array[::Hash[::Symbol, ::String]]
17
22
  def self.filters(attributes)
18
- attributes.map do |key, value|
19
- normalized = key == :updated_at ? value&.strftime('%Y-%m-%d') : value
23
+ attributes.flat_map do |key, value|
24
+ mapping = FILTER_MAPPINGS.fetch(key)
25
+ next [{ name: "filter[#{mapping[:field]}]", value: Array.wrap(value).join(',') }] unless mapping[:range]
20
26
 
21
- FILTER_MAPPINGS.fetch(key).merge(value: normalized)
27
+ range_entries(mapping.fetch(:range), mapping.fetch(:field), value)
22
28
  end
23
29
  end
24
30
 
25
- # @rbs (fields: ::Array[::String], attributes: ::Hash[::Symbol, untyped], ?skip: ::Integer, ?take: ::Integer) -> Dry::Monads::Result[::Hash[::Symbol, untyped]]
26
- def call(fields:, attributes:, skip: 0, take: 100)
27
- validate_arguments!(fields:, attributes:, take:)
31
+ # @rbs (::Symbol kind, ::String field, ::Range range) -> ::Array[::Hash[::Symbol, ::String]]
32
+ def self.range_entries(kind, field, range)
33
+ entries = []
34
+ entries << { name: "filter[#{field}][gte]", value: range_bound(kind, range.begin) } if range.begin
35
+ entries << { name: "filter[#{field}][#{range.exclude_end? ? 'lt' : 'lte'}]", value: range_bound(kind, range.end) } if range.end
28
36
 
29
- response = Guesty.do_request(:get, 'reservations', params(fields:, attributes:, skip:, take:))
30
- return response unless response.success?
37
+ entries
38
+ end
39
+ private_class_method :range_entries
31
40
 
32
- body = response.value!.body
33
- result = {
34
- results: body[:results],
35
- count: body[:count]
36
- }
41
+ # @rbs (::Symbol kind, untyped value) -> ::String
42
+ def self.range_bound(kind, value)
43
+ kind == :date ? value.strftime('%Y-%m-%d') : value.iso8601
44
+ end
45
+ private_class_method :range_bound
37
46
 
38
- Success(result)
47
+ # @rbs (attributes: ::Hash[::Symbol, untyped], ?skip: ::Integer, ?take: ::Integer, ?sort: ::String) -> Dry::Monads::Result[::Hash[::Symbol, untyped]]
48
+ def call(attributes:, skip: 0, take: TAKE, sort: 'createdAt')
49
+ validate_arguments!(attributes:, take:, sort:)
50
+
51
+ Success(request(:get, 'reservations-v3/search', params(attributes:, skip:, take:, sort:)).slice(:results, :pagination))
39
52
  end
40
53
 
41
54
  private
42
55
 
43
- def validate_arguments!(fields:, attributes:, take:)
44
- argument! fields: :required, fatal: true if fields.blank?
56
+ def validate_arguments!(attributes:, take:, sort:)
45
57
  argument! attributes: :required if attributes.blank?
46
- argument! take: :invalid if take && take <= 0
58
+ argument! take: :invalid if take <= 0
59
+ argument! sort: :invalid unless SORTS.include?(sort)
47
60
  argument! attributes: :invalid unless attributes.keys.all? { |name| FILTER_MAPPINGS.key?(name) }
48
- argument! updated_at: :required if attributes.key?(:updated_at) && attributes[:updated_at].blank?
49
- argument! ids: :required if attributes.key?(:ids) && attributes[:ids].empty?
61
+
62
+ attributes.each { |key, value| validate_filter!(key, value) }
63
+ end
64
+
65
+ # @rbs (::Symbol key, untyped value) -> void
66
+ def validate_filter!(key, value)
67
+ mapping = FILTER_MAPPINGS.fetch(key)
68
+
69
+ if mapping[:range]
70
+ argument! key => :invalid unless value.is_a?(Range) && (value.begin || value.end)
71
+ elsif value.blank?
72
+ argument! key => :required
73
+ end
50
74
  end
51
75
 
52
- def params(fields:, attributes:, skip:, take:)
53
- {
54
- filters: self.class.filters(attributes).to_json,
55
- sort: 'createdAt',
56
- limit: take,
57
- skip:,
58
- fields: fields.join(' ')
59
- }
76
+ # @rbs (attributes: ::Hash[::Symbol, untyped], skip: ::Integer, take: ::Integer, sort: ::String) -> ::Hash[::String, untyped]
77
+ def params(attributes:, skip:, take:, sort:)
78
+ self.class.filters(attributes).to_h { |entry| [entry[:name], entry[:value]] }.merge(
79
+ 'sort' => sort,
80
+ 'limit' => take,
81
+ 'skip' => skip
82
+ )
60
83
  end
61
84
  end
62
85
  end
@@ -1,27 +1,18 @@
1
1
  module Guesty
2
2
  module Reservations
3
+ # A v3 reservation embeds no guest and no money: read the guest (bookerId)
4
+ # through Guests::Profiles::Show and the payout through Payments::Index.
3
5
  class Show
4
6
  include Guesty::Operation
5
7
 
6
- # @rbs (reservation_id: ::String, fields: ::Array[::String]) -> Dry::Monads::Result[::Hash[::Symbol, untyped]]
7
- def call(reservation_id:, fields: [])
8
+ # @rbs (reservation_id: ::String) -> Dry::Monads::Result[::Hash[::Symbol, untyped]]
9
+ def call(reservation_id:)
8
10
  argument! reservation_id: :required if reservation_id.blank?
9
- argument! fields: :required if fields.blank?
10
11
 
11
- attributes = {} #: ::Hash[::Symbol, ::String]
12
- attributes[:fields] = fields.join(' ') if fields.present?
12
+ reservation = Index.new.call!(reservation_ids: [reservation_id]).value!.find { |row| row[:_id] == reservation_id }
13
+ error! "Reservation #{reservation_id} not found on Guesty", fatal: true unless reservation
13
14
 
14
- response = Guesty.do_request :get, "reservations/#{reservation_id}", attributes
15
-
16
- Success(handle_response(response))
17
- end
18
-
19
- private
20
-
21
- def handle_response(response)
22
- raise response.failure unless response.success?
23
-
24
- response.value!.body
15
+ Success(reservation)
25
16
  end
26
17
  end
27
18
  end
@@ -0,0 +1,19 @@
1
+ module Guesty
2
+ module Reservations
3
+ module Source
4
+ class Update
5
+ include Guesty::Operation
6
+
7
+ # @rbs (reservation_id: ::String, source: ::String, ?point_of_sale: ::String?, ?apply_recalculation: bool?) -> Dry::Monads::Result[bool]
8
+ def call(reservation_id:, source:, point_of_sale: nil, apply_recalculation: nil)
9
+ argument! reservation_id: :required if reservation_id.blank?
10
+ argument! source: :required if source.blank?
11
+
12
+ request(:put, "reservations-v3/#{reservation_id}/source", { source:, pointOfSale: point_of_sale, applyRecalculation: apply_recalculation }.compact)
13
+
14
+ Success(true)
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -9,9 +9,7 @@ module Guesty
9
9
  argument! reservation_id: :required if reservation_id.blank?
10
10
  argument! attributes: :required if attributes.blank?
11
11
 
12
- response = Guesty.do_request :put, "reservations-v3/#{reservation_id}/status", attributes
13
-
14
- raise response.failure unless response.success?
12
+ request(:put, "reservations-v3/#{reservation_id}/status", attributes)
15
13
 
16
14
  Success(true)
17
15
  end
@@ -8,9 +8,7 @@ module Guesty
8
8
  argument! review_id: :required if review_id.blank?
9
9
  argument! text: :required if text.blank?
10
10
 
11
- response = Guesty.do_request(:put, "reviews/#{review_id}/reply", { reviewReply: text })
12
-
13
- raise response.failure unless response.success?
11
+ request(:put, "reviews/#{review_id}/reply", { reviewReply: text })
14
12
 
15
13
  Success(true)
16
14
  end
@@ -1,3 +1,3 @@
1
1
  module Guesty
2
- VERSION = '0.1.0'.freeze
2
+ VERSION = '0.2.0'.freeze
3
3
  end
@@ -8,11 +8,7 @@ module Guesty
8
8
  argument! title: :required if title.blank?
9
9
  argument! section: :required if section.blank?
10
10
 
11
- response = Guesty.do_request :post, 'views', { title:, section: }
12
-
13
- raise response.failure unless response.success?
14
-
15
- Success(response.value!.body)
11
+ Success(request(:post, 'views', { title:, section: }))
16
12
  end
17
13
  end
18
14
  end
@@ -8,25 +8,7 @@ module Guesty
8
8
  argument! id: :required if id.blank?
9
9
  argument! attributes: :invalid if [title, fields, filters, sort].all?(&:nil?)
10
10
 
11
- response = Guesty.do_request :put,
12
- "views/#{id}",
13
- payload(
14
- id,
15
- title:,
16
- fields:,
17
- filters:,
18
- sort:
19
- )
20
-
21
- raise response.failure unless response.success?
22
-
23
- Success(response.value!.body)
24
- end
25
-
26
- private
27
-
28
- def payload(id, title:, fields:, filters:, sort:)
29
- { _id: id, title:, fields:, filters:, sort: }.compact
11
+ Success(request(:put, "views/#{id}", { _id: id, title:, fields:, filters:, sort: }.compact))
30
12
  end
31
13
  end
32
14
  end
@@ -8,13 +8,7 @@ module Guesty
8
8
  argument! url: :required if url.blank?
9
9
  argument! events: :required if events.blank?
10
10
 
11
- response = Guesty.do_request :post, 'webhooks', { url:, events: }
12
-
13
- if response.success?
14
- Success(response.value!.body)
15
- else
16
- response
17
- end
11
+ Success(request(:post, 'webhooks', { url:, events: }))
18
12
  end
19
13
  end
20
14
  end
@@ -5,13 +5,7 @@ module Guesty
5
5
 
6
6
  # @rbs () -> Dry::Monads::Result[::Array[untyped]]
7
7
  def call
8
- response = Guesty.do_request :get, 'webhooks'
9
-
10
- if response.success?
11
- Success(response.value!.body)
12
- else
13
- response
14
- end
8
+ Success(request(:get, 'webhooks'))
15
9
  end
16
10
  end
17
11
  end
@@ -3,10 +3,8 @@ require 'openssl'
3
3
 
4
4
  module Guesty
5
5
  module Webhooks
6
- # Guesty delivers webhooks through Svix, which signs every request. The secret is the
7
- # base64 after the optional whsec_ prefix of the account signing key, the signed content is
8
- # "<svix-id>.<svix-timestamp>.<raw body>", and svix-signature lists space-separated
9
- # "version,base64-HMAC-SHA256" entries, one per active key.
6
+ # Svix signs "<svix-id>.<svix-timestamp>.<raw body>" with the base64 after the whsec_ prefix;
7
+ # svix-signature lists space-separated "version,base64-HMAC-SHA256" entries, one per active key.
10
8
  module Signatures
11
9
  class Verify
12
10
  include Guesty::Operation
@@ -34,8 +32,7 @@ module Guesty
34
32
 
35
33
  private
36
34
 
37
- # A timestamp outside the tolerance fails even with a valid signature, so a captured
38
- # delivery cannot be replayed later.
35
+ # Refuses replays of a captured delivery.
39
36
  # @rbs (untyped header) -> void
40
37
  def verify_timestamp!(header)
41
38
  timestamp = Integer(header, exception: false)
@@ -1,8 +1,5 @@
1
1
  module Guesty
2
2
  module Webhooks
3
- # Subscribes the urls to the events: creates the missing, updates the
4
- # drifted, leaves the rest. Returns the urls grouped by :created, :updated,
5
- # :unchanged.
6
3
  class Sync
7
4
  include Guesty::Operation
8
5
 
@@ -9,13 +9,7 @@ module Guesty
9
9
  argument! url: :required if url.blank?
10
10
  argument! events: :required if events.blank?
11
11
 
12
- response = Guesty.do_request :put, "webhooks/#{id}", { url:, events: }
13
-
14
- if response.success?
15
- Success(response.value!.body)
16
- else
17
- response
18
- end
12
+ Success(request(:put, "webhooks/#{id}", { url:, events: }))
19
13
  end
20
14
  end
21
15
  end
data/lib/guesty.rb CHANGED
@@ -32,17 +32,22 @@ require_relative 'guesty/guests/profiles/show'
32
32
  require_relative 'guesty/guests/profiles/update'
33
33
  require_relative 'guesty/homes/calendars/show'
34
34
  require_relative 'guesty/homes/search'
35
+ require_relative 'guesty/payments/index'
36
+ require_relative 'guesty/payments/record'
35
37
  require_relative 'guesty/reservations'
36
38
  require_relative 'guesty/reservations/accommodation_fare/update'
37
39
  require_relative 'guesty/reservations/approve'
40
+ require_relative 'guesty/reservations/booking_date/update'
41
+ require_relative 'guesty/reservations/confirmation_code/update'
38
42
  require_relative 'guesty/reservations/create'
39
43
  require_relative 'guesty/reservations/custom_fields/update'
40
44
  require_relative 'guesty/reservations/dates/update'
41
45
  require_relative 'guesty/reservations/decline'
42
- require_relative 'guesty/reservations/flags/update'
43
- require_relative 'guesty/reservations/payments/create'
46
+ require_relative 'guesty/reservations/guests/update'
47
+ require_relative 'guesty/reservations/index'
44
48
  require_relative 'guesty/reservations/pre_approve'
45
49
  require_relative 'guesty/reservations/recover'
50
+ require_relative 'guesty/reservations/relocate'
46
51
  require_relative 'guesty/reservations/reviews/extractors/base'
47
52
  require_relative 'guesty/reservations/reviews/extractors/airbnb'
48
53
  require_relative 'guesty/reservations/reviews/extractors/booking_com'
@@ -50,10 +55,9 @@ require_relative 'guesty/reservations/reviews/extractors/vrbo'
50
55
  require_relative 'guesty/reservations/reviews/index'
51
56
  require_relative 'guesty/reservations/search'
52
57
  require_relative 'guesty/reservations/show'
58
+ require_relative 'guesty/reservations/source/update'
53
59
  require_relative 'guesty/reservations/status/cancel'
54
60
  require_relative 'guesty/reservations/status/update'
55
- require_relative 'guesty/reservations/stays/update'
56
- require_relative 'guesty/reservations/update'
57
61
  require_relative 'guesty/reviews/respond'
58
62
  require_relative 'guesty/views/create'
59
63
  require_relative 'guesty/views/update'
data/sig/guesty.rbs CHANGED
@@ -24,7 +24,6 @@ module Guesty
24
24
  def self.rate_limit_key: (::Symbol window) -> ::Symbol
25
25
  def self.token_slots: (?::Symbol priority) -> ::Array[slot]
26
26
  def self.webhook_key: () -> ::String?
27
- def self.sync_guest_and_reservation_changes?: () -> bool
28
27
  def self.pick_slot: (::Symbol priority) -> slot
29
28
  def self.successful_response?: (untyped response) -> bool
30
29
  def self.retryable_read?: (::StandardError error) -> bool
@@ -74,8 +73,6 @@ module Guesty
74
73
  attr_accessor rate_limiter: untyped
75
74
  attr_accessor slot_picker: untyped
76
75
  attr_accessor base_url: ::String
77
- attr_accessor sync_guest_and_reservation_changes: bool
78
- attr_accessor custom_fields: ::Hash[::Symbol, ::String]
79
76
  attr_accessor default_currency: ::String?
80
77
  end
81
78
 
@@ -90,7 +87,6 @@ module Guesty
90
87
 
91
88
  def read: (::String slot_key) -> Token?
92
89
  def save: (slot_key: ::String, access_token: ::String, expires_at: ::Time) -> Token
93
- def clear: () -> ::Hash[untyped, untyped]
94
90
  end
95
91
 
96
92
  class MemoryRateLimiter
@@ -98,7 +94,6 @@ module Guesty
98
94
  end
99
95
 
100
96
  class RateLimiterMiddleware
101
- def initialize: (untyped app, ?::Hash[::Symbol, untyped] options) -> void
102
97
  def on_request: (untyped env) -> void
103
98
  end
104
99
 
@@ -124,15 +119,24 @@ module Guesty
124
119
  def self.from_conversation: (untyped conversation) -> ::Array[::Hash[::Symbol, untyped]]
125
120
 
126
121
  class Search
127
- FILTER_MAPPINGS: ::Hash[::Symbol, ::Hash[::Symbol, ::String]]
122
+ FILTER_MAPPINGS: ::Hash[::Symbol, ::Hash[::Symbol, untyped]]
123
+ SORTS: ::Array[::String]
124
+ TAKE: ::Integer
128
125
 
129
- def self.filters: (::Hash[::Symbol, untyped] attributes) -> ::Array[::Hash[::Symbol, untyped]]
130
- def call: (fields: ::Array[::String], attributes: ::Hash[::Symbol, untyped], ?skip: ::Integer, ?take: ::Integer) -> ::Dry::Monads::Result[::Hash[::Symbol, untyped]]
126
+ def self.filters: (::Hash[::Symbol, untyped] attributes) -> ::Array[::Hash[::Symbol, ::String]]
127
+ def call: (attributes: ::Hash[::Symbol, untyped], ?skip: ::Integer, ?take: ::Integer, ?sort: ::String) -> ::Dry::Monads::Result[::Hash[::Symbol, untyped]]
131
128
  alias call! call
132
129
  end
133
130
 
134
131
  class Show
135
- def call: (reservation_id: ::String, fields: ::Array[::String]) -> ::Dry::Monads::Result[::Hash[::Symbol, untyped]]
132
+ def call: (reservation_id: ::String) -> ::Dry::Monads::Result[::Hash[::Symbol, untyped]]
133
+ alias call! call
134
+ end
135
+
136
+ class Index
137
+ TAKE: ::Integer
138
+
139
+ def call: (reservation_ids: ::Array[::String]) -> ::Dry::Monads::Result[::Array[::Hash[::Symbol, untyped]]]
136
140
  alias call! call
137
141
  end
138
142
 
@@ -141,8 +145,8 @@ module Guesty
141
145
  alias call! call
142
146
  end
143
147
 
144
- class Update
145
- def call: (reservation_id: ::String, attributes: ::Hash[::Symbol, untyped]) -> ::Dry::Monads::Result[bool]
148
+ class Relocate
149
+ def call: (reservation_id: ::String, listing_id: ::String, ?ignore_calendar: bool?, ?ignore_terms: bool?, ?ignore_blocks: bool?) -> ::Dry::Monads::Result[bool]
146
150
  alias call! call
147
151
  end
148
152
 
@@ -187,16 +191,32 @@ module Guesty
187
191
  end
188
192
  end
189
193
 
190
- module Stays
194
+ module Guests
195
+ class Update
196
+ def call: (reservation_id: ::String, attributes: ::Hash[::Symbol, untyped]) -> ::Dry::Monads::Result[bool]
197
+ alias call! call
198
+ end
199
+ end
200
+
201
+ module ConfirmationCode
202
+ class Update
203
+ LENGTH: ::Range
204
+
205
+ def call: (reservation_id: ::String, confirmation_code: ::String) -> ::Dry::Monads::Result[bool]
206
+ alias call! call
207
+ end
208
+ end
209
+
210
+ module Source
191
211
  class Update
192
- def call: (reservation_id: ::String, stay: ::Hash[::Symbol, untyped]) -> ::Dry::Monads::Result[bool]
212
+ def call: (reservation_id: ::String, source: ::String, ?point_of_sale: ::String?, ?apply_recalculation: bool?) -> ::Dry::Monads::Result[bool]
193
213
  alias call! call
194
214
  end
195
215
  end
196
216
 
197
- module Flags
217
+ module BookingDate
198
218
  class Update
199
- def call: (reservation_id: ::String, flags: ::Hash[::Symbol, bool]) -> ::Dry::Monads::Result[bool]
219
+ def call: (reservation_id: ::String, booking_date: ::Time) -> ::Dry::Monads::Result[bool]
200
220
  alias call! call
201
221
  end
202
222
  end
@@ -213,17 +233,7 @@ module Guesty
213
233
 
214
234
  module CustomFields
215
235
  class Update
216
- def call: (reservation_id: ::String, custom_fields: ::Array[::Hash[::Symbol, untyped]]) -> ::Dry::Monads::Result[::Hash[::Symbol, untyped]]
217
- alias call! call
218
- end
219
- end
220
-
221
- module Payments
222
- class Create
223
- PAYMENT_METHOD_NAME: ::String
224
- HISTORY_UNAVAILABLE: ::String
225
-
226
- def call: (reservation_id: ::String, attributes: ::Hash[::Symbol, untyped]) -> ::Dry::Monads::Result[::Hash[::Symbol, untyped]]
236
+ def call: (reservation_id: ::String, custom_fields: ::Array[::Hash[::Symbol, untyped]]) -> ::Dry::Monads::Result[untyped]
227
237
  alias call! call
228
238
  end
229
239
  end
@@ -256,6 +266,7 @@ module Guesty
256
266
  CHANNELS: ::Hash[::String, ::String]
257
267
 
258
268
  def self.channel: (::String module_type) -> ::String
269
+ def self.summary: (untyped conversation) -> ::Hash[::Symbol, untyped]
259
270
 
260
271
  class Index
261
272
  FIELDS: ::String
@@ -298,10 +309,6 @@ module Guesty
298
309
 
299
310
  module Messages
300
311
  class Reply
301
- BOOKING_MODULE_TYPES: ::Hash[::String, ::String]
302
-
303
- def self.module_type_for: (::String? channel_name) -> ::String?
304
-
305
312
  def call: (conversation_id: ::String, body: ::String, ?module_type: ::String?) -> ::Dry::Monads::Result[::Hash[::Symbol, untyped]]
306
313
  alias call! call
307
314
  end
@@ -317,6 +324,21 @@ module Guesty
317
324
  end
318
325
  end
319
326
 
327
+ module Payments
328
+ class Index
329
+ def call: (reservation_id: ::String) -> ::Dry::Monads::Result[::Hash[::Symbol, untyped]]
330
+ alias call! call
331
+ end
332
+
333
+ class Record
334
+ METHODS: ::Array[::String]
335
+ NOTE_MAX_LENGTH: ::Integer
336
+
337
+ def call: (reservation_id: ::String, attributes: ::Hash[::Symbol, untyped]) -> ::Dry::Monads::Result[::Hash[::Symbol, untyped]]
338
+ alias call! call
339
+ end
340
+ end
341
+
320
342
  module Guests
321
343
  OTA_LINK_TYPES: ::Hash[::Symbol, ::String]
322
344