BokaMera.API.Host

<back to all web services

CreateAxemaUserSync

Requires Authentication
Requires any of the roles:bookingsupplier-administrator-write, superadmin
The following routes are available for this service:
POST/codelock/axema/usersyncStart a sync of users from the Axema Vaka system into BokaMera customersThis operation runs in the background and may take several minutes. Use the GET endpoint to check status. Only one sync can run at a time per company.
<?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 AxemaUserSyncJobResponse implements JsonSerializable
{
    public function __construct(
        /** @var string */
        public string $Id='',
        /** @var string */
        public string $CompanyId='',
        /** @var int */
        public int $Status=0,
        /** @var string */
        public string $StatusName='',
        /** @var int|null */
        public ?int $UsersFound=null,
        /** @var int|null */
        public ?int $UsersCreated=null,
        /** @var int|null */
        public ?int $UsersUpdated=null,
        /** @var string|null */
        public ?string $ErrorMessage=null,
        /** @var DateTime */
        public DateTime $CreatedDate=new DateTime(),
        /** @var DateTime */
        public DateTime $UpdatedDate=new DateTime()
    ) {
    }

    /** @throws Exception */
    public function fromMap($o): void {
        if (isset($o['Id'])) $this->Id = $o['Id'];
        if (isset($o['CompanyId'])) $this->CompanyId = $o['CompanyId'];
        if (isset($o['Status'])) $this->Status = $o['Status'];
        if (isset($o['StatusName'])) $this->StatusName = $o['StatusName'];
        if (isset($o['UsersFound'])) $this->UsersFound = $o['UsersFound'];
        if (isset($o['UsersCreated'])) $this->UsersCreated = $o['UsersCreated'];
        if (isset($o['UsersUpdated'])) $this->UsersUpdated = $o['UsersUpdated'];
        if (isset($o['ErrorMessage'])) $this->ErrorMessage = $o['ErrorMessage'];
        if (isset($o['CreatedDate'])) $this->CreatedDate = JsonConverters::from('DateTime', $o['CreatedDate']);
        if (isset($o['UpdatedDate'])) $this->UpdatedDate = JsonConverters::from('DateTime', $o['UpdatedDate']);
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        if (isset($this->Id)) $o['Id'] = $this->Id;
        if (isset($this->CompanyId)) $o['CompanyId'] = $this->CompanyId;
        if (isset($this->Status)) $o['Status'] = $this->Status;
        if (isset($this->StatusName)) $o['StatusName'] = $this->StatusName;
        if (isset($this->UsersFound)) $o['UsersFound'] = $this->UsersFound;
        if (isset($this->UsersCreated)) $o['UsersCreated'] = $this->UsersCreated;
        if (isset($this->UsersUpdated)) $o['UsersUpdated'] = $this->UsersUpdated;
        if (isset($this->ErrorMessage)) $o['ErrorMessage'] = $this->ErrorMessage;
        if (isset($this->CreatedDate)) $o['CreatedDate'] = JsonConverters::to('DateTime', $this->CreatedDate);
        if (isset($this->UpdatedDate)) $o['UpdatedDate'] = JsonConverters::to('DateTime', $this->UpdatedDate);
        return empty($o) ? new class(){} : $o;
    }
}

// @ValidateRequest(Validator="IsAuthenticated")
// @ApiResponse(Description="You were unauthorized to call this service", StatusCode=401)
// @ApiResponse(Description="You have too low privileges to call this service", StatusCode=403)
class CreateAxemaUserSync implements ICompany, JsonSerializable
{
    public function __construct(
        /** @description The company id, if empty will use the company id for the user you are logged in with. */
        // @ApiMember(Description="The company id, if empty will use the company id for the user you are logged in with.")
        /** @var string|null */
        public ?string $CompanyId=null
    ) {
    }

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

PHP CreateAxemaUserSync 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.

POST /codelock/axema/usersync HTTP/1.1 
Host: api.bokamera.se 
Accept: text/jsv
Content-Type: text/jsv
Content-Length: length

{
	CompanyId: 00000000-0000-0000-0000-000000000000
}
HTTP/1.1 200 OK
Content-Type: text/jsv
Content-Length: length

{
	Status: 0,
	StatusName: String,
	UsersFound: 0,
	UsersCreated: 0,
	UsersUpdated: 0,
	ErrorMessage: String
}