1Fetch Client API

<back to all web services

TestSubscription

The following routes are available for this service:
GET,POST/subscription/testFire a test to one of your webhooks
GET,POST/subscription/test/{EventType}Fire a test to one of your webhooks
<?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 ApiServiceRequest implements IServiceRequest, IHasApiKey, JsonSerializable
{
    public function __construct(
        /** @description The API Key required for authentication */
        // @ApiMember(DataType="string", Description="The API Key required for authentication", IsRequired=true)
        /** @var string */
        public string $ApiKey=''
    ) {
    }

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

class ApiServiceResponse implements IServiceResponse, JsonSerializable
{
    public function __construct(
        /** @description Information about the response. */
        // @ApiMember(Description="Information about the response.", IsRequired=true)
        /** @var string */
        public string $Description='',

        /** @description Heading or summary of the response. */
        // @ApiMember(Description="Heading or summary of the response.", IsRequired=true)
        /** @var string */
        public string $Heading='',

        /** @description Did the intended operation for this response complete successfully? */
        // @ApiMember(DataType="boolean", Description="Did the intended operation for this response complete successfully?", IsRequired=true)
        /** @var bool|null */
        public ?bool $WasSuccessful=null
    ) {
    }

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

enum WebhookSubscriptionEventType : int
{
    case DriverOnTheWay = 0;
    case ArrivedAtWaypoint = 1;
    case DepartedWaypoint = 2;
    case OrderCompleted = 3;
    case OrderCancelled = 4;
}

class TestSubscription extends ApiServiceRequest implements ILogRequest, JsonSerializable
{
    /**
     * @param string $ApiKey
     */
    public function __construct(
        string $ApiKey='',
        /** @description The event type being subscribed to */
        // @ApiMember(Description="The event type being subscribed to", IsRequired=true)
        /** @var WebhookSubscriptionEventType|null */
        public ?WebhookSubscriptionEventType $EventType=null
    ) {
        parent::__construct($ApiKey);
    }

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

PHP TestSubscription 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 /subscription/test HTTP/1.1 
Host: 1fetch.api.client.prod.86degrees.com 
Accept: application/xml
Content-Type: application/xml
Content-Length: length

<TestSubscription xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/WebService.ClientServiceModel">
  <ApiKey xmlns="http://schemas.datacontract.org/2004/07/WebService.ClientServiceModel.Base">String</ApiKey>
  <EventType>DriverOnTheWay</EventType>
</TestSubscription>
HTTP/1.1 200 OK
Content-Type: application/xml
Content-Length: length

<ApiServiceResponse xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/WebService.ClientServiceModel.Base">
  <Description>String</Description>
  <Heading>String</Heading>
  <WasSuccessful>false</WasSuccessful>
</ApiServiceResponse>