Sanctions Search API: v2

<back to all web services

SearchCompanyLookup

CompanyLookup
The following routes are available for this service:
POST/companylookups/searchSearch for company details
<?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};


// @DataContract
class Authentication implements JsonSerializable
{
    public function __construct(
        /** @description The API User ID provided by us when you signed up to use our API */
        // @DataMember
        // @ApiMember(Description="The API User ID provided by us when you signed up to use our API", IsRequired=true, ParameterType="header, body")
        /** @var string */
        public string $apiUserId='',

        /** @description The API User Key provided by us when you signed up to use our API */
        // @DataMember
        // @ApiMember(Description="The API User Key provided by us when you signed up to use our API", IsRequired=true, ParameterType="header, body")
        /** @var string */
        public string $apiUserKey=''
    ) {
    }

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

// @DataContract
class BaseRequest implements IBaseRequest, JsonSerializable
{
    public function __construct(
        /** @description The authentication credentials */
        // @DataMember
        // @ApiMember(Description="The authentication credentials", IsRequired=true, ParameterType="header, body")
        /** @var Authentication|null */
        public ?Authentication $authentication=null
    ) {
    }

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

// @DataContract
class ResponseError implements JsonSerializable
{
    public function __construct(
        // @DataMember(Order=1)
        /** @var string|null */
        public ?string $errorCode=null,

        // @DataMember(Order=2)
        /** @var string|null */
        public ?string $fieldName=null,

        // @DataMember(Order=3)
        /** @var string|null */
        public ?string $message=null,

        // @DataMember(Order=4)
        /** @var array<string,string>|null */
        public ?array $meta=null
    ) {
    }

    /** @throws Exception */
    public function fromMap($o): void {
        if (isset($o['errorCode'])) $this->errorCode = $o['errorCode'];
        if (isset($o['fieldName'])) $this->fieldName = $o['fieldName'];
        if (isset($o['message'])) $this->message = $o['message'];
        if (isset($o['meta'])) $this->meta = JsonConverters::from(JsonConverters::context('Dictionary',genericArgs:['string','string']), $o['meta']);
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        if (isset($this->errorCode)) $o['errorCode'] = $this->errorCode;
        if (isset($this->fieldName)) $o['fieldName'] = $this->fieldName;
        if (isset($this->message)) $o['message'] = $this->message;
        if (isset($this->meta)) $o['meta'] = JsonConverters::to(JsonConverters::context('Dictionary',genericArgs:['string','string']), $this->meta);
        return empty($o) ? new class(){} : $o;
    }
}

/**
 * @template array of ResponseError
 */
class ArrayOfResponseError extends \ArrayObject implements JsonSerializable
{
    public function __construct(ResponseError ...$items) {
        parent::__construct($items, \ArrayObject::STD_PROP_LIST);
    }
    
    /** @throws \Exception */
    public function append($value): void {
        if ($value instanceof ResponseError)
            parent::append($value);
        else
            throw new \Exception("Can only append a ResponseError to " . __CLASS__);
    }
    
    /** @throws Exception */
    public function fromMap($o): void {
        foreach ($o as $item) {
            $el = new ResponseError();
            $el->fromMap($item);
            $this->append($el);
        }
    }
    
    /** @throws Exception */
    public function jsonSerialize(): array {
        return parent::getArrayCopy();
    }
}

// @DataContract
class ResponseStatus implements JsonSerializable
{
    public function __construct(
        // @DataMember(Order=1)
        /** @var string|null */
        public ?string $errorCode=null,

        // @DataMember(Order=2)
        /** @var string|null */
        public ?string $message=null,

        // @DataMember(Order=3)
        /** @var string|null */
        public ?string $stackTrace=null,

        // @DataMember(Order=4)
        /** @var ArrayOfResponseError|null */
        public ?ArrayOfResponseError $errors=null,

        // @DataMember(Order=5)
        /** @var array<string,string>|null */
        public ?array $meta=null
    ) {
    }

    /** @throws Exception */
    public function fromMap($o): void {
        if (isset($o['errorCode'])) $this->errorCode = $o['errorCode'];
        if (isset($o['message'])) $this->message = $o['message'];
        if (isset($o['stackTrace'])) $this->stackTrace = $o['stackTrace'];
        if (isset($o['errors'])) $this->errors = JsonConverters::from('ArrayOfResponseError', $o['errors']);
        if (isset($o['meta'])) $this->meta = JsonConverters::from(JsonConverters::context('Dictionary',genericArgs:['string','string']), $o['meta']);
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        if (isset($this->errorCode)) $o['errorCode'] = $this->errorCode;
        if (isset($this->message)) $o['message'] = $this->message;
        if (isset($this->stackTrace)) $o['stackTrace'] = $this->stackTrace;
        if (isset($this->errors)) $o['errors'] = JsonConverters::to('ArrayOfResponseError', $this->errors);
        if (isset($this->meta)) $o['meta'] = JsonConverters::to(JsonConverters::context('Dictionary',genericArgs:['string','string']), $this->meta);
        return empty($o) ? new class(){} : $o;
    }
}

class BaseResponse implements IBaseDataResponse, IHasResponseStatus, JsonSerializable
{
    public function __construct(
        /** @description The status of the response */
        // @ApiMember(Description="The status of the response")
        /** @var ResponseStatus|null */
        public ?ResponseStatus $responseStatus=null
    ) {
    }

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

class CompanySearchResultItem implements JsonSerializable
{
    public function __construct(
        /** @var string|null */
        public ?string $id=null,
        /** @var string|null */
        public ?string $number=null,
        /** @var string|null */
        public ?string $name=null,
        /** @var string|null */
        public ?string $address=null,
        /** @var string|null */
        public ?string $country=null,
        /** @var string|null */
        public ?string $status=null
    ) {
    }

    /** @throws Exception */
    public function fromMap($o): void {
        if (isset($o['id'])) $this->id = $o['id'];
        if (isset($o['number'])) $this->number = $o['number'];
        if (isset($o['name'])) $this->name = $o['name'];
        if (isset($o['address'])) $this->address = $o['address'];
        if (isset($o['country'])) $this->country = $o['country'];
        if (isset($o['status'])) $this->status = $o['status'];
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        if (isset($this->id)) $o['id'] = $this->id;
        if (isset($this->number)) $o['number'] = $this->number;
        if (isset($this->name)) $o['name'] = $this->name;
        if (isset($this->address)) $o['address'] = $this->address;
        if (isset($this->country)) $o['country'] = $this->country;
        if (isset($this->status)) $o['status'] = $this->status;
        return empty($o) ? new class(){} : $o;
    }
}

/**
 * @template array of CompanySearchResultItem
 */
class ArrayOfCompanySearchResult extends \ArrayObject implements JsonSerializable
{
    public function __construct(CompanySearchResultItem ...$items) {
        parent::__construct($items, \ArrayObject::STD_PROP_LIST);
    }
    
    /** @throws \Exception */
    public function append($value): void {
        if ($value instanceof CompanySearchResultItem)
            parent::append($value);
        else
            throw new \Exception("Can only append a CompanySearchResultItem to " . __CLASS__);
    }
    
    /** @throws Exception */
    public function fromMap($o): void {
        foreach ($o as $item) {
            $el = new CompanySearchResultItem();
            $el->fromMap($item);
            $this->append($el);
        }
    }
    
    /** @throws Exception */
    public function jsonSerialize(): array {
        return parent::getArrayCopy();
    }
}

class SearchCompanyLookupData extends BaseResponse implements JsonSerializable
{
    /**
     * @param ResponseStatus|null $responseStatus
     */
    public function __construct(
        ?ResponseStatus $responseStatus=null,
        /** @var ArrayOfCompanySearchResult|null */
        public ?ArrayOfCompanySearchResult $searchResults=null
    ) {
        parent::__construct($responseStatus);
    }

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

// @DataContract
class SearchCompanyLookupResponse implements JsonSerializable
{
    public function __construct(
        // @DataMember
        /** @var SearchCompanyLookupData|null */
        public ?SearchCompanyLookupData $data=null
    ) {
    }

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

class SearchCompanyLookupRequest implements JsonSerializable
{
    public function __construct(
        /** @var string|null */
        public ?string $companyName=null,
        /** @var string|null */
        public ?string $companyCountry=null,
        /** @var bool|null */
        public ?bool $autocompleteMode=null
    ) {
    }

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

// @DataContract
class SearchCompanyLookup extends BaseRequest implements JsonSerializable
{
    /**
     * @param Authentication|null $authentication
     */
    public function __construct(
        ?Authentication $authentication=null,
        // @DataMember
        /** @var SearchCompanyLookupRequest|null */
        public ?SearchCompanyLookupRequest $request=null
    ) {
        parent::__construct($authentication);
    }

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

PHP SearchCompanyLookup 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 /companylookups/search HTTP/1.1 
Host: api.sanctionssearch.com 
Accept: application/json
Content-Type: application/json
Content-Length: length

{"request":{"companyName":"String","companyCountry":"String","autocompleteMode":false},"authentication":{"apiUserId":"String","apiUserKey":"String"}}
HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: length

{"data":{"searchResults":[{"id":"String","number":"String","name":"String","address":"String","country":"String","status":"String"}],"responseStatus":{"errorCode":"String","message":"String","stackTrace":"String","errors":[{"errorCode":"String","fieldName":"String","message":"String","meta":{"String":"String"}}],"meta":{"String":"String"}}}}