GET | /rating/ | Get Ratings | Get Ratings. |
---|
import Foundation
import ServiceStack
// @ApiResponse(Description="You were unauthorized to call this service", StatusCode=401)
public class RatingQuery : QueryDb2<Rating, CompanyRatingResponse>, ICompany
{
/**
*
*/
// @ApiMember(Description="")
public var companyId:String?
/**
* Id of the booking
*/
// @DataMember(Name="BookedEventId")
// @ApiMember(Description="Id of the booking")
public var BookedEventId:Int?
/**
* If you want to collect only active ratings. Ratings are only active after one has past since creation date.
*/
// @ApiMember(Description="If you want to collect only active ratings. Ratings are only active after one has past since creation date.")
public var active:Bool?
/**
* If you want to include the rating reviews
*/
// @ApiMember(DataType="boolean", Description="If you want to include the rating reviews", ParameterType="query")
public var includeRatingReviews:Bool
/**
* Start of interval to query for bookings when they where created. UTC+0 and parameter as defined by date-time - RFC3339
*/
// @ApiMember(DataType="dateTime", Description="Start of interval to query for bookings when they where created. UTC+0 and parameter as defined by date-time - RFC3339", ParameterType="query")
public var createdFrom:Date?
/**
* End of interval to query for bookings when they where created. UTC+0 and parameter as defined by date-time - RFC3339
*/
// @ApiMember(DataType="dateTime", Description="End of interval to query for bookings when they where created. UTC+0 and parameter as defined by date-time - RFC3339", ParameterType="query")
public var createdTo:Date?
required public init(){ super.init() }
private enum CodingKeys : String, CodingKey {
case companyId
case BookedEventId
case active
case includeRatingReviews
case createdFrom
case createdTo
}
required public init(from decoder: Decoder) throws {
try super.init(from: decoder)
let container = try decoder.container(keyedBy: CodingKeys.self)
companyId = try container.decodeIfPresent(String.self, forKey: .companyId)
BookedEventId = try container.decodeIfPresent(Int.self, forKey: .BookedEventId)
active = try container.decodeIfPresent(Bool.self, forKey: .active)
includeRatingReviews = try container.decodeIfPresent(Bool.self, forKey: .includeRatingReviews)
createdFrom = try container.decodeIfPresent(Date.self, forKey: .createdFrom)
createdTo = try container.decodeIfPresent(Date.self, forKey: .createdTo)
}
public override func encode(to encoder: Encoder) throws {
try super.encode(to: encoder)
var container = encoder.container(keyedBy: CodingKeys.self)
if companyId != nil { try container.encode(companyId, forKey: .companyId) }
if BookedEventId != nil { try container.encode(BookedEventId, forKey: .BookedEventId) }
if active != nil { try container.encode(active, forKey: .active) }
if includeRatingReviews != nil { try container.encode(includeRatingReviews, forKey: .includeRatingReviews) }
if createdFrom != nil { try container.encode(createdFrom, forKey: .createdFrom) }
if createdTo != nil { try container.encode(createdTo, forKey: .createdTo) }
}
}
public class Rating : BaseModel
{
public var reviewId:String?
public var review:Review
// @Required()
public var companyId:String?
// @Required()
public var bookingId:Int?
// @Required()
public var ratingScore:Int?
// @Required()
public var status:Int?
// @Required()
public var created:Date?
// @Required()
public var updated:Date?
public var modifiedDate:Date?
required public init(){ super.init() }
private enum CodingKeys : String, CodingKey {
case reviewId
case review
case companyId
case bookingId
case ratingScore
case status
case created
case updated
case modifiedDate
}
required public init(from decoder: Decoder) throws {
try super.init(from: decoder)
let container = try decoder.container(keyedBy: CodingKeys.self)
reviewId = try container.decodeIfPresent(String.self, forKey: .reviewId)
review = try container.decodeIfPresent(Review.self, forKey: .review)
companyId = try container.decodeIfPresent(String.self, forKey: .companyId)
bookingId = try container.decodeIfPresent(Int.self, forKey: .bookingId)
ratingScore = try container.decodeIfPresent(Int.self, forKey: .ratingScore)
status = try container.decodeIfPresent(Int.self, forKey: .status)
created = try container.decodeIfPresent(Date.self, forKey: .created)
updated = try container.decodeIfPresent(Date.self, forKey: .updated)
modifiedDate = try container.decodeIfPresent(Date.self, forKey: .modifiedDate)
}
public override func encode(to encoder: Encoder) throws {
try super.encode(to: encoder)
var container = encoder.container(keyedBy: CodingKeys.self)
if reviewId != nil { try container.encode(reviewId, forKey: .reviewId) }
if review != nil { try container.encode(review, forKey: .review) }
if companyId != nil { try container.encode(companyId, forKey: .companyId) }
if bookingId != nil { try container.encode(bookingId, forKey: .bookingId) }
if ratingScore != nil { try container.encode(ratingScore, forKey: .ratingScore) }
if status != nil { try container.encode(status, forKey: .status) }
if created != nil { try container.encode(created, forKey: .created) }
if updated != nil { try container.encode(updated, forKey: .updated) }
if modifiedDate != nil { try container.encode(modifiedDate, forKey: .modifiedDate) }
}
}
public class BaseModel : Codable
{
required public init(){}
}
public class Review : BaseModel
{
public var reviewId:String
// @Required()
public var companyId:String?
// @Required()
public var title:String?
// @Required()
public var Description:String?
// @Required()
public var author:String?
// @Required()
public var status:Int?
// @Required()
public var created:Date?
// @Required()
public var updated:Date?
public var modifiedDate:Date?
public var reviewAnswer:String
required public init(){ super.init() }
private enum CodingKeys : String, CodingKey {
case reviewId
case companyId
case title
case Description
case author
case status
case created
case updated
case modifiedDate
case reviewAnswer
}
required public init(from decoder: Decoder) throws {
try super.init(from: decoder)
let container = try decoder.container(keyedBy: CodingKeys.self)
reviewId = try container.decodeIfPresent(String.self, forKey: .reviewId)
companyId = try container.decodeIfPresent(String.self, forKey: .companyId)
title = try container.decodeIfPresent(String.self, forKey: .title)
Description = try container.decodeIfPresent(String.self, forKey: .Description)
author = try container.decodeIfPresent(String.self, forKey: .author)
status = try container.decodeIfPresent(Int.self, forKey: .status)
created = try container.decodeIfPresent(Date.self, forKey: .created)
updated = try container.decodeIfPresent(Date.self, forKey: .updated)
modifiedDate = try container.decodeIfPresent(Date.self, forKey: .modifiedDate)
reviewAnswer = try container.decodeIfPresent(String.self, forKey: .reviewAnswer)
}
public override func encode(to encoder: Encoder) throws {
try super.encode(to: encoder)
var container = encoder.container(keyedBy: CodingKeys.self)
if reviewId != nil { try container.encode(reviewId, forKey: .reviewId) }
if companyId != nil { try container.encode(companyId, forKey: .companyId) }
if title != nil { try container.encode(title, forKey: .title) }
if Description != nil { try container.encode(Description, forKey: .Description) }
if author != nil { try container.encode(author, forKey: .author) }
if status != nil { try container.encode(status, forKey: .status) }
if created != nil { try container.encode(created, forKey: .created) }
if updated != nil { try container.encode(updated, forKey: .updated) }
if modifiedDate != nil { try container.encode(modifiedDate, forKey: .modifiedDate) }
if reviewAnswer != nil { try container.encode(reviewAnswer, forKey: .reviewAnswer) }
}
}
public class CompanyRatingResponse : Codable
{
/**
*
*/
// @ApiMember(Description="")
public var companyId:String
/**
* Id of the booking
*/
// @ApiMember(Description="Id of the booking")
public var bookingId:Int
/**
* The status of the rating, 1 = Active
*/
// @ApiMember(Description="The status of the rating, 1 = Active")
public var status:Int
/**
* The rating score
*/
// @ApiMember(Description="The rating score")
public var ratingScore:Int
/**
* The review if any exists to the rating
*/
// @ApiMember(Description="The review if any exists to the rating")
public var review:RatingReviewResponse
public var createdDate:Date
public var updatedDate:Date
required public init(){}
}
public class RatingReviewResponse : Codable
{
/**
* The title for the review
*/
// @ApiMember(Description="The title for the review")
public var title:String
/**
* The description for the review
*/
// @ApiMember(Description="The description for the review")
public var Description:String
/**
* The rating score
*/
// @ApiMember(Description="The rating score")
public var ratingScore:Int
/**
* The review author
*/
// @ApiMember(Description="The review author")
public var author:String
/**
* The created date
*/
// @ApiMember(Description="The created date")
public var created:Date
/**
* The review answer from the company
*/
// @ApiMember(Description="The review answer from the company")
public var reviewAnswer:String
required public init(){}
}
public class AccessKeyTypeResponse : Codable
{
public var id:Int
public var keyType:String
public var Description:String
required public init(){}
}
To override the Content-type in your clients, use the HTTP Accept Header, append the .csv suffix or ?format=csv
The following are sample HTTP requests and responses. The placeholders shown need to be replaced with actual values.
GET /rating/ HTTP/1.1 Host: api.bokamera.se Accept: text/csv
HTTP/1.1 200 OK Content-Type: text/csv Content-Length: length {"Offset":0,"Total":0,"Results":[{"BookingId":0,"Status":0,"RatingScore":0,"Review":{"Title":"String","Description":"String","RatingScore":0,"Author":"String","ReviewAnswer":"String"}}],"Meta":{"String":"String"},"ResponseStatus":{"ErrorCode":"String","Message":"String","StackTrace":"String","Errors":[{"ErrorCode":"String","FieldName":"String","Message":"String","Meta":{"String":"String"}}],"Meta":{"String":"String"}}}