Reservation Station API

<back to all web services

FindBookingRate

Requires Authentication
import Foundation
import ServiceStack

public class FindBookingRate : ApiServiceRequest
{
    public var facilityId:Int
    public var bookingUserId:Int
    public var requestedSlots:[SlotData] = []
    public var isNew:Bool
    public var isGuest:Bool

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

    private enum CodingKeys : String, CodingKey {
        case facilityId
        case bookingUserId
        case requestedSlots
        case isNew
        case isGuest
    }

    required public init(from decoder: Decoder) throws {
        try super.init(from: decoder)
        let container = try decoder.container(keyedBy: CodingKeys.self)
        facilityId = try container.decodeIfPresent(Int.self, forKey: .facilityId)
        bookingUserId = try container.decodeIfPresent(Int.self, forKey: .bookingUserId)
        requestedSlots = try container.decodeIfPresent([SlotData].self, forKey: .requestedSlots) ?? []
        isNew = try container.decodeIfPresent(Bool.self, forKey: .isNew)
        isGuest = try container.decodeIfPresent(Bool.self, forKey: .isGuest)
    }

    public override func encode(to encoder: Encoder) throws {
        try super.encode(to: encoder)
        var container = encoder.container(keyedBy: CodingKeys.self)
        if facilityId != nil { try container.encode(facilityId, forKey: .facilityId) }
        if bookingUserId != nil { try container.encode(bookingUserId, forKey: .bookingUserId) }
        if requestedSlots.count > 0 { try container.encode(requestedSlots, forKey: .requestedSlots) }
        if isNew != nil { try container.encode(isNew, forKey: .isNew) }
        if isGuest != nil { try container.encode(isGuest, forKey: .isGuest) }
    }
}

public class ApiServiceRequest : IServiceRequest, IHasApiKey, IHasDeviceInfo, Codable
{
    /**
    * The API Key required for authentication
    */
    // @ApiMember(DataType="string", Description="The API Key required for authentication", IsRequired=true)
    public var apiKey:String

    /**
    * Latitude of the user making this request
    */
    // @ApiMember(DataType="double", Description="Latitude of the user making this request")
    public var latitude:Double

    /**
    * Longitude of the user making this request
    */
    // @ApiMember(DataType="double", Description="Longitude of the user making this request")
    public var longitude:Double

    required public init(){}
}

public class SlotData : Codable
{
    public var start:String
    public var end:String
    public var status:SlotStatus
    public var bookingId:Int
    public var remindStart:Bool
    public var remind30Mins:Bool
    public var remind1Hour:Bool
    public var remind6Hours:Bool
    public var remind12Hours:Bool
    public var remind1Day:Bool
    public var remind1Week:Bool
    public var billableAmount:Double
    public var bookedByName:String
    public var billableHours:Double
    public var slotLength:Double
    public var userData:GuestData
    public var extraRequirements:String

    required public init(){}
}

public enum SlotStatus : Int, Codable
{
    case Available = 0
    case Closed = 1
    case Booked = 2
    case UserBooked = 3
    case GroupBooked = 4
    case ToBook = 5
}

public class GuestData : Codable
{
    public var name:String
    public var emailAddress:String
    public var mobileNumber:String
    public var userCustomFields:[UserCustomFieldData] = []
    public var isAlreadyUser:Bool
    public var systemUserId:Int

    required public init(){}
}

public class UserCustomFieldData : Codable
{
    public var id:String
    public var value:String
    public var name:String
    public var optional:Bool

    required public init(){}
}

public class FindBookingRateResponse : ApiServiceResponse
{
    public var updatedSlot:[SlotData] = []
    public var rates:[Double] = []
    public var wasMerge:Bool

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

    private enum CodingKeys : String, CodingKey {
        case updatedSlot
        case rates
        case wasMerge
    }

    required public init(from decoder: Decoder) throws {
        try super.init(from: decoder)
        let container = try decoder.container(keyedBy: CodingKeys.self)
        updatedSlot = try container.decodeIfPresent([SlotData].self, forKey: .updatedSlot) ?? []
        rates = try container.decodeIfPresent([Double].self, forKey: .rates) ?? []
        wasMerge = try container.decodeIfPresent(Bool.self, forKey: .wasMerge)
    }

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

public class ApiServiceResponse : IServiceResponse, Codable
{
    public var Description:String
    public var heading:String
    public var wasSuccessful:Bool
    //modelState:Object ignored. Type could not be extended in Swift

    required public init(){}
}


Swift FindBookingRate 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 /jsv/reply/FindBookingRate HTTP/1.1 
Host: reservation.api.dev.86degrees.com 
Accept: text/jsv
Content-Type: text/jsv
Content-Length: length

{
	facilityId: 0,
	bookingUserId: 0,
	requestedSlots: 
	[
		{
			start: String,
			end: String,
			status: 0,
			bookingId: 0,
			remindStart: False,
			remind30Mins: False,
			remind1Hour: False,
			remind6Hours: False,
			remind12Hours: False,
			remind1Day: False,
			remind1Week: False,
			billableAmount: 0,
			bookedByName: String,
			billableHours: 0,
			slotLength: 0,
			extraRequirements: String
		}
	],
	isNew: False,
	isGuest: False,
	apiKey: String,
	latitude: 0,
	longitude: 0
}
HTTP/1.1 200 OK
Content-Type: text/jsv
Content-Length: length

{
	updatedSlot: 
	[
		{
			start: String,
			end: String,
			status: 0,
			bookingId: 0,
			remindStart: False,
			remind30Mins: False,
			remind1Hour: False,
			remind6Hours: False,
			remind12Hours: False,
			remind1Day: False,
			remind1Week: False,
			billableAmount: 0,
			bookedByName: String,
			billableHours: 0,
			slotLength: 0,
			extraRequirements: String
		}
	],
	rates: 
	[
		0
	],
	wasMerge: False,
	description: String,
	heading: String,
	wasSuccessful: False,
	modelState: {}
}