Cochrane+ App API

<back to all web services

UserLogin

The following routes are available for this service:
POST/user/login
<?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, IHasDeviceInfo, 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='',

        /** @description Latitude of the user making this request */
        // @ApiMember(DataType="double", Description="Latitude of the user making this request")
        /** @var float */
        public float $latitude=0.0,

        /** @description Longitude of the user making this request */
        // @ApiMember(DataType="double", Description="Longitude of the user making this request")
        /** @var float */
        public float $longitude=0.0
    ) {
    }

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

class ApiServiceResponse implements IServiceResponse, JsonSerializable
{
    public function __construct(
        /** @var string|null */
        public ?string $description=null,
        /** @var string|null */
        public ?string $heading=null,
        /** @var bool|null */
        public ?bool $wasSuccessful=null,
        /** @var Object|null */
        public ?Object $modelState=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'];
        if (isset($o['modelState'])) $this->modelState = JsonConverters::from('Object', $o['modelState']);
    }
    
    /** @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;
        if (isset($this->modelState)) $o['modelState'] = JsonConverters::to('Object', $this->modelState);
        return empty($o) ? new class(){} : $o;
    }
}

class SystemUserPermission implements JsonSerializable
{
    public function __construct(
        /** @var bool|null */
        public ?bool $meeting=null,
        /** @var bool|null */
        public ?bool $journey=null,
        /** @var bool|null */
        public ?bool $attendance=null,
        /** @var bool|null */
        public ?bool $notificationCenter=null,
        /** @var bool|null */
        public ?bool $internalRating=null,
        /** @var bool|null */
        public ?bool $debrief=null,
        /** @var bool|null */
        public ?bool $thunderBoltActions=null,
        /** @var bool|null */
        public ?bool $onTheMove=null
    ) {
    }

    /** @throws Exception */
    public function fromMap($o): void {
        if (isset($o['meeting'])) $this->meeting = $o['meeting'];
        if (isset($o['journey'])) $this->journey = $o['journey'];
        if (isset($o['attendance'])) $this->attendance = $o['attendance'];
        if (isset($o['notificationCenter'])) $this->notificationCenter = $o['notificationCenter'];
        if (isset($o['internalRating'])) $this->internalRating = $o['internalRating'];
        if (isset($o['debrief'])) $this->debrief = $o['debrief'];
        if (isset($o['thunderBoltActions'])) $this->thunderBoltActions = $o['thunderBoltActions'];
        if (isset($o['onTheMove'])) $this->onTheMove = $o['onTheMove'];
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        if (isset($this->meeting)) $o['meeting'] = $this->meeting;
        if (isset($this->journey)) $o['journey'] = $this->journey;
        if (isset($this->attendance)) $o['attendance'] = $this->attendance;
        if (isset($this->notificationCenter)) $o['notificationCenter'] = $this->notificationCenter;
        if (isset($this->internalRating)) $o['internalRating'] = $this->internalRating;
        if (isset($this->debrief)) $o['debrief'] = $this->debrief;
        if (isset($this->thunderBoltActions)) $o['thunderBoltActions'] = $this->thunderBoltActions;
        if (isset($this->onTheMove)) $o['onTheMove'] = $this->onTheMove;
        return empty($o) ? new class(){} : $o;
    }
}

class AppSettings implements JsonSerializable
{
    public function __construct(
        /** @var bool|null */
        public ?bool $allowAbstainRatings=null,
        /** @var bool|null */
        public ?bool $showMoodIndicatorOnApp=null,
        /** @var bool|null */
        public ?bool $takePhotoForAnalysis=null
    ) {
    }

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

class UserLoginResponse extends ApiServiceResponse implements JsonSerializable
{
    /**
     * @param string|null $description
     * @param string|null $heading
     * @param bool|null $wasSuccessful
     * @param Object|null $modelState
     */
    public function __construct(
        ?string $description=null,
        ?string $heading=null,
        ?bool $wasSuccessful=null,
        ?Object $modelState=null,
        /** @var bool|null */
        public ?bool $allowAttendanceOnLaptop=null,
        /** @var string|null */
        public ?string $profileImageUrl=null,
        /** @var string|null */
        public ?string $friendlyName=null,
        /** @var int */
        public int $systemUserId=0,
        /** @var string|null */
        public ?string $username=null,
        /** @var SystemUserPermission|null */
        public ?SystemUserPermission $permissions=null,
        /** @var AppSettings|null */
        public ?AppSettings $settings=null,
        /** @var float */
        public float $startLatitude=0.0,
        /** @var float */
        public float $startLongitude=0.0,
        /** @var bool|null */
        public ?bool $hasStartLocation=null,
        /** @var float */
        public float $endLatitude=0.0,
        /** @var float */
        public float $endLongitude=0.0,
        /** @var bool|null */
        public ?bool $hasEndLocation=null,
        /** @var bool|null */
        public ?bool $isSalesPerson=null,
        /** @var string[]|null */
        public ?array $feelingStatusMappings=null,
        /** @var bool|null */
        public ?bool $hasAiPermissions=null,
        /** @var string|null */
        public ?string $refreshToken=null,
        /** @var bool|null */
        public ?bool $isManagerOrPromotedTo=null,
        /** @var bool|null */
        public ?bool $isTemplateApprover=null,
        /** @var int */
        public int $outstandingApprovals=0
    ) {
        parent::__construct($description,$heading,$wasSuccessful,$modelState);
    }

    /** @throws Exception */
    public function fromMap($o): void {
        parent::fromMap($o);
        if (isset($o['allowAttendanceOnLaptop'])) $this->allowAttendanceOnLaptop = $o['allowAttendanceOnLaptop'];
        if (isset($o['profileImageUrl'])) $this->profileImageUrl = $o['profileImageUrl'];
        if (isset($o['friendlyName'])) $this->friendlyName = $o['friendlyName'];
        if (isset($o['systemUserId'])) $this->systemUserId = $o['systemUserId'];
        if (isset($o['username'])) $this->username = $o['username'];
        if (isset($o['permissions'])) $this->permissions = JsonConverters::from('SystemUserPermission', $o['permissions']);
        if (isset($o['settings'])) $this->settings = JsonConverters::from('AppSettings', $o['settings']);
        if (isset($o['startLatitude'])) $this->startLatitude = $o['startLatitude'];
        if (isset($o['startLongitude'])) $this->startLongitude = $o['startLongitude'];
        if (isset($o['hasStartLocation'])) $this->hasStartLocation = $o['hasStartLocation'];
        if (isset($o['endLatitude'])) $this->endLatitude = $o['endLatitude'];
        if (isset($o['endLongitude'])) $this->endLongitude = $o['endLongitude'];
        if (isset($o['hasEndLocation'])) $this->hasEndLocation = $o['hasEndLocation'];
        if (isset($o['isSalesPerson'])) $this->isSalesPerson = $o['isSalesPerson'];
        if (isset($o['feelingStatusMappings'])) $this->feelingStatusMappings = JsonConverters::fromArray('string', $o['feelingStatusMappings']);
        if (isset($o['hasAiPermissions'])) $this->hasAiPermissions = $o['hasAiPermissions'];
        if (isset($o['refreshToken'])) $this->refreshToken = $o['refreshToken'];
        if (isset($o['isManagerOrPromotedTo'])) $this->isManagerOrPromotedTo = $o['isManagerOrPromotedTo'];
        if (isset($o['isTemplateApprover'])) $this->isTemplateApprover = $o['isTemplateApprover'];
        if (isset($o['outstandingApprovals'])) $this->outstandingApprovals = $o['outstandingApprovals'];
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = parent::jsonSerialize();
        if (isset($this->allowAttendanceOnLaptop)) $o['allowAttendanceOnLaptop'] = $this->allowAttendanceOnLaptop;
        if (isset($this->profileImageUrl)) $o['profileImageUrl'] = $this->profileImageUrl;
        if (isset($this->friendlyName)) $o['friendlyName'] = $this->friendlyName;
        if (isset($this->systemUserId)) $o['systemUserId'] = $this->systemUserId;
        if (isset($this->username)) $o['username'] = $this->username;
        if (isset($this->permissions)) $o['permissions'] = JsonConverters::to('SystemUserPermission', $this->permissions);
        if (isset($this->settings)) $o['settings'] = JsonConverters::to('AppSettings', $this->settings);
        if (isset($this->startLatitude)) $o['startLatitude'] = $this->startLatitude;
        if (isset($this->startLongitude)) $o['startLongitude'] = $this->startLongitude;
        if (isset($this->hasStartLocation)) $o['hasStartLocation'] = $this->hasStartLocation;
        if (isset($this->endLatitude)) $o['endLatitude'] = $this->endLatitude;
        if (isset($this->endLongitude)) $o['endLongitude'] = $this->endLongitude;
        if (isset($this->hasEndLocation)) $o['hasEndLocation'] = $this->hasEndLocation;
        if (isset($this->isSalesPerson)) $o['isSalesPerson'] = $this->isSalesPerson;
        if (isset($this->feelingStatusMappings)) $o['feelingStatusMappings'] = JsonConverters::toArray('string', $this->feelingStatusMappings);
        if (isset($this->hasAiPermissions)) $o['hasAiPermissions'] = $this->hasAiPermissions;
        if (isset($this->refreshToken)) $o['refreshToken'] = $this->refreshToken;
        if (isset($this->isManagerOrPromotedTo)) $o['isManagerOrPromotedTo'] = $this->isManagerOrPromotedTo;
        if (isset($this->isTemplateApprover)) $o['isTemplateApprover'] = $this->isTemplateApprover;
        if (isset($this->outstandingApprovals)) $o['outstandingApprovals'] = $this->outstandingApprovals;
        return empty($o) ? new class(){} : $o;
    }
}

class UserLogin extends ApiServiceRequest implements JsonSerializable
{
    /**
     * @param string $apiKey
     * @param float $latitude
     * @param float $longitude
     */
    public function __construct(
        string $apiKey='',
        float $latitude=0.0,
        float $longitude=0.0,
        /** @var string|null */
        public ?string $username=null,
        /** @var string|null */
        public ?string $password=null,
        /** @var int */
        public int $utcOffset=0
    ) {
        parent::__construct($apiKey,$latitude,$longitude);
    }

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

PHP UserLogin 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 /user/login HTTP/1.1 
Host: cochraneplus-api-dev.happen.zone 
Accept: application/xml
Content-Type: application/xml
Content-Length: length

<UserLogin xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/WebService.ServiceModel">
  <ApiKey xmlns="http://schemas.datacontract.org/2004/07/WebService.ServiceModel.Base">String</ApiKey>
  <Latitude xmlns="http://schemas.datacontract.org/2004/07/WebService.ServiceModel.Base">0</Latitude>
  <Longitude xmlns="http://schemas.datacontract.org/2004/07/WebService.ServiceModel.Base">0</Longitude>
  <Password>String</Password>
  <Username>String</Username>
  <UtcOffset>0</UtcOffset>
</UserLogin>
HTTP/1.1 200 OK
Content-Type: application/xml
Content-Length: length

<UserLoginResponse xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/WebService.ServiceModel">
  <Description xmlns="http://schemas.datacontract.org/2004/07/CommonService.Api.Models.Base">String</Description>
  <Heading xmlns="http://schemas.datacontract.org/2004/07/CommonService.Api.Models.Base">String</Heading>
  <ModelState xmlns="http://schemas.datacontract.org/2004/07/CommonService.Api.Models.Base" />
  <WasSuccessful xmlns="http://schemas.datacontract.org/2004/07/CommonService.Api.Models.Base">false</WasSuccessful>
  <AllowAttendanceOnLaptop>false</AllowAttendanceOnLaptop>
  <EndLatitude>0</EndLatitude>
  <EndLongitude>0</EndLongitude>
  <FeelingStatusMappings xmlns:d2p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
    <d2p1:string>String</d2p1:string>
  </FeelingStatusMappings>
  <FriendlyName>String</FriendlyName>
  <HasAiPermissions>false</HasAiPermissions>
  <IsManagerOrPromotedTo>false</IsManagerOrPromotedTo>
  <IsSalesPerson>false</IsSalesPerson>
  <IsTemplateApprover>false</IsTemplateApprover>
  <OutstandingApprovals>0</OutstandingApprovals>
  <Permissions xmlns:d2p1="http://schemas.datacontract.org/2004/07/BusinessLogic.Entities">
    <d2p1:Attendance>false</d2p1:Attendance>
    <d2p1:Debrief>false</d2p1:Debrief>
    <d2p1:InternalRating>false</d2p1:InternalRating>
    <d2p1:Journey>false</d2p1:Journey>
    <d2p1:Meeting>false</d2p1:Meeting>
    <d2p1:NotificationCenter>false</d2p1:NotificationCenter>
    <d2p1:OnTheMove>false</d2p1:OnTheMove>
    <d2p1:ThunderBoltActions>false</d2p1:ThunderBoltActions>
  </Permissions>
  <ProfileImageUrl>String</ProfileImageUrl>
  <RefreshToken>String</RefreshToken>
  <Settings>
    <AllowAbstainRatings>false</AllowAbstainRatings>
    <ShowMoodIndicatorOnApp>false</ShowMoodIndicatorOnApp>
    <TakePhotoForAnalysis>false</TakePhotoForAnalysis>
  </Settings>
  <StartLatitude>0</StartLatitude>
  <StartLongitude>0</StartLongitude>
  <SystemUserId>0</SystemUserId>
  <Username>String</Username>
</UserLoginResponse>