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.
import 'package:servicestack/servicestack.dart';

class UserProfileResponse implements IConvertible
{
    String? Id;
    String? Firstname;
    String? Lastname;
    String? Phone;
    String? Email;

    UserProfileResponse({this.Id,this.Firstname,this.Lastname,this.Phone,this.Email});
    UserProfileResponse.fromJson(Map<String, dynamic> json) { fromMap(json); }

    fromMap(Map<String, dynamic> json) {
        Id = json['Id'];
        Firstname = json['Firstname'];
        Lastname = json['Lastname'];
        Phone = json['Phone'];
        Email = json['Email'];
        return this;
    }

    Map<String, dynamic> toJson() => {
        'Id': Id,
        'Firstname': Firstname,
        'Lastname': Lastname,
        'Phone': Phone,
        'Email': Email
    };

    getTypeName() => "UserProfileResponse";
    TypeContext? context = _ctx;
}

class AdminProfile implements IConvertible
{
    String? CompanyId;
    String? Id;
    String? Firstname;
    String? Lastname;
    String? Email;
    String? WorkerId;
    String? Phone;

    AdminProfile({this.CompanyId,this.Id,this.Firstname,this.Lastname,this.Email,this.WorkerId,this.Phone});
    AdminProfile.fromJson(Map<String, dynamic> json) { fromMap(json); }

    fromMap(Map<String, dynamic> json) {
        CompanyId = json['CompanyId'];
        Id = json['Id'];
        Firstname = json['Firstname'];
        Lastname = json['Lastname'];
        Email = json['Email'];
        WorkerId = json['WorkerId'];
        Phone = json['Phone'];
        return this;
    }

    Map<String, dynamic> toJson() => {
        'CompanyId': CompanyId,
        'Id': Id,
        'Firstname': Firstname,
        'Lastname': Lastname,
        'Email': Email,
        'WorkerId': WorkerId,
        'Phone': Phone
    };

    getTypeName() => "AdminProfile";
    TypeContext? context = _ctx;
}

class UpdateUserResponse implements IConvertible
{
    dynamic? ResponseStatus;
    /**
    * The user id for your profile.
    */
    // @ApiMember(Description="The user id for your profile.", IsRequired=true)
    String? UserId;

    UserProfileResponse? UserProfile;
    AdminProfile? AdminProfile;
    bool? IsSentConfirmationUpdateEmail;

    UpdateUserResponse({this.ResponseStatus,this.UserId,this.UserProfile,this.AdminProfile,this.IsSentConfirmationUpdateEmail});
    UpdateUserResponse.fromJson(Map<String, dynamic> json) { fromMap(json); }

    fromMap(Map<String, dynamic> json) {
        ResponseStatus = JsonConverters.fromJson(json['ResponseStatus'],'dynamic',context!);
        UserId = json['UserId'];
        UserProfile = JsonConverters.fromJson(json['UserProfile'],'UserProfileResponse',context!);
        AdminProfile = JsonConverters.fromJson(json['AdminProfile'],'AdminProfile',context!);
        IsSentConfirmationUpdateEmail = json['IsSentConfirmationUpdateEmail'];
        return this;
    }

    Map<String, dynamic> toJson() => {
        'ResponseStatus': JsonConverters.toJson(ResponseStatus,'dynamic',context!),
        'UserId': UserId,
        'UserProfile': JsonConverters.toJson(UserProfile,'UserProfileResponse',context!),
        'AdminProfile': JsonConverters.toJson(AdminProfile,'AdminProfile',context!),
        'IsSentConfirmationUpdateEmail': IsSentConfirmationUpdateEmail
    };

    getTypeName() => "UpdateUserResponse";
    TypeContext? context = _ctx;
}

class UpdateCustomerProfile implements IConvertible
{
    String? Firstname;
    String? Lastname;
    String? Phone;
    String? Email;

    UpdateCustomerProfile({this.Firstname,this.Lastname,this.Phone,this.Email});
    UpdateCustomerProfile.fromJson(Map<String, dynamic> json) { fromMap(json); }

    fromMap(Map<String, dynamic> json) {
        Firstname = json['Firstname'];
        Lastname = json['Lastname'];
        Phone = json['Phone'];
        Email = json['Email'];
        return this;
    }

    Map<String, dynamic> toJson() => {
        'Firstname': Firstname,
        'Lastname': Lastname,
        'Phone': Phone,
        'Email': Email
    };

    getTypeName() => "UpdateCustomerProfile";
    TypeContext? context = _ctx;
}

class UpdateAdminProfile implements IConvertible
{
    String? Firstname;
    String? Lastname;
    String? Phone;
    String? Email;

    UpdateAdminProfile({this.Firstname,this.Lastname,this.Phone,this.Email});
    UpdateAdminProfile.fromJson(Map<String, dynamic> json) { fromMap(json); }

    fromMap(Map<String, dynamic> json) {
        Firstname = json['Firstname'];
        Lastname = json['Lastname'];
        Phone = json['Phone'];
        Email = json['Email'];
        return this;
    }

    Map<String, dynamic> toJson() => {
        'Firstname': Firstname,
        'Lastname': Lastname,
        'Phone': Phone,
        'Email': Email
    };

    getTypeName() => "UpdateAdminProfile";
    TypeContext? context = _ctx;
}

enum KeyCloakRealm
{
    BookMore,
    BookMoreAdmin,
    SuperAdmin,
}

// @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 IConvertible
{
    /**
    * The user id for your profile.
    */
    // @ApiMember(Description="The user id for your profile.")
    String? UserId;

    String? NewEmail;
    UpdateCustomerProfile? UserProfile;
    UpdateAdminProfile? AdminProfile;
    /**
    * The user realm for identity server.  BookMore = 1, BookMoreAdmin = 2 
    */
    // @ApiMember(Description="The user realm for identity server.  BookMore = 1, BookMoreAdmin = 2 ", IsRequired=true)
    KeyCloakRealm? Realm;

    UpdateUser({this.UserId,this.NewEmail,this.UserProfile,this.AdminProfile,this.Realm});
    UpdateUser.fromJson(Map<String, dynamic> json) { fromMap(json); }

    fromMap(Map<String, dynamic> json) {
        UserId = json['UserId'];
        NewEmail = json['NewEmail'];
        UserProfile = JsonConverters.fromJson(json['UserProfile'],'UpdateCustomerProfile',context!);
        AdminProfile = JsonConverters.fromJson(json['AdminProfile'],'UpdateAdminProfile',context!);
        Realm = JsonConverters.fromJson(json['Realm'],'KeyCloakRealm',context!);
        return this;
    }

    Map<String, dynamic> toJson() => {
        'UserId': UserId,
        'NewEmail': NewEmail,
        'UserProfile': JsonConverters.toJson(UserProfile,'UpdateCustomerProfile',context!),
        'AdminProfile': JsonConverters.toJson(AdminProfile,'UpdateAdminProfile',context!),
        'Realm': JsonConverters.toJson(Realm,'KeyCloakRealm',context!)
    };

    getTypeName() => "UpdateUser";
    TypeContext? context = _ctx;
}

TypeContext _ctx = TypeContext(library: 'api.bokamera.se', types: <String, TypeInfo> {
    'UserProfileResponse': TypeInfo(TypeOf.Class, create:() => UserProfileResponse()),
    'AdminProfile': TypeInfo(TypeOf.Class, create:() => AdminProfile()),
    'UpdateUserResponse': TypeInfo(TypeOf.Class, create:() => UpdateUserResponse()),
    'UpdateCustomerProfile': TypeInfo(TypeOf.Class, create:() => UpdateCustomerProfile()),
    'UpdateAdminProfile': TypeInfo(TypeOf.Class, create:() => UpdateAdminProfile()),
    'KeyCloakRealm': TypeInfo(TypeOf.Enum, enumValues:KeyCloakRealm.values),
    'UpdateUser': TypeInfo(TypeOf.Class, create:() => UpdateUser()),
});

Dart UpdateUser DTOs

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

HTTP + CSV

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

PUT /users HTTP/1.1 
Host: api.bokamera.se 
Accept: text/csv
Content-Type: text/csv
Content-Length: length

{"UserId":"00000000-0000-0000-0000-000000000000","NewEmail":"String","UserProfile":{"Firstname":"String","Lastname":"String","Phone":"String","Email":"String"},"AdminProfile":{"Firstname":"String","Lastname":"String","Phone":"String","Email":"String"},"Realm":"BookMore"}
HTTP/1.1 200 OK
Content-Type: text/csv
Content-Length: length

{"ResponseStatus":{},"UserId":"00000000-0000-0000-0000-000000000000","UserProfile":{"Firstname":"String","Lastname":"String","Phone":"String","Email":"String"},"AdminProfile":{"Firstname":"String","Lastname":"String","Email":"String","WorkerId":"String","Phone":"String"},"IsSentConfirmationUpdateEmail":false}