Cochrane+ App API

<back to all web services

Test

The following routes are available for this service:
GET/testSimple test method to confirm the services are working
<?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 TestResult implements JsonSerializable
{
    public function __construct(
        /** @var bool|null */
        public ?bool $wasSuccessful=null,
        /** @var string|null */
        public ?string $description=null
    ) {
    }

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

class TestResponse implements JsonSerializable
{
    public function __construct(
        /** @var string|null */
        public ?string $environment=null,
        /** @var array<string,TestResult>|null */
        public ?array $tests=null,
        /** @var bool|null */
        public ?bool $wasSuccessful=null,
        /** @var string|null */
        public ?string $db=null
    ) {
    }

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

class Test implements JsonSerializable
{
    public function __construct(
        /** @description An email address a test email will be sent to */
        // @ApiMember(Description="An email address a test email will be sent to")
        /** @var string|null */
        public ?string $smtp=null
    ) {
    }

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

PHP Test DTOs

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

HTTP + JSV

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

GET /test HTTP/1.1 
Host: cochraneplus-api-dev.happen.zone 
Accept: text/jsv
HTTP/1.1 200 OK
Content-Type: text/jsv
Content-Length: length

{
	environment: String,
	tests: 
	{
		String: 
		{
			wasSuccessful: False,
			description: String
		}
	},
	wasSuccessful: False,
	db: String
}