opendoor-partner-sdk-server-ruby 1.3.9.beta.139.1 → 1.3.9.beta.141.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:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 6d7440b7a017705de0d34dc1f8dc7984068a553a067534e487e40a39010a2174
|
|
4
|
+
data.tar.gz: ef7b40035269977aa211f39ccd678f6e802565aaebc307d41a4873f0792bd20e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 9b6d2c0b3fc15d400f8f127cb462169711450c09898db63870a4b6092d4c2f0a2d6576bdf7e5ca5ca3975797d593bc464368c3adcc874b25092833c13f1875fd
|
|
7
|
+
data.tar.gz: 430d449f32bd9ccad1c5b23596a5e5678773c8d40b4a9ab17d48c94d7363a11aaab26b05cf0c4ac1bbd1758272497617ab0657cfce0132662c09a0fe39400eb3
|
|
@@ -85,6 +85,22 @@ module Opendoor
|
|
|
85
85
|
{ addresses: addresses }
|
|
86
86
|
end
|
|
87
87
|
|
|
88
|
+
# Submit a stable participant plan for an address-only request. API enablement is required.
|
|
89
|
+
def submit_offer(offer_id:, data:)
|
|
90
|
+
normalized = normalize_participant_data(data)
|
|
91
|
+
normalized = Validators.validate_participant_submission(offer_id, normalized)
|
|
92
|
+
result = graphql(query: Graphql::OFFER_REQUEST_SUBMIT,
|
|
93
|
+
variables: { params: normalized.merge("opendoorOfferRequestId" => offer_id) })
|
|
94
|
+
participant_setup_result(result.fetch("offerRequestSubmit"))
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
# Read setup progress separately from pricing and live email delivery.
|
|
98
|
+
def get_offer_submission(offer_id:)
|
|
99
|
+
raise ValidationError.new("offerId is required", "offerId") if blank?(offer_id)
|
|
100
|
+
result = graphql(query: Graphql::OFFER_SUBMISSION_STATUS, variables: { id: offer_id })
|
|
101
|
+
participant_setup_result(result.fetch("offerRequest"))
|
|
102
|
+
end
|
|
103
|
+
|
|
88
104
|
def create_offer(data:)
|
|
89
105
|
Validators.validate_create_offer_request(data)
|
|
90
106
|
address = get(data, :address)
|
|
@@ -310,6 +326,24 @@ module Opendoor
|
|
|
310
326
|
|
|
311
327
|
private
|
|
312
328
|
|
|
329
|
+
def participant_setup_result(request)
|
|
330
|
+
setup = request.fetch("participantSetup")
|
|
331
|
+
raise ApiError.new("No participant plan has been submitted", "NOT_FOUND", 404) if setup.nil?
|
|
332
|
+
symbolize_keys({ "opendoorOfferRequestId" => request.fetch("opendoorOfferRequestId"),
|
|
333
|
+
"state" => setup.fetch("status"), "participants" => setup.fetch("participants") })
|
|
334
|
+
end
|
|
335
|
+
|
|
336
|
+
def normalize_participant_data(value)
|
|
337
|
+
case value
|
|
338
|
+
when Hash
|
|
339
|
+
value.to_h { |key, item| [key.to_s.gsub(/_([a-z])/) { Regexp.last_match(1).upcase }, normalize_participant_data(item)] }
|
|
340
|
+
when Array
|
|
341
|
+
value.map { |item| normalize_participant_data(item) }
|
|
342
|
+
else
|
|
343
|
+
value
|
|
344
|
+
end
|
|
345
|
+
end
|
|
346
|
+
|
|
313
347
|
def resolve_prediction(prediction, session_token)
|
|
314
348
|
if prediction["street"] && prediction["city"] && prediction["state"] && prediction["postalCode"]
|
|
315
349
|
return {
|
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
module Opendoor
|
|
2
2
|
module PartnerSdk
|
|
3
3
|
module Graphql
|
|
4
|
+
OFFER_REQUEST_SUBMIT = <<~GRAPHQL.freeze
|
|
5
|
+
mutation SubmitPartnerOffer($params: OfferRequestSubmitInput!) {
|
|
6
|
+
offerRequestSubmit(params: $params) { opendoorOfferRequestId participantSetup { status participants { ref state } } }
|
|
7
|
+
}
|
|
8
|
+
GRAPHQL
|
|
9
|
+
OFFER_SUBMISSION_STATUS = <<~GRAPHQL.freeze
|
|
10
|
+
query PartnerOfferSubmission($id: String!) {
|
|
11
|
+
offerRequest(opendoorOfferRequestId: $id) { opendoorOfferRequestId participantSetup { status participants { ref state } } }
|
|
12
|
+
}
|
|
13
|
+
GRAPHQL
|
|
4
14
|
OFFER_REQUEST_CREATE = <<~GRAPHQL.freeze
|
|
5
15
|
mutation OfferRequestCreate($offerRequestCreateInput: OfferRequestCreateInput!) {
|
|
6
16
|
offerRequestCreate(params: $offerRequestCreateInput) {
|
|
@@ -33,6 +33,60 @@ module Opendoor
|
|
|
33
33
|
) if data.empty?
|
|
34
34
|
end
|
|
35
35
|
|
|
36
|
+
def validate_participant_submission(offer_id, data)
|
|
37
|
+
raise ValidationError.new("offerId is required") if blank?(offer_id)
|
|
38
|
+
unless data.is_a?(Hash) && !blank?(data["idempotencyKey"]) && data["idempotencyKey"].length <= 128
|
|
39
|
+
raise ValidationError.new("An idempotencyKey of at most 128 characters is required")
|
|
40
|
+
end
|
|
41
|
+
people = data["participants"]
|
|
42
|
+
unless people.is_a?(Array) && (1..2).cover?(people.length)
|
|
43
|
+
raise ValidationError.new("Supply one or two participants")
|
|
44
|
+
end
|
|
45
|
+
refs, emails, participants = [], [], []
|
|
46
|
+
people.each do |person|
|
|
47
|
+
unless person.is_a?(Hash) && person["ref"].is_a?(String) && person["ref"].match?(/\A[A-Za-z0-9_-]{1,128}\z/) && !refs.include?(person["ref"])
|
|
48
|
+
raise ValidationError.new("Participant references must be unique and nonempty")
|
|
49
|
+
end
|
|
50
|
+
email = person["email"].to_s.strip.downcase
|
|
51
|
+
if blank?(person["fullName"]) || !valid_participant_email?(email) || emails.include?(email)
|
|
52
|
+
raise ValidationError.new("Each person needs a name and a unique email")
|
|
53
|
+
end
|
|
54
|
+
roles = person["roles"]
|
|
55
|
+
unless roles.is_a?(Array) && !roles.empty? && roles.uniq == roles && (roles - %w[SELLER SELLER_AGENT]).empty?
|
|
56
|
+
raise ValidationError.new("Each person needs valid, unique roles")
|
|
57
|
+
end
|
|
58
|
+
raise ValidationError.new("Invitation timing is not configurable") if person.key?("activation")
|
|
59
|
+
refs << person["ref"]; emails << email
|
|
60
|
+
participants << person.merge("email" => email)
|
|
61
|
+
end
|
|
62
|
+
sellers = people.select { |person| person["roles"].include?("SELLER") }
|
|
63
|
+
agents = people.select { |person| person["roles"].include?("SELLER_AGENT") }
|
|
64
|
+
if sellers.length > 1 || agents.length > 1 || !refs.include?(data["primaryParticipantRef"])
|
|
65
|
+
raise ValidationError.new("Choose supplied people for seller, agent, and main contact")
|
|
66
|
+
end
|
|
67
|
+
rep = data["representation"]
|
|
68
|
+
if agents.any?
|
|
69
|
+
unless rep.is_a?(Hash) && rep["agentRef"] == agents.first["ref"] && [true, false].include?(rep["signedListingAgreement"]) &&
|
|
70
|
+
(sellers.empty? ? blank?(rep["sellerRef"]) : rep["sellerRef"] == sellers.first["ref"])
|
|
71
|
+
raise ValidationError.new("Representation must reference the supplied agent and seller")
|
|
72
|
+
end
|
|
73
|
+
elsif rep
|
|
74
|
+
raise ValidationError.new("Representation requires an agent")
|
|
75
|
+
end
|
|
76
|
+
(data["homeDetails"] || {}).each_key do |key|
|
|
77
|
+
raise ValidationError.new("Contact fields belong in participants") unless key.start_with?("home") || key == "sellerSaleTimeline"
|
|
78
|
+
end
|
|
79
|
+
data.merge("participants" => participants)
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
def valid_participant_email?(email)
|
|
83
|
+
return false if email.length > 254 || email.match?(/\s/)
|
|
84
|
+
parts = email.split("@", -1)
|
|
85
|
+
return false unless parts.length == 2
|
|
86
|
+
local, domain = parts
|
|
87
|
+
!local.empty? && !domain.empty? && domain.include?(".") && !domain.start_with?(".") && !domain.end_with?(".")
|
|
88
|
+
end
|
|
89
|
+
|
|
36
90
|
def blank?(value)
|
|
37
91
|
value.nil? || value.to_s.strip.empty?
|
|
38
92
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: opendoor-partner-sdk-server-ruby
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.3.9.beta.
|
|
4
|
+
version: 1.3.9.beta.141.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Opendoor
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-
|
|
11
|
+
date: 2026-11-02 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: minitest
|