Skip to content

Commit ed81fb5

Browse files
authored
New Components - domain_group (#15932)
* new components * pnpm-lock.yaml
1 parent d0c1e1b commit ed81fb5

File tree

11 files changed

+1237
-8
lines changed

11 files changed

+1237
-8
lines changed
Lines changed: 157 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
1+
import domainGroup from "../../domain_group.app.mjs";
2+
import { BUSINESS_TYPES } from "../../common/property-types.mjs";
3+
4+
export default {
5+
key: "domain_group-create-business-listing",
6+
name: "Create Business Listing",
7+
description: "Creates a new business listing. [See the documentation](https://developer.domain.com.au/docs/latest/apis/pkg_listing_management/references/listings_upsertbusinesslisting/).",
8+
version: "0.0.1",
9+
type: "action",
10+
props: {
11+
domainGroup,
12+
agencyId: {
13+
propDefinition: [
14+
domainGroup,
15+
"agencyId",
16+
],
17+
},
18+
providerAdId: {
19+
propDefinition: [
20+
domainGroup,
21+
"providerAdId",
22+
],
23+
},
24+
propertyType: {
25+
propDefinition: [
26+
domainGroup,
27+
"propertyType",
28+
],
29+
options: BUSINESS_TYPES,
30+
},
31+
listingAction: {
32+
propDefinition: [
33+
domainGroup,
34+
"listingAction",
35+
],
36+
},
37+
underOfferOrContract: {
38+
propDefinition: [
39+
domainGroup,
40+
"underOfferOrContract",
41+
],
42+
},
43+
nabers: {
44+
propDefinition: [
45+
domainGroup,
46+
"nabers",
47+
],
48+
},
49+
fromPrice: {
50+
propDefinition: [
51+
domainGroup,
52+
"fromPrice",
53+
],
54+
},
55+
toPrice: {
56+
propDefinition: [
57+
domainGroup,
58+
"toPrice",
59+
],
60+
},
61+
description: {
62+
propDefinition: [
63+
domainGroup,
64+
"description",
65+
],
66+
},
67+
features: {
68+
propDefinition: [
69+
domainGroup,
70+
"features",
71+
],
72+
},
73+
streetNumber: {
74+
propDefinition: [
75+
domainGroup,
76+
"streetNumber",
77+
],
78+
},
79+
unitNumber: {
80+
propDefinition: [
81+
domainGroup,
82+
"unitNumber",
83+
],
84+
},
85+
street: {
86+
propDefinition: [
87+
domainGroup,
88+
"street",
89+
],
90+
},
91+
state: {
92+
propDefinition: [
93+
domainGroup,
94+
"state",
95+
],
96+
},
97+
suburb: {
98+
propDefinition: [
99+
domainGroup,
100+
"suburb",
101+
],
102+
},
103+
postcode: {
104+
propDefinition: [
105+
domainGroup,
106+
"postcode",
107+
],
108+
},
109+
receiveEmailsToDefaultAddress: {
110+
propDefinition: [
111+
domainGroup,
112+
"receiveEmailsToDefaultAddress",
113+
],
114+
},
115+
isRural: {
116+
propDefinition: [
117+
domainGroup,
118+
"isRural",
119+
],
120+
},
121+
},
122+
async run({ $ }) {
123+
const response = await this.domainGroup.createBusinessListing({
124+
$,
125+
data: {
126+
domainAgencyID: this.agencyId,
127+
providerAdId: this.providerAdId,
128+
listingAction: this.listingAction,
129+
underOfferOrContract: this.underOfferOrContract,
130+
nabers: this.nabers && +this.nabers,
131+
price: {
132+
from: this.fromPrice,
133+
to: this.toPrice,
134+
},
135+
description: this.description,
136+
features: this.features,
137+
propertyDetails: {
138+
propertyType: [
139+
this.propertyType,
140+
],
141+
address: {
142+
streetNumber: this.streetNumber,
143+
unitNumber: this.unitNumber,
144+
street: this.street,
145+
state: this.state,
146+
suburb: this.suburb,
147+
postcode: this.postcode,
148+
},
149+
},
150+
receiveEmailsToDefaultAddress: this.receiveEmailsToDefaultAddress,
151+
isRural: this.isRural,
152+
},
153+
});
154+
$.export("$summary", `Created business listing with ID: ${response.id}`);
155+
return response;
156+
},
157+
};
Lines changed: 231 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,231 @@
1+
import domainGroup from "../../domain_group.app.mjs";
2+
import { COMMERCIAL_TYPES } from "../../common/property-types.mjs";
3+
4+
export default {
5+
key: "domain_group-create-commercial-listing",
6+
name: "Create Commercial Listing",
7+
description: "Creates a new commercial listing. [See the documentation](https://developer.domain.com.au/docs/latest/apis/pkg_listing_management/references/listings_upsertcommerciallisting/).",
8+
version: "0.0.1",
9+
type: "action",
10+
props: {
11+
domainGroup,
12+
agencyId: {
13+
propDefinition: [
14+
domainGroup,
15+
"agencyId",
16+
],
17+
},
18+
providerAdId: {
19+
propDefinition: [
20+
domainGroup,
21+
"providerAdId",
22+
],
23+
},
24+
propertyType: {
25+
propDefinition: [
26+
domainGroup,
27+
"propertyType",
28+
],
29+
options: COMMERCIAL_TYPES,
30+
},
31+
listingAction: {
32+
propDefinition: [
33+
domainGroup,
34+
"listingAction",
35+
],
36+
reloadProps: true,
37+
},
38+
underOfferOrContract: {
39+
propDefinition: [
40+
domainGroup,
41+
"underOfferOrContract",
42+
],
43+
},
44+
nabers: {
45+
propDefinition: [
46+
domainGroup,
47+
"nabers",
48+
],
49+
},
50+
description: {
51+
propDefinition: [
52+
domainGroup,
53+
"description",
54+
],
55+
},
56+
features: {
57+
propDefinition: [
58+
domainGroup,
59+
"features",
60+
],
61+
},
62+
streetNumber: {
63+
propDefinition: [
64+
domainGroup,
65+
"streetNumber",
66+
],
67+
},
68+
unitNumber: {
69+
propDefinition: [
70+
domainGroup,
71+
"unitNumber",
72+
],
73+
},
74+
street: {
75+
propDefinition: [
76+
domainGroup,
77+
"street",
78+
],
79+
},
80+
state: {
81+
propDefinition: [
82+
domainGroup,
83+
"state",
84+
],
85+
},
86+
suburb: {
87+
propDefinition: [
88+
domainGroup,
89+
"suburb",
90+
],
91+
},
92+
postcode: {
93+
propDefinition: [
94+
domainGroup,
95+
"postcode",
96+
],
97+
},
98+
areaValue: {
99+
type: "string",
100+
label: "Area Value",
101+
description: "The size of the area in the commercial listing",
102+
},
103+
areaUnit: {
104+
type: "string",
105+
label: "Area Unit",
106+
description: "The unit of measure of the area value",
107+
options: [
108+
"squareMetres",
109+
"acres",
110+
"hectares",
111+
"squareFeet",
112+
"squareYards",
113+
"squares",
114+
],
115+
},
116+
receiveEmailsToDefaultAddress: {
117+
propDefinition: [
118+
domainGroup,
119+
"receiveEmailsToDefaultAddress",
120+
],
121+
},
122+
isRural: {
123+
propDefinition: [
124+
domainGroup,
125+
"isRural",
126+
],
127+
},
128+
occupancyType: {
129+
type: "string",
130+
label: "Occupancy Type",
131+
description: "The occupancy type of the listing",
132+
options: [
133+
"tenanted",
134+
"vacant",
135+
],
136+
optional: true,
137+
},
138+
},
139+
additionalProps() {
140+
const props = {};
141+
if (!this.listingAction) {
142+
return props;
143+
}
144+
145+
const saleFromPrice = {
146+
type: "integer",
147+
label: "Sale - From Price",
148+
description: "Lowest price the property is expected to sell for to set search price. For a fixed price, set this value the same as To Price",
149+
};
150+
const saleToPrice = {
151+
type: "integer",
152+
label: "Sale - To Price",
153+
description: "Highest price the property is expected to sell for to set search price. For a fixed price, set this value the same as From Price",
154+
};
155+
const leaseFromPrice = {
156+
type: "integer",
157+
label: "Lease - From Price",
158+
description: "Lowest price the property is expected to rent for to set search price. For a fixed price, set this value the same as To Price",
159+
};
160+
const leaseToPrice = {
161+
type: "integer",
162+
label: "Lease - To Price",
163+
description: "Highest price the property is expected to rent for to set search price. For a fixed price, set this value the same as From Price",
164+
};
165+
166+
if (this.listingAction === "sale") {
167+
props.saleFromPrice = saleFromPrice;
168+
props.saleToPrice = saleToPrice;
169+
}
170+
if (this.listingAction === "rent") {
171+
props.leaseFromPrice = leaseFromPrice;
172+
props.leaseToPrice = leaseToPrice;
173+
}
174+
if (this.listingAction === "saleAndLease") {
175+
props.saleFromPrice = saleFromPrice;
176+
props.saleToPrice = saleToPrice;
177+
props.leaseFromPrice = leaseFromPrice;
178+
props.leaseToPrice = leaseToPrice;
179+
}
180+
181+
return props;
182+
},
183+
async run({ $ }) {
184+
const response = await this.domainGroup.createCommercialListing({
185+
$,
186+
data: {
187+
domainAgencyID: this.agencyId,
188+
providerAdId: this.providerAdId,
189+
nabers: this.nabers,
190+
listingAction: this.listingAction,
191+
underOfferOrContract: this.underOfferOrContract,
192+
salePrice: this.saleFromPrice
193+
? {
194+
from: this.saleFromPrice,
195+
to: this.saleToPrice,
196+
}
197+
: undefined,
198+
leasePrice: this.leaseFromPrice
199+
? {
200+
from: this.leaseFromPrice,
201+
to: this.leaseToPrice,
202+
}
203+
: undefined,
204+
description: this.description,
205+
features: this.features,
206+
propertyDetails: {
207+
propertyType: [
208+
this.propertyType,
209+
],
210+
address: {
211+
streetNumber: this.streetNumber,
212+
unitNumber: this.unitNumber,
213+
street: this.street,
214+
state: this.state,
215+
suburb: this.suburb,
216+
postcode: this.postcode,
217+
},
218+
area: {
219+
value: +this.areaValue,
220+
unit: this.areaUnit,
221+
},
222+
},
223+
receiveEmailsToDefaultAddress: this.receiveEmailsToDefaultAddress,
224+
isRural: this.isRural,
225+
occupancyType: this.occupancyType,
226+
},
227+
});
228+
$.export("$summary", `Created commercial listing with ID: ${response.id}`);
229+
return response;
230+
},
231+
};

0 commit comments

Comments
 (0)