| PUT | /users | Update my information | Updates 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 datetime
import decimal
from marshmallow.fields import *
from servicestack import *
from typing import *
from dataclasses import dataclass, field
from dataclasses_json import dataclass_json, LetterCase, Undefined, config
from enum import Enum, IntEnum
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class InvoiceAddressResponse:
invoice_address_id: Optional[str] = None
user_id: Optional[str] = None
corporate_identity_number: Optional[str] = None
invoice_address1: Optional[str] = None
invoice_address2: Optional[str] = None
invoice_city: Optional[str] = None
invoice_postal_code: Optional[str] = None
invoice_country_code: Optional[str] = None
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class UserProfileResponse:
id: Optional[str] = None
firstname: Optional[str] = None
lastname: Optional[str] = None
phone: Optional[str] = None
email: Optional[str] = None
invoice_address: Optional[InvoiceAddressResponse] = None
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class AdminProfile:
company_id: Optional[str] = None
id: Optional[str] = None
firstname: Optional[str] = None
lastname: Optional[str] = None
email: Optional[str] = None
worker_id: Optional[str] = None
phone: Optional[str] = None
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class UpdateUserResponse:
response_status: Optional[Object] = None
# @ApiMember(Description="The user id for your profile.", IsRequired=true)
user_id: Optional[str] = None
"""
The user id for your profile.
"""
user_profile: Optional[UserProfileResponse] = None
admin_profile: Optional[AdminProfile] = None
is_sent_confirmation_update_email: Optional[bool] = None
invoice_address: Optional[InvoiceAddressResponse] = None
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class UpdateCustomerProfile:
firstname: Optional[str] = None
lastname: Optional[str] = None
phone: Optional[str] = None
email: Optional[str] = None
invoice_address: Optional[InvoiceAddressResponse] = None
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class UpdateAdminProfile:
firstname: Optional[str] = None
lastname: Optional[str] = None
phone: Optional[str] = None
email: Optional[str] = None
class KeyCloakRealm(IntEnum):
BOOK_MORE = 1
BOOK_MORE_ADMIN = 2
SUPER_ADMIN = 3
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class InvoiceAddressToHandle(IInvoiceAddress):
corporate_identity_number: Optional[str] = None
invoice_address1: Optional[str] = None
invoice_address2: Optional[str] = None
invoice_city: Optional[str] = None
invoice_postal_code: Optional[str] = None
invoice_country_code: Optional[str] = None
# @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")
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class UpdateUser:
# @ApiMember(Description="The user id for your profile.")
user_id: Optional[str] = None
"""
The user id for your profile.
"""
new_email: Optional[str] = None
user_profile: Optional[UpdateCustomerProfile] = None
admin_profile: Optional[UpdateAdminProfile] = None
# @ApiMember(Description="The user realm for identity server. BookMore = 1, BookMoreAdmin = 2 ", IsRequired=true)
realm: Optional[KeyCloakRealm] = None
"""
The user realm for identity server. BookMore = 1, BookMoreAdmin = 2
"""
invoice_address: Optional[InvoiceAddressToHandle] = None
To override the Content-type in your clients, use the HTTP Accept Header, append the .xml suffix or ?format=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>
<InvoiceAddress>
<CorporateIdentityNumber>String</CorporateIdentityNumber>
<InvoiceAddress1>String</InvoiceAddress1>
<InvoiceAddress2>String</InvoiceAddress2>
<InvoiceCity>String</InvoiceCity>
<InvoiceCountryCode>String</InvoiceCountryCode>
<InvoicePostalCode>String</InvoicePostalCode>
</InvoiceAddress>
<NewEmail>String</NewEmail>
<Realm>BookMore</Realm>
<UserId>00000000-0000-0000-0000-000000000000</UserId>
<UserProfile>
<Email>String</Email>
<Firstname>String</Firstname>
<InvoiceAddress>
<CorporateIdentityNumber>String</CorporateIdentityNumber>
<InvoiceAddress1>String</InvoiceAddress1>
<InvoiceAddress2>String</InvoiceAddress2>
<InvoiceAddressId>00000000-0000-0000-0000-000000000000</InvoiceAddressId>
<InvoiceCity>String</InvoiceCity>
<InvoiceCountryCode>String</InvoiceCountryCode>
<InvoicePostalCode>String</InvoicePostalCode>
<UserId>00000000-0000-0000-0000-000000000000</UserId>
</InvoiceAddress>
<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>
<InvoiceAddress>
<CorporateIdentityNumber>String</CorporateIdentityNumber>
<InvoiceAddress1>String</InvoiceAddress1>
<InvoiceAddress2>String</InvoiceAddress2>
<InvoiceAddressId>00000000-0000-0000-0000-000000000000</InvoiceAddressId>
<InvoiceCity>String</InvoiceCity>
<InvoiceCountryCode>String</InvoiceCountryCode>
<InvoicePostalCode>String</InvoicePostalCode>
<UserId>00000000-0000-0000-0000-000000000000</UserId>
</InvoiceAddress>
<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>
<InvoiceAddress>
<CorporateIdentityNumber>String</CorporateIdentityNumber>
<InvoiceAddress1>String</InvoiceAddress1>
<InvoiceAddress2>String</InvoiceAddress2>
<InvoiceAddressId>00000000-0000-0000-0000-000000000000</InvoiceAddressId>
<InvoiceCity>String</InvoiceCity>
<InvoiceCountryCode>String</InvoiceCountryCode>
<InvoicePostalCode>String</InvoicePostalCode>
<UserId>00000000-0000-0000-0000-000000000000</UserId>
</InvoiceAddress>
<Lastname>String</Lastname>
<Phone>String</Phone>
</UserProfile>
</UpdateUserResponse>