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 .xml suffix or ?format=xml

HTTP + XML

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/xml
Content-Type: application/xml
Content-Length: length

<GetSuburbs xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/Eros.Subtle.Canvara.WebAPIModel.ServiceModel">
  <CountryId>00000000-0000-0000-0000-000000000000</CountryId>
  <CountryName>String</CountryName>
  <PostCode>String</PostCode>
  <SearchText>String</SearchText>
  <StateName>String</StateName>
</GetSuburbs>
HTTP/1.1 200 OK
Content-Type: application/xml
Content-Length: length

<GetSuburbsResponse xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/Eros.Subtle.Canvara.WebAPIModel.ServiceModel">
  <ResponseStatus xmlns:d2p1="http://schemas.servicestack.net/types">
    <d2p1:ErrorCode>String</d2p1:ErrorCode>
    <d2p1:Message>String</d2p1:Message>
    <d2p1:StackTrace>String</d2p1:StackTrace>
    <d2p1:Errors>
      <d2p1:ResponseError>
        <d2p1:ErrorCode>String</d2p1:ErrorCode>
        <d2p1:FieldName>String</d2p1:FieldName>
        <d2p1:Message>String</d2p1:Message>
        <d2p1:Meta xmlns:d5p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
          <d5p1:KeyValueOfstringstring>
            <d5p1:Key>String</d5p1:Key>
            <d5p1:Value>String</d5p1:Value>
          </d5p1:KeyValueOfstringstring>
        </d2p1:Meta>
      </d2p1:ResponseError>
    </d2p1:Errors>
    <d2p1:Meta xmlns:d3p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
      <d3p1:KeyValueOfstringstring>
        <d3p1:Key>String</d3p1:Key>
        <d3p1:Value>String</d3p1:Value>
      </d3p1:KeyValueOfstringstring>
    </d2p1:Meta>
  </ResponseStatus>
  <Suburbs xmlns:d2p1="http://schemas.datacontract.org/2004/07/Eros.Saguna.Common.WebAPIModel.Models">
    <d2p1:SuburbModel>
      <d2p1:CountryId>00000000-0000-0000-0000-000000000000</d2p1:CountryId>
      <d2p1:CountryName>String</d2p1:CountryName>
      <d2p1:Name>String</d2p1:Name>
      <d2p1:PostCode>String</d2p1:PostCode>
      <d2p1:StateId>00000000-0000-0000-0000-000000000000</d2p1:StateId>
      <d2p1:StateName>String</d2p1:StateName>
      <d2p1:SuburbId>00000000-0000-0000-0000-000000000000</d2p1:SuburbId>
    </d2p1:SuburbModel>
  </Suburbs>
</GetSuburbsResponse>