BokaMera.API.Host

<back to all web services

UpdateUser

Requires Authentication
The following routes are available for this service:
PUT/usersUpdate my informationUpdates the logged in users info both in customer profile and application admin profile if any exists. Users are only allowed to update their own info.
<?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 UserProfileResponse implements JsonSerializable
{
    public function __construct(
        /** @var string */
        public string $Id='',
        /** @var string|null */
        public ?string $Firstname=null,
        /** @var string|null */
        public ?string $Lastname=null,
        /** @var string|null */
        public ?string $Phone=null,
        /** @var string|null */
        public ?string $Email=null
    ) {
    }

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

class AdminProfile implements JsonSerializable
{
    public function __construct(
        /** @var string */
        public string $CompanyId='',
        /** @var string */
        public string $Id='',
        /** @var string|null */
        public ?string $Firstname=null,
        /** @var string|null */
        public ?string $Lastname=null,
        /** @var string|null */
        public ?string $Email=null,
        /** @var string|null */
        public ?string $WorkerId=null,
        /** @var string|null */
        public ?string $Phone=null
    ) {
    }

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

class UpdateUserResponse implements JsonSerializable
{
    public function __construct(
        /** @var Object|null */
        public ?Object $ResponseStatus=null,
        /** @description The user id for your profile. */
        // @ApiMember(Description="The user id for your profile.", IsRequired=true)
        /** @var string */
        public string $UserId='',

        /** @var UserProfileResponse|null */
        public ?UserProfileResponse $UserProfile=null,
        /** @var AdminProfile|null */
        public ?AdminProfile $AdminProfile=null,
        /** @var bool|null */
        public ?bool $IsSentConfirmationUpdateEmail=null
    ) {
    }

    /** @throws Exception */
    public function fromMap($o): void {
        if (isset($o['ResponseStatus'])) $this->ResponseStatus = JsonConverters::from('Object', $o['ResponseStatus']);
        if (isset($o['UserId'])) $this->UserId = $o['UserId'];
        if (isset($o['UserProfile'])) $this->UserProfile = JsonConverters::from('UserProfileResponse', $o['UserProfile']);
        if (isset($o['AdminProfile'])) $this->AdminProfile = JsonConverters::from('AdminProfile', $o['AdminProfile']);
        if (isset($o['IsSentConfirmationUpdateEmail'])) $this->IsSentConfirmationUpdateEmail = $o['IsSentConfirmationUpdateEmail'];
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        if (isset($this->ResponseStatus)) $o['ResponseStatus'] = JsonConverters::to('Object', $this->ResponseStatus);
        if (isset($this->UserId)) $o['UserId'] = $this->UserId;
        if (isset($this->UserProfile)) $o['UserProfile'] = JsonConverters::to('UserProfileResponse', $this->UserProfile);
        if (isset($this->AdminProfile)) $o['AdminProfile'] = JsonConverters::to('AdminProfile', $this->AdminProfile);
        if (isset($this->IsSentConfirmationUpdateEmail)) $o['IsSentConfirmationUpdateEmail'] = $this->IsSentConfirmationUpdateEmail;
        return empty($o) ? new class(){} : $o;
    }
}

class UpdateCustomerProfile implements JsonSerializable
{
    public function __construct(
        /** @var string|null */
        public ?string $Firstname=null,
        /** @var string|null */
        public ?string $Lastname=null,
        /** @var string|null */
        public ?string $Phone=null,
        /** @var string|null */
        public ?string $Email=null
    ) {
    }

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

class UpdateAdminProfile implements JsonSerializable
{
    public function __construct(
        /** @var string|null */
        public ?string $Firstname=null,
        /** @var string|null */
        public ?string $Lastname=null,
        /** @var string|null */
        public ?string $Phone=null,
        /** @var string|null */
        public ?string $Email=null
    ) {
    }

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

enum KeyCloakRealm : int
{
    case BookMore = 1;
    case BookMoreAdmin = 2;
    case SuperAdmin = 3;
}

// @ApiResponse(Description="Returned if there is a validation error on the input parameters", StatusCode=400)
// @ApiResponse(Description="Returned if the current user is not allowed to perform the action", StatusCode=401)
// @ValidateRequest(Validator="IsAuthenticated")
class UpdateUser implements JsonSerializable
{
    public function __construct(
        /** @description The user id for your profile. */
        // @ApiMember(Description="The user id for your profile.")
        /** @var string|null */
        public ?string $UserId=null,

        /** @var string|null */
        public ?string $NewEmail=null,
        /** @var UpdateCustomerProfile|null */
        public ?UpdateCustomerProfile $UserProfile=null,
        /** @var UpdateAdminProfile|null */
        public ?UpdateAdminProfile $AdminProfile=null,
        /** @description The user realm for identity server.  BookMore = 1, BookMoreAdmin = 2  */
        // @ApiMember(Description="The user realm for identity server.  BookMore = 1, BookMoreAdmin = 2 ", IsRequired=true)
        /** @var KeyCloakRealm|null */
        public ?KeyCloakRealm $Realm=null
    ) {
    }

    /** @throws Exception */
    public function fromMap($o): void {
        if (isset($o['UserId'])) $this->UserId = $o['UserId'];
        if (isset($o['NewEmail'])) $this->NewEmail = $o['NewEmail'];
        if (isset($o['UserProfile'])) $this->UserProfile = JsonConverters::from('UpdateCustomerProfile', $o['UserProfile']);
        if (isset($o['AdminProfile'])) $this->AdminProfile = JsonConverters::from('UpdateAdminProfile', $o['AdminProfile']);
        if (isset($o['Realm'])) $this->Realm = JsonConverters::from('KeyCloakRealm', $o['Realm']);
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        if (isset($this->UserId)) $o['UserId'] = $this->UserId;
        if (isset($this->NewEmail)) $o['NewEmail'] = $this->NewEmail;
        if (isset($this->UserProfile)) $o['UserProfile'] = JsonConverters::to('UpdateCustomerProfile', $this->UserProfile);
        if (isset($this->AdminProfile)) $o['AdminProfile'] = JsonConverters::to('UpdateAdminProfile', $this->AdminProfile);
        if (isset($this->Realm)) $o['Realm'] = JsonConverters::to('KeyCloakRealm', $this->Realm);
        return empty($o) ? new class(){} : $o;
    }
}

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

PUT /users HTTP/1.1 
Host: testapi.bokamera.se 
Accept: application/xml
Content-Type: application/xml
Content-Length: length

<UpdateUser xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/BokaMera.API.ServiceModel.Dtos">
  <AdminProfile>
    <Email>String</Email>
    <Firstname>String</Firstname>
    <Lastname>String</Lastname>
    <Phone>String</Phone>
  </AdminProfile>
  <NewEmail>String</NewEmail>
  <Realm>BookMore</Realm>
  <UserId>00000000-0000-0000-0000-000000000000</UserId>
  <UserProfile>
    <Email>String</Email>
    <Firstname>String</Firstname>
    <Lastname>String</Lastname>
    <Phone>String</Phone>
  </UserProfile>
</UpdateUser>
HTTP/1.1 200 OK
Content-Type: application/xml
Content-Length: length

<UpdateUserResponse xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/BokaMera.API.ServiceModel.Dtos">
  <AdminProfile>
    <CompanyId>00000000-0000-0000-0000-000000000000</CompanyId>
    <Email>String</Email>
    <Firstname>String</Firstname>
    <Id>00000000-0000-0000-0000-000000000000</Id>
    <Lastname>String</Lastname>
    <Phone>String</Phone>
    <WorkerId>String</WorkerId>
  </AdminProfile>
  <IsSentConfirmationUpdateEmail>false</IsSentConfirmationUpdateEmail>
  <ResponseStatus />
  <UserId>00000000-0000-0000-0000-000000000000</UserId>
  <UserProfile>
    <Email>String</Email>
    <Firstname>String</Firstname>
    <Id>00000000-0000-0000-0000-000000000000</Id>
    <Lastname>String</Lastname>
    <Phone>String</Phone>
  </UserProfile>
</UpdateUserResponse>