BokaMera.API.Host

<back to all web services

CreateResourceType

Requires Authentication
Requires any of the roles:bookingsupplier-administrator-write, superadmin
The following routes are available for this service:
POST/resourcetypesAdd a new resourcetypeAdd a new resourcetype to the company of the currently logged in user, only administrators are allowed to add resourcetypes.
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 ResourceTypeResource:
    # @ApiMember(Description="The resource id")
    id: int = 0
    """
    The resource id
    """


    # @ApiMember(Description="The resource name")
    name: Optional[str] = None
    """
    The resource name
    """


    # @ApiMember(Description="The resource status")
    active: bool = False
    """
    The resource status
    """


    # @ApiMember(Description="The resource description")
    description: Optional[str] = None
    """
    The resource description
    """


    # @ApiMember(Description="The resource email")
    email: Optional[str] = None
    """
    The resource email
    """


    # @ApiMember(Description="The resource phone")
    phone: Optional[str] = None
    """
    The resource phone
    """


    # @ApiMember(Description="The resource color")
    color: Optional[str] = None
    """
    The resource color
    """


    # @ApiMember(Description="The resource image")
    image_url: Optional[str] = None
    """
    The resource image
    """


    # @ApiMember(Description="The priority of the resource")
    priority: int = 0
    """
    The priority of the resource
    """


    # @ApiMember(Description="If the resource want to receive email notifications")
    email_notification: bool = False
    """
    If the resource want to receive email notifications
    """


    # @ApiMember(Description="If the resource want to receive sms notifications")
    sms_notification: bool = False
    """
    If the resource want to receive sms notifications
    """


    # @ApiMember(Description="If the resource want to receive email reminders")
    email_reminder: bool = False
    """
    If the resource want to receive email reminders
    """


    # @ApiMember(Description="If the resource want to receive sms reminders")
    sms_reminder: bool = False
    """
    If the resource want to receive sms reminders
    """


@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class ResourceTypeQueryResponse:
    # @ApiMember(Description="The resourcetype id")
    id: int = 0
    """
    The resourcetype id
    """


    # @ApiMember(Description="The resourcetype name")
    name: Optional[str] = None
    """
    The resourcetype name
    """


    # @ApiMember(Description="The resourcetype description")
    description: Optional[str] = None
    """
    The resourcetype description
    """


    # @ApiMember(Description="The resources in the resourcetype. Only shows active resources if not admin.")
    resources: Optional[List[ResourceTypeResource]] = None
    """
    The resources in the resourcetype. Only shows active resources if not admin.
    """


    # @ApiMember(Description="If resourcetype is active or not")
    active: bool = False
    """
    If resourcetype is active or not
    """


    # @ApiMember(Description="Then date when the resource was created")
    created: datetime.datetime = datetime.datetime(1, 1, 1)
    """
    Then date when the resource was created
    """


    # @ApiMember(Description="Then date when the resource was updated")
    updated: datetime.datetime = datetime.datetime(1, 1, 1)
    """
    Then date when the resource was updated
    """


@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class AddResourceTypeResource:
    # @ApiMember(Description="The resource id")
    id: int = 0
    """
    The resource id
    """


    # @ApiMember(Description="The priority of the resource. If no priority is set it will take random resource when booking a time.")
    priority: int = 0
    """
    The priority of the resource. If no priority is set it will take random resource when booking a time.
    """


# @ApiResponse(Description="You were unauthorized to call this service", StatusCode=401)
# @ApiResponse(Description="You have too low privilegies to call this service", StatusCode=403)
# @ValidateRequest(Validator="IsAuthenticated")
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class CreateResourceType(ICompany):
    # @ApiMember(Description="The company id, if empty will use the company id for the user you are logged in with.")
    company_id: Optional[str] = None
    """
    The company id, if empty will use the company id for the user you are logged in with.
    """


    # @ApiMember(Description="The resourcetype name")
    name: Optional[str] = None
    """
    The resourcetype name
    """


    # @ApiMember(Description="The resources to be included")
    resources: Optional[List[AddResourceTypeResource]] = None
    """
    The resources to be included
    """


    # @ApiMember(Description="The resourcetype description")
    description: Optional[str] = None
    """
    The resourcetype description
    """


    # @ApiMember(Description="If resourcetype is active or not")
    active: bool = False
    """
    If resourcetype is active or not
    """

Python CreateResourceType 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 /resourcetypes HTTP/1.1 
Host: api.bokamera.se 
Accept: text/jsv
Content-Type: text/jsv
Content-Length: length

{
	CompanyId: 00000000-0000-0000-0000-000000000000,
	Name: String,
	Resources: 
	[
		{
			Id: 0,
			Priority: 0
		}
	],
	Description: String,
	Active: False
}
HTTP/1.1 200 OK
Content-Type: text/jsv
Content-Length: length

{
	Id: 0,
	Name: String,
	Description: String,
	Resources: 
	[
		{
			Id: 0,
			Name: String,
			Active: False,
			Description: String,
			Email: String,
			Phone: String,
			Color: String,
			Priority: 0,
			EmailNotification: False,
			SMSNotification: False,
			EmailReminder: False,
			SMSReminder: False
		}
	],
	Active: False
}