opendoor-partner-sdk-server-ruby 1.2.1.beta.100.1 → 1.2.1.beta.101.1

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: 0423c0791e10cae9e42338ef544e3581acb832b7a8f4e5db0311439be5659f62
4
- data.tar.gz: d14b568991c56e1b55928af48a32ceb8d65cbbd5ecc462378cd7a532a08f5328
3
+ metadata.gz: feb77d4b04a77b7578914a3b471b0f1ccc7844447c4eba51924a01e4a11d8ad6
4
+ data.tar.gz: e37040bd3b5fd69fed99accaaac378bfd8a8cec21622e27ba2ca7af20580a20b
5
5
  SHA512:
6
- metadata.gz: 38c89143230f2c7c0ada4a901528e6c4a21f14e5aea449865ab48f780ea9147a0b70a104b793885d475bad8cf455c2ead2ffa012d492e0a2928d6c1bd86544b4
7
- data.tar.gz: af663e203b54a9bac9b91809015718ec1d1de65760ab33359a9e9ffa5234912afea2a4a267a0b28f5b122d5ced311177ffe7bf7dac10e03899da2790e851e9f9
6
+ metadata.gz: 670480628011e6d732825d0d8527bab7be967319b122116c5f42a55db6ddc49e16fa7b60035d7e3d813baab130a2a8c768e4cfdc2c46ee3eb1e76da97f9f6c49
7
+ data.tar.gz: a08d3c269c2f0deb2011d3580a57c03d2038acac329260494ca5d2e6cb6963c21c871589a01c489539a6ffb86d9b324fbd984f68a75c3744418a96be5611d1cd
@@ -219,41 +219,23 @@ module Opendoor
219
219
  def get_assessment_slots(offer_id:, calendar_type: "ASSESSMENT_VISIT")
220
220
  raise ValidationError.new("offerId is required", "offerId") if blank?(offer_id)
221
221
 
222
- # The /v2/* REST routes are served by the cloudflare-worker on the
223
- # *address* domain (demo.simplersell.com staging / www.opendoor.com prod),
224
- # not the partnership-bff GraphQL host. They live under /partner-api-proxy/*.
225
- api_base = address_endpoint_origin
226
- url = "#{api_base}/partner-api-proxy/v2/exterior_assessment_slots"
227
- log("REST POST -> #{url}")
228
-
229
- response = fetch_with_timeout(
230
- url,
231
- method: :post,
232
- headers: {
233
- "Content-Type" => "application/json",
234
- "Authorization" => "Basic #{@api_key}"
235
- },
236
- body: JSON.generate(
237
- partnerId: @api_key,
222
+ data = graphql(
223
+ query: Graphql::EXTERIOR_ASSESSMENT_SLOTS_QUERY,
224
+ variables: {
238
225
  sellerInputUuid: offer_id,
239
226
  # Default: pre-UW assessment (the post-IFO Lennar Trade-In path).
240
227
  # "DILIGENCE_VISIT" is the post-contract Inspectify visit.
241
228
  calendarType: calendar_type
242
- )
229
+ }
243
230
  )
244
- ensure_ok!(response, "Assessment slots request failed", "NETWORK_ERROR")
245
- raw = parse_json_response(response.body, http_status: response.code.to_i)
246
-
247
- unless raw["success"]
248
- raise ApiError.new(raw["error"] || "Assessment slots request failed", "API_ERROR", 200)
249
- end
250
231
 
232
+ slots = data["exteriorAssessmentSlots"] || {}
251
233
  {
252
- currentInspectionTime: raw["currentInspectionTime"],
253
- availableSlots: raw["availableSlots"] || [],
254
- isSlotBased: raw["isSlotBased"] || false,
255
- visitId: raw["visitId"] || "",
256
- timezone: raw["timezone"] || "UTC"
234
+ currentInspectionTime: slots["currentInspectionTime"],
235
+ availableSlots: slots["availableSlots"] || [],
236
+ isSlotBased: slots["isSlotBased"] || false,
237
+ visitId: slots["visitId"] || "",
238
+ timezone: slots["timezone"] || "UTC"
257
239
  }
258
240
  end
259
241
 
@@ -435,25 +417,6 @@ module Opendoor
435
417
  value.nil? || value.to_s.strip.empty?
436
418
  end
437
419
 
438
- # Same-origin base as JS `new URL(apiEndpoint).origin` (includes non-default port).
439
- def graphql_api_origin
440
- uri_origin(@api_endpoint)
441
- end
442
-
443
- # Cloudflare-worker origin (where /partner-api-proxy/v2/* routes live).
444
- def address_endpoint_origin
445
- uri_origin(@address_endpoint)
446
- end
447
-
448
- def uri_origin(endpoint)
449
- uri = URI.parse(endpoint)
450
- if uri.respond_to?(:origin) && !uri.origin.nil?
451
- uri.origin
452
- else
453
- "#{uri.scheme}://#{uri.host}#{uri.port && ![80, 443].include?(uri.port) ? ":#{uri.port}" : ""}"
454
- end
455
- end
456
-
457
420
  def parse_json_response(body, http_status:)
458
421
  JSON.parse(body.to_s)
459
422
  rescue JSON::ParserError => e
@@ -169,6 +169,21 @@ module Opendoor
169
169
  }
170
170
  }
171
171
  GRAPHQL
172
+
173
+ # `calendarType` is "ASSESSMENT_VISIT" for the pre-underwriting home
174
+ # assessment (post-IFO Lennar Trade-In path) or "DILIGENCE_VISIT" for
175
+ # the post-contract Inspectify visit.
176
+ EXTERIOR_ASSESSMENT_SLOTS_QUERY = <<~GRAPHQL.freeze
177
+ query ExteriorAssessmentSlots($sellerInputUuid: String!, $calendarType: CalendarType!) {
178
+ exteriorAssessmentSlots(sellerInputUuid: $sellerInputUuid, calendarType: $calendarType) {
179
+ timezone
180
+ availableSlots
181
+ currentInspectionTime
182
+ isSlotBased
183
+ visitId
184
+ }
185
+ }
186
+ GRAPHQL
172
187
  end
173
188
  end
174
189
  end
@@ -1,5 +1,5 @@
1
1
  module Opendoor
2
2
  module PartnerSdk
3
- VERSION = "1.2.1.beta.100.1"
3
+ VERSION = "1.2.1.beta.101.1"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: opendoor-partner-sdk-server-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.1.beta.100.1
4
+ version: 1.2.1.beta.101.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Opendoor