| Requires any of the roles: | bookingsupplier-administrator-write, superadmin | 
| POST | /resource | Add a new resource | Add a new resource to the company of the currently logged in user, only administrators are allowed to add resources. | 
|---|
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 TimeException(ITimeException):
    # @ApiMember(Description="Time exception id")
    id: int = 0
    """
    Time exception id
    """
    # @ApiMember(Description="Indicates whether or not the time exception is recurring")
    is_recurring: bool = False
    """
    Indicates whether or not the time exception is recurring
    """
    # @ApiMember(Description="Indicates whether the time exception is blocking the time or not")
    is_block: bool = False
    """
    Indicates whether the time exception is blocking the time or not
    """
    # @ApiMember(Description="The reason of the time exception, example: Vacation, doctors appointment, ...")
    reason_text: Optional[str] = None
    """
    The reason of the time exception, example: Vacation, doctors appointment, ...
    """
    # @ApiMember(Description="The public reason of the time exception, example: Vacation, doctors appointment, ...")
    reason_text_public: Optional[str] = None
    """
    The public reason of the time exception, example: Vacation, doctors appointment, ...
    """
    # @ApiMember(Description="Time exception start")
    from_: datetime.datetime = field(metadata=config(field_name='from'), default=datetime.datetime(1, 1, 1))
    """
    Time exception start
    """
    # @ApiMember(Description="Time exception end")
    to: datetime.datetime = datetime.datetime(1, 1, 1)
    """
    Time exception end
    """
    # @ApiMember(Description="Resources that owns this exception")
    resource_ids: List[int] = field(default_factory=list)
    """
    Resources that owns this exception
    """
class BookingStatusEnum(IntEnum):
    BOOKED = 1
    UNBOOKED = 2
    RESERVED = 3
    CANCELED = 4
    AWAITING_PAYMENT = 5
    AWAITING_PAYMENT_NO_TIME_LIMIT = 6
    PAYED = 7
    AWAITING_PAYMENT_REQUEST_FROM_ADMIN = 8
    AWAITING_PAYMENT_FROM_PROVIDER = 9
    INVOICED = 10
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class BookedCustomer:
    id: Optional[str] = None
    firstname: Optional[str] = None
    lastname: Optional[str] = None
    email: Optional[str] = None
    phone: Optional[str] = None
    facebook_user_name: Optional[str] = None
    image_url: 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 BookedTime(IBookedTime):
    # @ApiMember(Description="Booking id")
    id: int = 0
    """
    Booking id
    """
    # @ApiMember(Description="The booked service")
    service_id: int = 0
    """
    The booked service
    """
    # @ApiMember(Description="Booking start")
    from_: datetime.datetime = field(metadata=config(field_name='from'), default=datetime.datetime(1, 1, 1))
    """
    Booking start
    """
    # @ApiMember(Description="Booking end")
    to: datetime.datetime = datetime.datetime(1, 1, 1)
    """
    Booking end
    """
    # @ApiMember(Description="Number of booked spots")
    booked_spots: int = 0
    """
    Number of booked spots
    """
    # @ApiMember(Description="Number of total spots for the service")
    total_spots: int = 0
    """
    Number of total spots for the service
    """
    # @ApiMember(Description="The pause after the booking")
    pause_after_in_minutes: int = 0
    """
    The pause after the booking
    """
    # @ApiMember(Description="The booking status")
    status_id: int = 0
    """
    The booking status
    """
    status: Optional[BookingStatusEnum] = None
    # @ApiMember(Description="The customer the booking belongs to")
    customer: Optional[BookedCustomer] = None
    """
    The customer the booking belongs to
    """
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class ResourceQueryResponse:
    # @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 description")
    description: Optional[str] = None
    """
    The resource description
    """
    # @ApiMember(Description="If resource is active or not")
    active: bool = False
    """
    If resource is active or not
    """
    # @ApiMember(Description="The resource color in scheduler in hexadecimal color code. Example: #00b0f0 for blue.")
    color: Optional[str] = None
    """
    The resource color in scheduler in hexadecimal color code. Example: #00b0f0 for blue.
    """
    # @ApiMember(Description="The Email of the resource")
    email: Optional[str] = None
    """
    The Email of the resource
    """
    # @ApiMember(Description="The Image URL of the resource")
    image_url: Optional[str] = None
    """
    The Image URL of the resource
    """
    # @ApiMember(Description="The Mobile phone number of the resource")
    mobile_phone: Optional[str] = None
    """
    The Mobile phone number of the resource
    """
    # @ApiMember(Description="Used by example code locks to know what access group the resource is assigned to")
    access_group: Optional[str] = None
    """
    Used by example code locks to know what access group the resource is assigned to
    """
    # @ApiMember(Description="If the resource should receive Email notification when booked")
    email_notification: bool = False
    """
    If the resource should receive Email notification when booked
    """
    # @ApiMember(Description="If the resource should receive SMS notification when booked")
    sms_notification: bool = False
    """
    If the resource should receive SMS notification when booked
    """
    # @ApiMember(Description="If the resource should receive Email reminders on bookings")
    send_email_reminder: Optional[bool] = None
    """
    If the resource should receive Email reminders on bookings
    """
    # @ApiMember(Description="If the resource should receive SMS reminders on bookings")
    send_s_m_s_reminder: Optional[bool] = None
    """
    If the resource should receive SMS reminders on bookings
    """
    # @ApiMember(Description="The resource time exceptions")
    exceptions: List[TimeException] = field(default_factory=list)
    """
    The resource time exceptions
    """
    # @ApiMember(Description="The resource bookings")
    bookings: List[BookedTime] = field(default_factory=list)
    """
    The resource bookings
    """
    # @ApiMember(Description="The date when the resource was created")
    created: datetime.datetime = datetime.datetime(1, 1, 1)
    """
    The date when the resource was created
    """
    # @ApiMember(Description="The date when the resource was updated")
    updated: datetime.datetime = datetime.datetime(1, 1, 1)
    """
    The date when the resource was updated
    """
    response_status: Optional[ResponseStatus] = None
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class AddCustomField:
    id: int = 0
    value: Optional[str] = None
# @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 CreateResource(ICompany):
    # @ApiMember(Description="Enter the company id, if blank company id and you are an admin, your company id will be used.", IsRequired=true)
    company_id: Optional[str] = None
    """
    Enter the company id, if blank company id and you are an admin, your company id will be used.
    """
    # @ApiMember(Description="The resource name")
    name: Optional[str] = None
    """
    The resource name
    """
    # @ApiMember(Description="The resource description")
    description: Optional[str] = None
    """
    The resource description
    """
    # @ApiMember(Description="If resource is active or not. Default is active.")
    active: bool = False
    """
    If resource is active or not. Default is active.
    """
    # @ApiMember(Description="The resource color in scheduler")
    color: Optional[str] = None
    """
    The resource color in scheduler
    """
    # @ApiMember(Description="The Email of the resource")
    email: Optional[str] = None
    """
    The Email of the resource
    """
    # @ApiMember(Description="The Image URL of the resource")
    image_url: Optional[str] = None
    """
    The Image URL of the resource
    """
    # @ApiMember(Description="Used by example code locks to know what access group the resource is assigned to")
    access_group: Optional[str] = None
    """
    Used by example code locks to know what access group the resource is assigned to
    """
    # @ApiMember(Description="The Mobile phone number of the resource")
    mobile_phone: Optional[str] = None
    """
    The Mobile phone number of the resource
    """
    # @ApiMember(Description="If the resource should receive email notification when booked")
    email_notification: Optional[bool] = None
    """
    If the resource should receive email notification when booked
    """
    # @ApiMember(Description="If the resource should receive SMS notification when booked")
    sms_notification: Optional[bool] = None
    """
    If the resource should receive SMS notification when booked
    """
    # @ApiMember(Description="If the resource should receive Email reminders on bookings")
    send_email_reminder: Optional[bool] = None
    """
    If the resource should receive Email reminders on bookings
    """
    # @ApiMember(Description="If the resource should receive SMS reminders on bookings")
    send_s_m_s_reminder: Optional[bool] = None
    """
    If the resource should receive SMS reminders on bookings
    """
    # @ApiMember(Description="If Custom Fields are added to the resource, here you will send the id and the value for each custom field to be saved")
    custom_fields: List[AddCustomField] = field(default_factory=list)
    """
    If Custom Fields are added to the resource, here you will send the id and the value for each custom field to be saved
    """
To override the Content-type in your clients, use the HTTP Accept Header, append the .jsv suffix or ?format=jsv
The following are sample HTTP requests and responses. The placeholders shown need to be replaced with actual values.
POST /resource 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,
	Description: String,
	Active: False,
	Color: String,
	Email: String,
	AccessGroup: String,
	MobilePhone: String,
	EmailNotification: False,
	SMSNotification: False,
	SendEmailReminder: False,
	SendSMSReminder: False,
	CustomFields: 
	[
		{
			Id: 0,
			Value: String
		}
	]
}
HTTP/1.1 200 OK
Content-Type: text/jsv
Content-Length: length
{
	Id: 0,
	Name: String,
	Description: String,
	Active: False,
	Color: String,
	Email: String,
	MobilePhone: String,
	AccessGroup: String,
	EmailNotification: False,
	SMSNotification: False,
	SendEmailReminder: False,
	SendSMSReminder: False,
	Exceptions: 
	[
		{
			Id: 0,
			IsRecurring: False,
			IsBlock: False,
			ReasonText: String,
			ReasonTextPublic: String,
			ResourceIds: 
			[
				0
			]
		}
	],
	Bookings: 
	[
		{
			Id: 0,
			ServiceId: 0,
			BookedSpots: 0,
			TotalSpots: 0,
			PauseAfterInMinutes: 0,
			StatusId: 0,
			Status: Booked,
			Customer: 
			{
				Firstname: String,
				Lastname: String,
				Email: String,
				Phone: String,
				FacebookUserName: String,
				ImageUrl: String,
				CorporateIdentityNumber: String,
				InvoiceAddress1: String,
				InvoiceAddress2: String,
				InvoiceCity: String,
				InvoicePostalCode: String,
				InvoiceCountryCode: String
			}
		}
	],
	ResponseStatus: 
	{
		ErrorCode: String,
		Message: String,
		StackTrace: String,
		Errors: 
		[
			{
				ErrorCode: String,
				FieldName: String,
				Message: String,
				Meta: 
				{
					String: String
				}
			}
		],
		Meta: 
		{
			String: String
		}
	}
}