Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
import domainGroup from "../../domain_group.app.mjs";
import { BUSINESS_TYPES } from "../../common/property-types.mjs";

export default {
key: "domain_group-create-business-listing",
name: "Create Business Listing",
description: "Creates a new business listing. [See the documentation](https://developer.domain.com.au/docs/latest/apis/pkg_listing_management/references/listings_upsertbusinesslisting/).",
version: "0.0.1",
type: "action",
props: {
domainGroup,
agencyId: {
propDefinition: [
domainGroup,
"agencyId",
],
},
providerAdId: {
propDefinition: [
domainGroup,
"providerAdId",
],
},
propertyType: {
propDefinition: [
domainGroup,
"propertyType",
],
options: BUSINESS_TYPES,
},
listingAction: {
propDefinition: [
domainGroup,
"listingAction",
],
},
underOfferOrContract: {
propDefinition: [
domainGroup,
"underOfferOrContract",
],
},
nabers: {
propDefinition: [
domainGroup,
"nabers",
],
},
fromPrice: {
propDefinition: [
domainGroup,
"fromPrice",
],
},
toPrice: {
propDefinition: [
domainGroup,
"toPrice",
],
},
description: {
propDefinition: [
domainGroup,
"description",
],
},
features: {
propDefinition: [
domainGroup,
"features",
],
},
streetNumber: {
propDefinition: [
domainGroup,
"streetNumber",
],
},
unitNumber: {
propDefinition: [
domainGroup,
"unitNumber",
],
},
street: {
propDefinition: [
domainGroup,
"street",
],
},
state: {
propDefinition: [
domainGroup,
"state",
],
},
suburb: {
propDefinition: [
domainGroup,
"suburb",
],
},
postcode: {
propDefinition: [
domainGroup,
"postcode",
],
},
receiveEmailsToDefaultAddress: {
propDefinition: [
domainGroup,
"receiveEmailsToDefaultAddress",
],
},
isRural: {
propDefinition: [
domainGroup,
"isRural",
],
},
},
async run({ $ }) {
const response = await this.domainGroup.createBusinessListing({
$,
data: {
domainAgencyID: this.agencyId,
providerAdId: this.providerAdId,
listingAction: this.listingAction,
underOfferOrContract: this.underOfferOrContract,
nabers: this.nabers && +this.nabers,
price: {
from: this.fromPrice,
to: this.toPrice,
},
description: this.description,
features: this.features,
propertyDetails: {
propertyType: [
this.propertyType,
],
address: {
streetNumber: this.streetNumber,
unitNumber: this.unitNumber,
street: this.street,
state: this.state,
suburb: this.suburb,
postcode: this.postcode,
},
},
receiveEmailsToDefaultAddress: this.receiveEmailsToDefaultAddress,
isRural: this.isRural,
},
});
$.export("$summary", `Created business listing with ID: ${response.id}`);
return response;
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,231 @@
import domainGroup from "../../domain_group.app.mjs";
import { COMMERCIAL_TYPES } from "../../common/property-types.mjs";

export default {
key: "domain_group-create-commercial-listing",
name: "Create Commercial Listing",
description: "Creates a new commercial listing. [See the documentation](https://developer.domain.com.au/docs/latest/apis/pkg_listing_management/references/listings_upsertcommerciallisting/).",
version: "0.0.1",
type: "action",
props: {
domainGroup,
agencyId: {
propDefinition: [
domainGroup,
"agencyId",
],
},
providerAdId: {
propDefinition: [
domainGroup,
"providerAdId",
],
},
propertyType: {
propDefinition: [
domainGroup,
"propertyType",
],
options: COMMERCIAL_TYPES,
},
listingAction: {
propDefinition: [
domainGroup,
"listingAction",
],
reloadProps: true,
},
underOfferOrContract: {
propDefinition: [
domainGroup,
"underOfferOrContract",
],
},
nabers: {
propDefinition: [
domainGroup,
"nabers",
],
},
description: {
propDefinition: [
domainGroup,
"description",
],
},
features: {
propDefinition: [
domainGroup,
"features",
],
},
streetNumber: {
propDefinition: [
domainGroup,
"streetNumber",
],
},
unitNumber: {
propDefinition: [
domainGroup,
"unitNumber",
],
},
street: {
propDefinition: [
domainGroup,
"street",
],
},
state: {
propDefinition: [
domainGroup,
"state",
],
},
suburb: {
propDefinition: [
domainGroup,
"suburb",
],
},
postcode: {
propDefinition: [
domainGroup,
"postcode",
],
},
areaValue: {
type: "string",
label: "Area Value",
description: "The size of the area in the commercial listing",
},
areaUnit: {
type: "string",
label: "Area Unit",
description: "The unit of measure of the area value",
options: [
"squareMetres",
"acres",
"hectares",
"squareFeet",
"squareYards",
"squares",
],
},
receiveEmailsToDefaultAddress: {
propDefinition: [
domainGroup,
"receiveEmailsToDefaultAddress",
],
},
isRural: {
propDefinition: [
domainGroup,
"isRural",
],
},
occupancyType: {
type: "string",
label: "Occupancy Type",
description: "The occupancy type of the listing",
options: [
"tenanted",
"vacant",
],
optional: true,
},
},
additionalProps() {
const props = {};
if (!this.listingAction) {
return props;
}

const saleFromPrice = {
type: "integer",
label: "Sale - From Price",
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",
};
const saleToPrice = {
type: "integer",
label: "Sale - To Price",
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",
};
const leaseFromPrice = {
type: "integer",
label: "Lease - From Price",
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",
};
const leaseToPrice = {
type: "integer",
label: "Lease - To Price",
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",
};

if (this.listingAction === "sale") {
props.saleFromPrice = saleFromPrice;
props.saleToPrice = saleToPrice;
}
if (this.listingAction === "rent") {
props.leaseFromPrice = leaseFromPrice;
props.leaseToPrice = leaseToPrice;
}
if (this.listingAction === "saleAndLease") {
props.saleFromPrice = saleFromPrice;
props.saleToPrice = saleToPrice;
props.leaseFromPrice = leaseFromPrice;
props.leaseToPrice = leaseToPrice;
}

return props;
},
async run({ $ }) {
const response = await this.domainGroup.createCommercialListing({
$,
data: {
domainAgencyID: this.agencyId,
providerAdId: this.providerAdId,
nabers: this.nabers,
listingAction: this.listingAction,
underOfferOrContract: this.underOfferOrContract,
salePrice: this.saleFromPrice
? {
from: this.saleFromPrice,
to: this.saleToPrice,
}
: undefined,
leasePrice: this.leaseFromPrice
? {
from: this.leaseFromPrice,
to: this.leaseToPrice,
}
: undefined,
description: this.description,
features: this.features,
propertyDetails: {
propertyType: [
this.propertyType,
],
address: {
streetNumber: this.streetNumber,
unitNumber: this.unitNumber,
street: this.street,
state: this.state,
suburb: this.suburb,
postcode: this.postcode,
},
area: {
value: +this.areaValue,
unit: this.areaUnit,
},
},
receiveEmailsToDefaultAddress: this.receiveEmailsToDefaultAddress,
isRural: this.isRural,
occupancyType: this.occupancyType,
},
});
$.export("$summary", `Created commercial listing with ID: ${response.id}`);
return response;
},
};
Loading
Loading