guesty-client 0.2.0 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: abb486d40a4bf8d831a35d7096142a0abb0203bc7ebf330d7c5be0f28d720c56
4
- data.tar.gz: b6c5ceeda67b8a09f4da6785e0ba16a6903860337705cd1412aa8af7258d16f5
3
+ metadata.gz: e0a69783fb24f68ffcd5f29f9fd07d991064d8f0c36d93227db53c2c21b40e30
4
+ data.tar.gz: d07bf169c2e2c5624191b763ca81f47ef778cb01be7ec9da0c15d1f402c1ed9f
5
5
  SHA512:
6
- metadata.gz: 4f16f55de71dc90340172b65eb1cabd589387e67cdd5b459ffea7cb9a43a3f6624de1bcf5663c707d81e1fc4b32247ed8a10e0ed7551d3d99e765a809d9f1315
7
- data.tar.gz: 9ad6eb5ddac5b0f54183a8d4a7a5de6aa4708729d8070f2e8d3194ec271e2ece0d2e8da09698432c2b63543e012c172c6350242eea825396cb32e10d8e1e01c1
6
+ metadata.gz: 2e3a42ad6036d44288612fb92b2f3e4bf025b4444158cab4668be71f9809be499262a1031051fc83303d44499b2091f56f3f874eadea700f036a5a6cf968d5b8
7
+ data.tar.gz: 7b9bb280c15297338f83fc231304fb1de861514d988749a941621b82342a9f518e6a7effa00f0230fa11d09fa06c3a7537655200431d91abffc60f7ab5b71498
data/CHANGELOG.md CHANGED
@@ -2,6 +2,24 @@
2
2
 
3
3
  ## [Unreleased]
4
4
 
5
+ ## [0.2.2] - 2026-11-19
6
+
7
+ ### Added
8
+
9
+ - `Reservations::Resolutions::Index` reads `GET /airbnb-resolutions-center/reservations/{id}/resolutions`, the
10
+ reservation's closed Airbnb Resolution Center requests created in the `created_at:` Range (both ends required).
11
+ Each comes back as `{ external_id:, state:, amount_paid:, currency:, closed_at: }`: `external_id` is Airbnb's
12
+ request id (as in `airbnb.com/resolutions/<id>`), `state` the lowercased status (`CLOSED_STATE`) and `closed_at`
13
+ Airbnb's last update.
14
+
15
+ ## [0.2.1] - 2026-11-18
16
+
17
+ ### Added
18
+
19
+ - `Conversations::Posts::Index` keeps the posts Guesty marks `sentBy: channel`: emails the booking channel itself
20
+ sends, such as Airbnb Resolution Center notices. They come back with `sender_kind: "channel"` and the email's text
21
+ (`plainTextBody`) as `body`; `CHANNEL_SENDER` names the value.
22
+
5
23
  ## [0.2.0] - 2026-11-10
6
24
 
7
25
  Migrates the reservation surface off the legacy `/reservations` resources, which Guesty retires on
@@ -87,6 +105,8 @@ that integration's provider specs, ported with their recorded VCR cassettes.
87
105
  - Webhooks: `Index`, `Create`, `Update`, `Sync`, `Signatures::Verify` for Svix signatures.
88
106
  - Views: `Create`, `Update`.
89
107
 
90
- [Unreleased]: https://github.com/guestitab/guesty-client/compare/v0.2.0...staging
108
+ [Unreleased]: https://github.com/guestitab/guesty-client/compare/v0.2.2...staging
109
+ [0.2.2]: https://github.com/guestitab/guesty-client/compare/v0.2.1...v0.2.2
110
+ [0.2.1]: https://github.com/guestitab/guesty-client/compare/v0.2.0...v0.2.1
91
111
  [0.2.0]: https://github.com/guestitab/guesty-client/compare/v0.1.0...v0.2.0
92
112
  [0.1.0]: https://github.com/guestitab/guesty-client/releases/tag/v0.1.0
@@ -6,7 +6,8 @@ module Guesty
6
6
 
7
7
  LIMIT = 500
8
8
  LOG_SENDER = 'log'.freeze #: ::String
9
- SENDERS = ['guest', 'host', LOG_SENDER].freeze #: ::Array[::String]
9
+ CHANNEL_SENDER = 'channel'.freeze #: ::String
10
+ SENDERS = ['guest', 'host', LOG_SENDER, CHANNEL_SENDER].freeze #: ::Array[::String]
10
11
  SYSTEM_MODULE_TYPES = %w[note aiSummary].freeze #: ::Array[::String]
11
12
  INVALID_RESPONSE = 'Guesty posts response has an unexpected shape.'.freeze #: ::String
12
13
 
@@ -59,7 +60,16 @@ module Guesty
59
60
  return false if post[:_id].blank? || post[:createdAt].blank?
60
61
  return false if SYSTEM_MODULE_TYPES.include?(post.dig(:module, :type))
61
62
 
62
- SENDERS.include?(post[:sentBy]) && (post[:body].present? || attachments.any?)
63
+ SENDERS.include?(post[:sentBy]) && (body(post).present? || attachments.any?)
64
+ end
65
+
66
+ # A channel post is an email the booking channel sent, such as an Airbnb Resolution Center notice:
67
+ # `body` holds its HTML and `plainTextBody` its text.
68
+ # @rbs (untyped post) -> ::String
69
+ def body(post)
70
+ return post[:plainTextBody].presence || post[:body] || '' if post[:sentBy] == CHANNEL_SENDER
71
+
72
+ post[:body] || ''
63
73
  end
64
74
 
65
75
  # @rbs (untyped post) -> untyped
@@ -71,7 +81,7 @@ module Guesty
71
81
  {
72
82
  provider_message_id: post[:_id],
73
83
  sender_kind: sender_kind(post),
74
- body: post[:body] || '',
84
+ body: body(post),
75
85
  attachments:,
76
86
  attachment_keys: normalize_attachment_keys(raw_attachments),
77
87
  module_type: channel_type(post),
@@ -0,0 +1,55 @@
1
+ module Guesty
2
+ module Reservations
3
+ module Resolutions
4
+ # Airbnb Resolution Center: Guesty lists only closed resolutions, about a day after Airbnb closes them,
5
+ # and filters them by their creation time.
6
+ class Index
7
+ include Guesty::Operation
8
+
9
+ CLOSED_STATE = 'closed'.freeze #: ::String
10
+ INVALID_RESPONSE = 'Guesty resolutions response has an unexpected shape.'.freeze #: ::String
11
+
12
+ # @rbs (reservation_id: ::String, created_at: ::Range[::Time | ::ActiveSupport::TimeWithZone]) -> Dry::Monads::Result[::Array[untyped]]
13
+ def call(reservation_id:, created_at:)
14
+ argument! reservation_id: :required if reservation_id.blank?
15
+ argument! created_at: :invalid unless created_at.is_a?(Range) && created_at.begin && created_at.end
16
+
17
+ body = request(:get, "airbnb-resolutions-center/reservations/#{reservation_id}/resolutions", query(created_at))
18
+
19
+ Success(normalize_response(body))
20
+ end
21
+
22
+ private
23
+
24
+ # @rbs (::Range[::Time | ::ActiveSupport::TimeWithZone] created_at) -> ::Hash[::Symbol, ::String]
25
+ def query(created_at)
26
+ {
27
+ from: created_at.begin.utc.iso8601,
28
+ to: created_at.end.utc.iso8601
29
+ }
30
+ end
31
+
32
+ # @rbs (untyped body) -> ::Array[untyped]
33
+ def normalize_response(body)
34
+ resolutions = body[:resolutions] if body.is_a?(Hash)
35
+ error! INVALID_RESPONSE unless resolutions.is_a?(Array)
36
+
37
+ resolutions.map { |resolution| normalize_resolution(resolution) }
38
+ end
39
+
40
+ # @rbs (untyped resolution) -> untyped
41
+ def normalize_resolution(resolution)
42
+ updated_at = resolution[:airbnbUpdatedAt]
43
+
44
+ {
45
+ external_id: resolution.fetch(:resolutionId),
46
+ state: resolution[:statusName]&.downcase,
47
+ amount_paid: resolution[:totalAmountPaid]&.to_d,
48
+ currency: resolution[:currency],
49
+ closed_at: (Time.iso8601(updated_at) if updated_at.present?)
50
+ }
51
+ end
52
+ end
53
+ end
54
+ end
55
+ end
@@ -1,3 +1,3 @@
1
1
  module Guesty
2
- VERSION = '0.2.0'.freeze
2
+ VERSION = '0.2.2'.freeze
3
3
  end
data/lib/guesty.rb CHANGED
@@ -48,6 +48,7 @@ require_relative 'guesty/reservations/index'
48
48
  require_relative 'guesty/reservations/pre_approve'
49
49
  require_relative 'guesty/reservations/recover'
50
50
  require_relative 'guesty/reservations/relocate'
51
+ require_relative 'guesty/reservations/resolutions/index'
51
52
  require_relative 'guesty/reservations/reviews/extractors/base'
52
53
  require_relative 'guesty/reservations/reviews/extractors/airbnb'
53
54
  require_relative 'guesty/reservations/reviews/extractors/booking_com'
data/sig/guesty.rbs CHANGED
@@ -238,6 +238,23 @@ module Guesty
238
238
  end
239
239
  end
240
240
 
241
+ module Resolutions
242
+ class Index
243
+ CLOSED_STATE: ::String
244
+
245
+ type resolution = {
246
+ external_id: ::String,
247
+ state: ::String?,
248
+ amount_paid: ::BigDecimal?,
249
+ currency: ::String?,
250
+ closed_at: ::Time?
251
+ }
252
+
253
+ def call: (reservation_id: ::String, created_at: ::Range[::Time | ::ActiveSupport::TimeWithZone]) -> ::Dry::Monads::Result[::Array[resolution]]
254
+ alias call! call
255
+ end
256
+ end
257
+
241
258
  module Reviews
242
259
  class Index
243
260
  def call: (since: ::Time, ?skip: ::Integer, ?take: ::Integer) -> ::Dry::Monads::Result[::Array[::Hash[::Symbol, untyped]]]
@@ -294,6 +311,7 @@ module Guesty
294
311
  module Posts
295
312
  class Index
296
313
  LIMIT: ::Integer
314
+ CHANNEL_SENDER: ::String
297
315
 
298
316
  def call: (conversation_id: ::String, ?cursor: ::String?) -> ::Dry::Monads::Result[::Hash[::Symbol, untyped]]
299
317
  alias call! call
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: guesty-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Guestit
@@ -146,6 +146,7 @@ files:
146
146
  - lib/guesty/reservations/pre_approve.rb
147
147
  - lib/guesty/reservations/recover.rb
148
148
  - lib/guesty/reservations/relocate.rb
149
+ - lib/guesty/reservations/resolutions/index.rb
149
150
  - lib/guesty/reservations/reviews/extractors/airbnb.rb
150
151
  - lib/guesty/reservations/reviews/extractors/base.rb
151
152
  - lib/guesty/reservations/reviews/extractors/booking_com.rb