ScannerVision Web Server

<back to all web services

JsonFileUploadRequest

Requires Authentication
<?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 JsonDto implements JsonSerializable
{
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        return empty($o) ? new class(){} : $o;
    }
}

class JsonRequestDto extends JsonDto implements JsonSerializable
{
    public function __construct(
        /** @var string|null */
        public ?string $ClientCode=null,
        /** @var string|null */
        public ?string $ClientRegistrationCode=null,
        /** @var string|null */
        public ?string $Token=null
    ) {
    }

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

class JsonFileUploadResponse extends JsonDto implements JsonSerializable
{
    public function __construct(
        /** @var string|null */
        public ?string $ErrorMessage=null,
        /** @var bool|null */
        public ?bool $InError=null,
        /** @var string|null */
        public ?string $TemplateGuid=null
    ) {
    }

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

class JsonFileUploadRequest extends JsonRequestDto implements JsonSerializable
{
    /**
     * @param string|null $ClientCode
     * @param string|null $ClientRegistrationCode
     * @param string|null $Token
     */
    public function __construct(
        ?string $ClientCode=null,
        ?string $ClientRegistrationCode=null,
        ?string $Token=null,
        /** @var string|null */
        public ?string $FileName=null,
        /** @var ByteArray|null */
        public ?ByteArray $RequestStream=null,
        /** @var string|null */
        public ?string $TemplateGuid=null
    ) {
        parent::__construct($ClientCode,$ClientRegistrationCode,$Token);
    }

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

PHP JsonFileUploadRequest 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 /xml/reply/JsonFileUploadRequest HTTP/1.1 
Host: buildmax.org 
Accept: application/xml
Content-Type: application/xml
Content-Length: length

<JsonFileUploadRequest xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/ScannerVision.WebService.Json.Dto">
  <ClientCode>String</ClientCode>
  <ClientRegistrationCode>String</ClientRegistrationCode>
  <Token>String</Token>
  <FileName>String</FileName>
  <RequestStream xmlns:d2p1="http://schemas.datacontract.org/2004/07/System.IO" i:nil="true" />
  <TemplateGuid>String</TemplateGuid>
</JsonFileUploadRequest>
HTTP/1.1 200 OK
Content-Type: application/xml
Content-Length: length

<JsonFileUploadResponse xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/ScannerVision.WebService.Json.Dto">
  <ErrorMessage>String</ErrorMessage>
  <InError>false</InError>
  <TemplateGuid>String</TemplateGuid>
</JsonFileUploadResponse>