GET | /BookingsByTraveller |
---|
import Foundation
import ServiceStack
// @DataContract(Namespace="schemas.agentivity.com/types")
public class GetBookingsByTraveller : CompanyLevelRequestBase
{
/**
* Traveller CRM ID or reference
*/
// @DataMember
public var travellerReference:String
/**
* Agentivity Traveller GUID
*/
// @DataMember
public var travellerGUID:String
/**
* Date in format YYYYMMDD
*/
// @DataMember
public var travelDateStart:String
/**
* Date in format YYYYMMDD
*/
// @DataMember
public var travelDateEnd:String
/**
* Last name
*/
// @DataMember
public var lastName:String
/**
* First name
*/
// @DataMember
public var firstName:String
/**
* Include Itinerary in the response
*/
// @DataMember
public var includeItinerary:Bool
/**
* Indicates the required formatting: 0=None(Default); 1= Html; 2 = Chart
*/
// @DataMember
public var itineraryFormatting:FormattingStyle
/**
* Itinerary segments to show
*/
// @DataMember
public var itinerarySegmentsToShow:String
/**
* CRM System Name used by Agency
*/
// @DataMember
public var crm:String
required public init(){ super.init() }
private enum CodingKeys : String, CodingKey {
case travellerReference
case travellerGUID
case travelDateStart
case travelDateEnd
case lastName
case firstName
case includeItinerary
case itineraryFormatting
case itinerarySegmentsToShow
case crm
}
required public init(from decoder: Decoder) throws {
try super.init(from: decoder)
let container = try decoder.container(keyedBy: CodingKeys.self)
travellerReference = try container.decodeIfPresent(String.self, forKey: .travellerReference)
travellerGUID = try container.decodeIfPresent(String.self, forKey: .travellerGUID)
travelDateStart = try container.decodeIfPresent(String.self, forKey: .travelDateStart)
travelDateEnd = try container.decodeIfPresent(String.self, forKey: .travelDateEnd)
lastName = try container.decodeIfPresent(String.self, forKey: .lastName)
firstName = try container.decodeIfPresent(String.self, forKey: .firstName)
includeItinerary = try container.decodeIfPresent(Bool.self, forKey: .includeItinerary)
itineraryFormatting = try container.decodeIfPresent(FormattingStyle.self, forKey: .itineraryFormatting)
itinerarySegmentsToShow = try container.decodeIfPresent(String.self, forKey: .itinerarySegmentsToShow)
crm = try container.decodeIfPresent(String.self, forKey: .crm)
}
public override func encode(to encoder: Encoder) throws {
try super.encode(to: encoder)
var container = encoder.container(keyedBy: CodingKeys.self)
if travellerReference != nil { try container.encode(travellerReference, forKey: .travellerReference) }
if travellerGUID != nil { try container.encode(travellerGUID, forKey: .travellerGUID) }
if travelDateStart != nil { try container.encode(travelDateStart, forKey: .travelDateStart) }
if travelDateEnd != nil { try container.encode(travelDateEnd, forKey: .travelDateEnd) }
if lastName != nil { try container.encode(lastName, forKey: .lastName) }
if firstName != nil { try container.encode(firstName, forKey: .firstName) }
if includeItinerary != nil { try container.encode(includeItinerary, forKey: .includeItinerary) }
if itineraryFormatting != nil { try container.encode(itineraryFormatting, forKey: .itineraryFormatting) }
if itinerarySegmentsToShow != nil { try container.encode(itinerarySegmentsToShow, forKey: .itinerarySegmentsToShow) }
if crm != nil { try container.encode(crm, forKey: .crm) }
}
}
// @DataContract(Namespace="schemas.agentivity.com/types")
public class CompanyLevelRequestBase : PagingMetadata, IMemberUsername, IMemberOwningCompanyCode
{
/**
* Comma Delimited List of Owning Company Codes
*/
// @DataMember
public var owningCompanyCode:[String]
/**
* UserName in form of an email address
*/
// @DataMember
public var userName:String
required public init(){ super.init() }
private enum CodingKeys : String, CodingKey {
case owningCompanyCode
case userName
}
required public init(from decoder: Decoder) throws {
try super.init(from: decoder)
let container = try decoder.container(keyedBy: CodingKeys.self)
owningCompanyCode = try container.decodeIfPresent([String].self, forKey: .owningCompanyCode) ?? []
userName = try container.decodeIfPresent(String.self, forKey: .userName)
}
public override func encode(to encoder: Encoder) throws {
try super.encode(to: encoder)
var container = encoder.container(keyedBy: CodingKeys.self)
if owningCompanyCode != nil { try container.encode(owningCompanyCode, forKey: .owningCompanyCode) }
if userName != nil { try container.encode(userName, forKey: .userName) }
}
}
// @DataContract(Name="Metadata", Namespace="schemas.agentivity.com/types")
public class PagingMetadata : Codable
{
/**
* Starting Record
*/
// @DataMember
// @ApiMember(DataType="string", Description="Starting Record", Name="Offset", ParameterType="query")
public var offset:String
/**
* Number of records to return (PageSize)
*/
// @DataMember
// @ApiMember(DataType="string", Description="Number of records to return (PageSize)", Name="Limit", ParameterType="query")
public var limit:String
/**
* Total Number of Records in a Full Reponse (if no paging)
*/
// @DataMember
// @ApiMember(DataType="string", Description="Total Number of Records in a Full Reponse (if no paging)", Name="TotalRecords", ParameterType="query")
public var totalRecords:Int
/**
* Total Number of Records in this Reponse (on this page)
*/
// @DataMember
// @ApiMember(DataType="string", Description="Total Number of Records in this Reponse (on this page)", Name="ResponseRecords", ParameterType="query")
public var responseRecords:Int
required public init(){}
}
// @Flags()
public enum FormattingStyle : Int, Codable
{
case None = 0
case Html = 1
case Charting = 2
}
// @DataContract(Name="AgentivityResponse", Namespace="schemas.agentivity.com/types")
public class BookingsByTravellerItemResponse : ItemResponse<BookingByTraveller, BookingsByTravellerResponseReport>
{
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)
}
}
// @DataContract(Name="AgentivityResponse", Namespace="schemas.agentivity.com/types")
public class ItemResponse<TItem : Codable, TReport : Codable> : Codable
{
// @DataMember(Order=1)
public var responseMetadata:ResponseMetadata
// @DataMember(Order=2, EmitDefaultValue=false)
public var responseReport:TReport
// @DataMember(Order=3, EmitDefaultValue=false)
public var responseError:AgentivityError
required public init(){}
}
// @DataContract(Name="ResponseMetadata", Namespace="schemas.agentivity.com/types")
public class ResponseMetadata : Codable
{
// @DataMember(Order=0)
public var success:Bool
// @DataMember(Order=1)
public var hasCache:Bool
// @DataMember(Order=2)
public var hasPaging:Bool
// @DataMember(Order=3, EmitDefaultValue=false)
public var cacheMetadata:CacheMetadata
// @DataMember(Order=4, EmitDefaultValue=false)
public var pagingMetadata:PagingMetadata
required public init(){}
}
// @DataContract(Name="CacheMetadata", Namespace="schemas.agentivity.com/types")
public class CacheMetadata : Codable
{
// @DataMember(Order=1)
public var cachedAt:Date
// @DataMember(Order=2)
public var cacheExpiresAt:Date
// @DataMember(Order=0)
public var isFromCache:Bool
required public init(){}
}
// @DataContract(Name="ResponseMetadata", Namespace="schemas.agentivity.com/types")
public class AgentivityError : Codable
{
// @DataMember
public var errorCode:String
// @DataMember
public var message:String
// @DataMember
public var statusCode:String
// @DataMember
public var verboseMessage:String
required public init(){}
}
// @DataContract(Name="BookingByTraveller", Namespace="schemas.agentivity.com/types")
public class BookingByTraveller : IBookingItinerary, Codable
{
// @DataMember(Order=20)
public var recordLocator:String
// @DataMember(Order=25)
public var pnrCreationDate:Date?
// @DataMember(Order=30)
public var lastName:String
// @DataMember(Order=40)
public var firstName:String
// @DataMember(Order=50)
public var account:String
// @DataMember(Order=60)
public var accountName:String
// @DataMember(Order=70)
public var owningConsultant:String
// @DataMember(Order=80)
public var travelDate:Date?
// @DataMember(Order=90)
public var pnrCancelled:String
// @DataMember(Order=100)
public var pnrTicketed:String
// @DataMember(Order=110)
public var passenger:String
// @DataMember(Order=10)
public var agentivityRef:Int
// @DataMember(Order=500)
public var itinerary:ItinerarySegmentsCollection
// @DataMember(Order=510)
public var itineraryFormatted:String
required public init(){}
}
public class ItinerarySegmentsCollection : List<ItinerarySegment>
{
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)
}
}
// @DataContract(Name="ItinerarySegment", Namespace="schemas.agentivity.com/types")
public class ItinerarySegment : Codable
{
// @DataMember
public var segmentType:String
// @DataMember
public var segmentNbr:Int
// @DataMember
public var boardPoint:String
// @DataMember
public var offPoint:String
// @DataMember
public var operatorCode:String
// @DataMember
public var operatorService:String
// @DataMember
public var segmentStatus:String
// @DataMember
public var departureTimeFormatted:String
// @DataMember
public var arrivalTimeFormatted:String
// @DataMember
public var changeOfDayFormatted:String
// @DataMember
public var serviceCode:String
// @DataMember
public var startDate:String
// @DataMember
public var endDate:String
// @DataMember
public var ticketNumber:String
/**
* Comma separated list of vendor locators
*/
// @DataMember
public var vendorLocators:String
// @DataMember
public var equipmentCode:String
// @DataMember
public var equipment:String
required public init(){}
}
// @DataContract(Name="BookingByTraveller", Namespace="schemas.agentivity.com/types")
public class BookingsByTravellerResponseReport : Report<BookingsByTravellerItemResponse, BookingByTraveller>
{
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)
}
}
// @DataContract(Namespace="schemas.agentivity.com/types")
public class Report<TItemResponse : Codable, TItem : Codable> : Codable
{
// @DataMember(Order=1, EmitDefaultValue=false)
public var item:TItem
required public init(){}
}
Swift GetBookingsByTraveller DTOs
To override the Content-type in your clients, use the HTTP Accept Header, append the .other suffix or ?format=other
The following are sample HTTP requests and responses. The placeholders shown need to be replaced with actual values.
GET /BookingsByTraveller HTTP/1.1 Host: api.agentivity.com Accept: text/jsonl
HTTP/1.1 200 OK Content-Type: text/jsonl Content-Length: length {"ResponseMetadata":{"Success":false,"HasCache":false,"HasPaging":false,"CacheMetadata":{"IsFromCache":false,"CachedAt":"\/Date(-62135596800000-0000)\/","CacheExpiresAt":"\/Date(-62135596800000-0000)\/"},"PagingMetadata":{"Offset":"String","Limit":"String","TotalRecords":0,"ResponseRecords":0}},"ResponseReport":{"Item":{"AgentivityRef":0,"RecordLocator":"String","PNRCreationDate":"\/Date(-62135596800000-0000)\/","LastName":"String","FirstName":"String","Account":"String","AccountName":"String","OwningConsultant":"String","TravelDate":"\/Date(-62135596800000-0000)\/","PNRCancelled":"String","PNRTicketed":"String","Passenger":"String","Itinerary":[{"SegmentType":"String","SegmentNbr":0,"BoardPoint":"String","OffPoint":"String","OperatorCode":"String","OperatorService":"String","SegmentStatus":"String","DepartureTimeFormatted":"String","ArrivalTimeFormatted":"String","ChangeOfDayFormatted":"String","ServiceCode":"String","StartDate":"String","EndDate":"String","TicketNumber":"String","VendorLocators":"String","EquipmentCode":"String","Equipment":"String"}],"ItineraryFormatted":"String"}},"ResponseError":{"ErrorCode":"String","Message":"String","StatusCode":"String","VerboseMessage":"String"}}