Platform API

<back to all web services

GetSuburbs

Get all suburbs for the specified country, state and/or postcode

The following routes are available for this service:
All Verbs/api/suburbs
<?php namespace dtos;

use DateTime;
use Exception;
use DateInterval;
use JsonSerializable;
use ServiceStack\{IReturn,IReturnVoid,IGet,IPost,IPut,IDelete,IPatch,IMeta,IHasSessionId,IHasBearerToken,IHasVersion};
use ServiceStack\{ICrud,ICreateDb,IUpdateDb,IPatchDb,IDeleteDb,ISaveDb,AuditBase,QueryDb,QueryDb2,QueryData,QueryData2,QueryResponse};
use ServiceStack\{ResponseStatus,ResponseError,EmptyResponse,IdResponse,ArrayList,KeyValuePair2,StringResponse,StringsResponse,Tuple2,Tuple3,ByteArray};
use ServiceStack\{JsonConverters,Returns,TypeContext};


class SuburbModel implements JsonSerializable
{
    public function __construct(
        /** @var string */
        public string $SuburbId='',
        /** @var string|null */
        public ?string $Name=null,
        /** @var string */
        public string $StateId='',
        /** @var string|null */
        public ?string $StateName=null,
        /** @var string|null */
        public ?string $PostCode=null,
        /** @var string */
        public string $CountryId='',
        /** @var string|null */
        public ?string $CountryName=null
    ) {
    }

    /** @throws Exception */
    public function fromMap($o): void {
        if (isset($o['SuburbId'])) $this->SuburbId = $o['SuburbId'];
        if (isset($o['Name'])) $this->Name = $o['Name'];
        if (isset($o['StateId'])) $this->StateId = $o['StateId'];
        if (isset($o['StateName'])) $this->StateName = $o['StateName'];
        if (isset($o['PostCode'])) $this->PostCode = $o['PostCode'];
        if (isset($o['CountryId'])) $this->CountryId = $o['CountryId'];
        if (isset($o['CountryName'])) $this->CountryName = $o['CountryName'];
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        if (isset($this->SuburbId)) $o['SuburbId'] = $this->SuburbId;
        if (isset($this->Name)) $o['Name'] = $this->Name;
        if (isset($this->StateId)) $o['StateId'] = $this->StateId;
        if (isset($this->StateName)) $o['StateName'] = $this->StateName;
        if (isset($this->PostCode)) $o['PostCode'] = $this->PostCode;
        if (isset($this->CountryId)) $o['CountryId'] = $this->CountryId;
        if (isset($this->CountryName)) $o['CountryName'] = $this->CountryName;
        return empty($o) ? new class(){} : $o;
    }
}

// @ApiResponse(Description="List of suburbs matching the criteria")
class GetSuburbsResponse implements JsonSerializable
{
    public function __construct(
        /** @var array<SuburbModel>|null */
        public ?array $Suburbs=null,
        /** @var ResponseStatus|null */
        public ?ResponseStatus $ResponseStatus=null
    ) {
    }

    /** @throws Exception */
    public function fromMap($o): void {
        if (isset($o['Suburbs'])) $this->Suburbs = JsonConverters::fromArray('SuburbModel', $o['Suburbs']);
        if (isset($o['ResponseStatus'])) $this->ResponseStatus = JsonConverters::from('ResponseStatus', $o['ResponseStatus']);
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        if (isset($this->Suburbs)) $o['Suburbs'] = JsonConverters::toArray('SuburbModel', $this->Suburbs);
        if (isset($this->ResponseStatus)) $o['ResponseStatus'] = JsonConverters::to('ResponseStatus', $this->ResponseStatus);
        return empty($o) ? new class(){} : $o;
    }
}

/** @description Get all suburbs for the specified country, state and/or postcode */
// @Api(Description="Get all suburbs for the specified country, state and/or postcode")
class GetSuburbs implements JsonSerializable
{
    public function __construct(
        /** @description Get suburbs matching the specified search text criteria. */
        // @ApiMember(Description="Get suburbs matching the specified search text criteria.", Name="SearchText")
        /** @var string|null */
        public ?string $SearchText=null,

        /** @description State to get suburbs for */
        // @ApiMember(Description="State to get suburbs for", Name="StateName")
        /** @var string|null */
        public ?string $StateName=null,

        /** @description Postcode to get suburbs for */
        // @ApiMember(Description="Postcode to get suburbs for", Name="Postcode")
        /** @var string|null */
        public ?string $PostCode=null,

        /** @description Country to get suburbs for */
        // @ApiMember(Description="Country to get suburbs for", Name="CountryId")
        /** @var string */
        public string $CountryId='',

        /** @description Country to get suburbs for */
        // @ApiMember(Description="Country to get suburbs for", Name="CountryName")
        /** @var string|null */
        public ?string $CountryName=null
    ) {
    }

    /** @throws Exception */
    public function fromMap($o): void {
        if (isset($o['SearchText'])) $this->SearchText = $o['SearchText'];
        if (isset($o['StateName'])) $this->StateName = $o['StateName'];
        if (isset($o['PostCode'])) $this->PostCode = $o['PostCode'];
        if (isset($o['CountryId'])) $this->CountryId = $o['CountryId'];
        if (isset($o['CountryName'])) $this->CountryName = $o['CountryName'];
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        if (isset($this->SearchText)) $o['SearchText'] = $this->SearchText;
        if (isset($this->StateName)) $o['StateName'] = $this->StateName;
        if (isset($this->PostCode)) $o['PostCode'] = $this->PostCode;
        if (isset($this->CountryId)) $o['CountryId'] = $this->CountryId;
        if (isset($this->CountryName)) $o['CountryName'] = $this->CountryName;
        return empty($o) ? new class(){} : $o;
    }
}

PHP GetSuburbs DTOs

To override the Content-type in your clients, use the HTTP Accept Header, append the .json suffix or ?format=json

To embed the response in a jsonp callback, append ?callback=myCallback

HTTP + JSON

The following are sample HTTP requests and responses. The placeholders shown need to be replaced with actual values.

POST /api/suburbs HTTP/1.1 
Host: pfapi.pstpf.com.au 
Accept: application/json
Content-Type: application/json
Content-Length: length

{"SearchText":"String","StateName":"String","PostCode":"String","CountryId":"00000000-0000-0000-0000-000000000000","CountryName":"String"}
HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: length

{"Suburbs":[{"SuburbId":"00000000-0000-0000-0000-000000000000","Name":"String","StateId":"00000000-0000-0000-0000-000000000000","StateName":"String","PostCode":"String","CountryId":"00000000-0000-0000-0000-000000000000","CountryName":"String"}],"ResponseStatus":{"ErrorCode":"String","Message":"String","StackTrace":"String","Errors":[{"ErrorCode":"String","FieldName":"String","Message":"String","Meta":{"String":"String"}}],"Meta":{"String":"String"}}}