BokaMera.API.Host

<back to all web services

UpdateBookingReservation

The following routes are available for this service:
PUT/bookingreservations/{SessionKey}Update a booking reservationUpdates an existing reservation identified by its session key. If the slot (From/To) changes the availability is re-checked for the new slot and the hold expiration is recomputed.
import Foundation
import ServiceStack

// @ApiResponse(Description="You were unauthorized to call this service", StatusCode=401)
// @ApiResponse(Description="No reservation found for the given session key", StatusCode=404)
// @ApiResponse(Description="The selected slot is no longer available", StatusCode=409)
public class UpdateBookingReservation : CreateBookingBase, IInterval
{
    /**
    * The opaque session key that identifies the reservation.
    */
    // @ApiMember(Description="The opaque session key that identifies the reservation.", IsRequired=true, ParameterType="path")
    public var sessionKey:String

    /**
    * The datetime you want to start the reservation.
    */
    // @ApiMember(Description="The datetime you want to start the reservation.", IsRequired=true)
    public var from:Date

    /**
    * The datetime you want to end the reservation.
    */
    // @ApiMember(Description="The datetime you want to end the reservation.", IsRequired=true)
    public var to:Date

    /**
    * Set the number of spots you want to reserve. You add number of spots per price category. Multiple spots require that the service has GroupBooking enabled. Default is one spot.
    */
    // @ApiMember(Description="Set the number of spots you want to reserve. You add number of spots per price category. Multiple spots require that the service has GroupBooking enabled. Default is one spot.")
    public var quantities:[QuantityToBook] = []

    required public init(){ super.init() }

    private enum CodingKeys : String, CodingKey {
        case sessionKey
        case from
        case to
        case quantities
    }

    required public init(from decoder: Decoder) throws {
        try super.init(from: decoder)
        let container = try decoder.container(keyedBy: CodingKeys.self)
        sessionKey = try container.decodeIfPresent(String.self, forKey: .sessionKey)
        from = try container.decodeIfPresent(Date.self, forKey: .from)
        to = try container.decodeIfPresent(Date.self, forKey: .to)
        quantities = try container.decodeIfPresent([QuantityToBook].self, forKey: .quantities) ?? []
    }

    public override func encode(to encoder: Encoder) throws {
        try super.encode(to: encoder)
        var container = encoder.container(keyedBy: CodingKeys.self)
        if sessionKey != nil { try container.encode(sessionKey, forKey: .sessionKey) }
        if from != nil { try container.encode(from, forKey: .from) }
        if to != nil { try container.encode(to, forKey: .to) }
        if quantities.count > 0 { try container.encode(quantities, forKey: .quantities) }
    }
}

public class CreateBookingBase : ICreateBookingBase, Codable
{
    /**
    * The company id, if empty will use the company id for the user you are logged in with.
    */
    // @ApiMember(Description="The company id, if empty will use the company id for the user you are logged in with.")
    public var companyId:String?

    /**
    * If you want to book on an existing customer instead of CustomerToBook info set the CustomerId here. Set Empty Guid (00000000-0000-0000-0000-000000000000) if you want to book without any customer, this is only allowed by admin. The customer id is shown in the customer list named as id. When booking as customer (no admin) leave this field blank.
    */
    // @ApiMember(Description="If you want to book on an existing customer instead of CustomerToBook info set the CustomerId here. Set Empty Guid (00000000-0000-0000-0000-000000000000) if you want to book without any customer, this is only allowed by admin. The customer id is shown in the customer list named as id. When booking as customer (no admin) leave this field blank.")
    public var customerId:String?

    /**
    * If company requires to be authenticated or a pin code entered to book on a specific customer, enter it here.
    */
    // @ApiMember(Description="If company requires to be authenticated or a pin code entered to book on a specific customer, enter it here.")
    public var pinCode:String

    /**
    * If you want to book with customer information instead of the Customer Id send the customer information here. Note: If customer profile already exists with the same email the information will not be changed, instead the provided information will be added as BookingsComments if it differs from the ordinary profile. 
    */
    // @ApiMember(Description="If you want to book with customer information instead of the Customer Id send the customer information here. Note: If customer profile already exists with the same email the information will not be changed, instead the provided information will be added as BookingsComments if it differs from the ordinary profile. ")
    public var customer:CustomerToHandle

    /**
    * If you want to book with customer information instead of the Customer Id send the customer information here. Note: If customer profile already exists with the same email the information will not be changed, instead the provided information will be added as BookingsComments if it differs from the ordinary profile. 
    */
    // @ApiMember(Description="If you want to book with customer information instead of the Customer Id send the customer information here. Note: If customer profile already exists with the same email the information will not be changed, instead the provided information will be added as BookingsComments if it differs from the ordinary profile. ")
    public var invoiceAddress:InvoiceAddressToHandle

    /**
    * The service to be booked
    */
    // @ApiMember(Description="The service to be booked", IsRequired=true)
    public var serviceId:Int

    /**
    * If you want to add comments to a booking you can add them here, this comments are never shared with the customer
    */
    // @ApiMember(Description="If you want to add comments to a booking you can add them here, this comments are never shared with the customer")
    public var bookedComments:String

    /**
    * If you want to add comments to the booking that is sent to the customer, you can add them here. Comments will be sent in the booking confirmation
    */
    // @ApiMember(Description="If you want to add comments to the booking that is sent to the customer, you can add them here. Comments will be sent in the booking confirmation")
    public var commentsToCustomer:String

    public var resources:[ResourceToBook] = []
    /**
    * Rebate codes applied to booking
    */
    // @ApiMember(Description="Rebate codes applied to booking")
    public var rebateCodeIds:[Int]

    /**
    * Article ids that should be booked with the service. The articles must be of type ServiceAddonArticle and connected to the service.
    */
    // @ApiMember(Description="Article ids that should be booked with the service. The articles must be of type ServiceAddonArticle and connected to the service.", IsRequired=true)
    public var articles:[ArticleToCreateBase] = []

    /**
    * If you want to send Email reminder
    */
    // @ApiMember(Description="If you want to send Email reminder")
    public var sendEmailReminder:Bool?

    /**
    * If you want to send SMS reminder
    */
    // @ApiMember(Description="If you want to send SMS reminder")
    public var sendSmsReminder:Bool?

    /**
    * If you want to send SMS confirmation
    */
    // @ApiMember(Description="If you want to send SMS confirmation")
    public var sendSmsConfirmation:Bool?

    /**
    * Only admins are allowed to not send an email confirmation. Default is true
    */
    // @ApiMember(Description="Only admins are allowed to not send an email confirmation. Default is true")
    public var sendEmailConfirmation:Bool?

    /**
    * If payment is enabled and you're an administrator, optional to choose payment option, if empty then the default settings will be used. Following payment options exists. DefaultSetting = 0, BookWithoutPayment = 1 (will be direcyly booked without payment), BookWithPaymentMessageToCustomer = 2 (will set status AwaitingPayment and send payment instructions to customer), BookWithManualPayment = 3 (Will set status AwaitingPaymentNoTimeLimit and Admin will need to manually mark the booking as payed when recieved payment).
    */
    // @ApiMember(Description="If payment is enabled and you're an administrator, optional to choose payment option, if empty then the default settings will be used. Following payment options exists. DefaultSetting = 0, BookWithoutPayment = 1 (will be direcyly booked without payment), BookWithPaymentMessageToCustomer = 2 (will set status AwaitingPayment and send payment instructions to customer), BookWithManualPayment = 3 (Will set status AwaitingPaymentNoTimeLimit and Admin will need to manually mark the booking as payed when recieved payment).")
    public var paymentOption:PaymentOptions

    /**
    * If Custom Fields are added to the booking, here you will send the id and the value for each custom field to be saved
    */
    // @ApiMember(Description="If Custom Fields are added to the booking, here you will send the id and the value for each custom field to be saved")
    public var customFields:[AddCustomField] = []

    /**
    * If Custom Fields are added to the customer, here you will send the id and the value for each custom field to be updated
    */
    // @ApiMember(Description="If Custom Fields are added to the customer, here you will send the id and the value for each custom field to be updated")
    public var customerCustomFields:[AddCustomField] = []

    /**
    * If want to allow to book outside the service schedules. This means you can book a time after the schedule opening hours as long as the resource are available. This is only allowed by administrators
    */
    // @ApiMember(Description="If want to allow to book outside the service schedules. This means you can book a time after the schedule opening hours as long as the resource are available. This is only allowed by administrators")
    public var allowBookingOutsideSchedules:Bool

    /**
    * Ids of tags to attach to the booking at creation time. Tags must have Scope = Booking and belong to the company.
    */
    // @ApiMember(Description="Ids of tags to attach to the booking at creation time. Tags must have Scope = Booking and belong to the company.")
    public var tagIds:[Int] = []

    required public init(){}
}

public class CustomerToHandle : CustomerBase
{
    required public init(){ super.init() }

    required public init(from decoder: Decoder) throws {
        try super.init(from: decoder)
    }

    public override func encode(to encoder: Encoder) throws {
        try super.encode(to: encoder)
    }
}

public class CustomerBase : ICustomerBase, Codable
{
    public var customerId:String?
    public var firstname:String
    public var lastname:String
    public var email:String
    public var phone:String
    public var subscribedToNewsletter:Bool
    public var personalIdentityNumber:String

    required public init(){}
}

public class InvoiceAddressToHandle : IInvoiceAddress, Codable
{
    public var corporateIdentityNumber:String
    public var invoiceAddress1:String
    public var invoiceAddress2:String
    public var invoiceCity:String
    public var invoicePostalCode:String
    public var invoiceCountryCode:String

    required public init(){}
}

public class ResourceToBook : Codable
{
    public var resourceTypeId:Int
    public var resourceId:Int

    required public init(){}
}

public class ArticleToCreateBase : Codable
{
    public var articleId:Int
    public var quantity:Int

    required public init(){}
}

public enum PaymentOptions : String, Codable
{
    case DefaultSetting
    case BookWithoutPayment
    case BookWithPaymentMessageToCustomer
    case BookWithManualPayment
}

public class AddCustomField : Codable
{
    public var id:Int
    public var value:String

    required public init(){}
}

public class QuantityToBook : Codable
{
    /**
    * If service has a price, enter the price id for that price. If no price exists for the service set 0 as PriceId. If you put 0 and a price exists, it will use that price (only works if just one price exists for the current selected date to book)
    */
    // @ApiMember(Description="If service has a price, enter the price id for that price. If no price exists for the service set 0 as PriceId. If you put 0 and a price exists, it will use that price (only works if just one price exists for the current selected date to book)", IsRequired=true)
    public var priceId:Int

    /**
    * Set the number of spots or resources you want to book on the specific price category
    */
    // @ApiMember(Description="Set the number of spots or resources you want to book on the specific price category", IsRequired=true)
    public var quantity:Int

    /**
    * If the quantity you add should occupy a spot. Default is true. If no it will only be a row that includes price information.
    */
    // @ApiMember(Description="If the quantity you add should occupy a spot. Default is true. If no it will only be a row that includes price information.")
    public var occupiesSpot:Bool

    required public init(){}
}

public class BookingReservationResponse : Codable
{
    /**
    * The opaque session key that identifies the reservation.
    */
    // @ApiMember(Description="The opaque session key that identifies the reservation.")
    public var sessionKey:String

    /**
    * The company id.
    */
    // @ApiMember(Description="The company id.")
    public var companyId:String

    /**
    * The reserved service id.
    */
    // @ApiMember(Description="The reserved service id.")
    public var serviceId:Int

    /**
    * The reservation start.
    */
    // @ApiMember(Description="The reservation start.")
    public var from:Date

    /**
    * The reservation end.
    */
    // @ApiMember(Description="The reservation end.")
    public var to:Date

    /**
    * The BookingReservationStatus value.
    */
    // @ApiMember(Description="The BookingReservationStatus value.")
    public var statusCode:Int

    /**
    * The BookingReservationStatus name.
    */
    // @ApiMember(Description="The BookingReservationStatus name.")
    public var statusName:String

    /**
    * When the hold expires (company-local time).
    */
    // @ApiMember(Description="When the hold expires (company-local time).")
    public var expirationDatetime:Date

    /**
    * Number of reserved spots.
    */
    // @ApiMember(Description="Number of reserved spots.")
    public var numberOfBookedSpots:Int

    /**
    * The computed price of the reservation, if any.
    */
    // @ApiMember(Description="The computed price of the reservation, if any.")
    public var price:Double?

    /**
    * The currency of the price, if any.
    */
    // @ApiMember(Description="The currency of the price, if any.")
    public var currencyId:String

    /**
    * Ids of the resources held by the reservation.
    */
    // @ApiMember(Description="Ids of the resources held by the reservation.")
    public var resourceIds:[Int] = []

    /**
    * The full in-progress selection payload (wizard/session state) as JSON.
    */
    // @ApiMember(Description="The full in-progress selection payload (wizard/session state) as JSON.")
    public var selectionPayload:String

    public var responseStatus:ResponseStatus

    required public init(){}
}


Swift UpdateBookingReservation 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.

PUT /bookingreservations/{SessionKey} HTTP/1.1 
Host: testapi.bokamera.se 
Accept: text/jsv
Content-Type: text/jsv
Content-Length: length

{
	Quantities: 
	[
		{
			PriceId: 0,
			Quantity: 0,
			OccupiesSpot: False
		}
	],
	CompanyId: 00000000-0000-0000-0000-000000000000,
	CustomerId: 00000000-0000-0000-0000-000000000000,
	PinCode: String,
	Customer: 
	{
		CustomerId: 00000000-0000-0000-0000-000000000000,
		Firstname: String,
		Lastname: String,
		Email: String,
		Phone: String,
		SubscribedToNewsletter: False,
		PersonalIdentityNumber: String
	},
	InvoiceAddress: 
	{
		CorporateIdentityNumber: String,
		InvoiceAddress1: String,
		InvoiceAddress2: String,
		InvoiceCity: String,
		InvoicePostalCode: String,
		InvoiceCountryCode: String
	},
	ServiceId: 0,
	BookedComments: String,
	CommentsToCustomer: String,
	Resources: 
	[
		{
			ResourceTypeId: 0,
			ResourceId: 0
		}
	],
	RebateCodeIds: 
	[
		0
	],
	Articles: 
	[
		{
			ArticleId: 0,
			Quantity: 0
		}
	],
	SendEmailReminder: False,
	SendSmsReminder: False,
	SendSmsConfirmation: False,
	SendEmailConfirmation: False,
	PaymentOption: DefaultSetting,
	CustomFields: 
	[
		{
			Id: 0,
			Value: String
		}
	],
	CustomerCustomFields: 
	[
		{
			Id: 0,
			Value: String
		}
	],
	AllowBookingOutsideSchedules: False,
	TagIds: 
	[
		0
	]
}
HTTP/1.1 200 OK
Content-Type: text/jsv
Content-Length: length

{
	ServiceId: 0,
	StatusCode: 0,
	StatusName: String,
	NumberOfBookedSpots: 0,
	Price: 0,
	CurrencyId: String,
	ResourceIds: 
	[
		0
	],
	SelectionPayload: String,
	ResponseStatus: 
	{
		ErrorCode: String,
		Message: String,
		StackTrace: String,
		Errors: 
		[
			{
				ErrorCode: String,
				FieldName: String,
				Message: String,
				Meta: 
				{
					String: String
				}
			}
		],
		Meta: 
		{
			String: String
		}
	}
}