BokaMera.API.Host

<back to all web services

RatingQuery

The following routes are available for this service:
GET/rating/Get RatingsGet 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(){}
}


Swift RatingQuery DTOs

To override the Content-type in your clients, use the HTTP Accept Header, append the .xml suffix or ?format=xml

HTTP + XML

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: application/xml
HTTP/1.1 200 OK
Content-Type: application/xml
Content-Length: length

<QueryResponseOfCompanyRatingResponseWg5EthtI xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.servicestack.net/types">
  <Offset>0</Offset>
  <Total>0</Total>
  <Results xmlns:d2p1="http://schemas.datacontract.org/2004/07/BokaMera.API.ServiceModel.Dtos">
    <d2p1:CompanyRatingResponse>
      <d2p1:BookingId>0</d2p1:BookingId>
      <d2p1:CompanyId>00000000-0000-0000-0000-000000000000</d2p1:CompanyId>
      <d2p1:CreatedDate>0001-01-01T00:00:00</d2p1:CreatedDate>
      <d2p1:RatingScore>0</d2p1:RatingScore>
      <d2p1:Review>
        <d2p1:Author>String</d2p1:Author>
        <d2p1:Created>0001-01-01T00:00:00</d2p1:Created>
        <d2p1:Description>String</d2p1:Description>
        <d2p1:RatingScore>0</d2p1:RatingScore>
        <d2p1:ReviewAnswer>String</d2p1:ReviewAnswer>
        <d2p1:Title>String</d2p1:Title>
      </d2p1:Review>
      <d2p1:Status>0</d2p1:Status>
      <d2p1:UpdatedDate>0001-01-01T00:00:00</d2p1:UpdatedDate>
    </d2p1:CompanyRatingResponse>
  </Results>
  <Meta xmlns:d2p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
    <d2p1:KeyValueOfstringstring>
      <d2p1:Key>String</d2p1:Key>
      <d2p1:Value>String</d2p1:Value>
    </d2p1:KeyValueOfstringstring>
  </Meta>
  <ResponseStatus>
    <ErrorCode>String</ErrorCode>
    <Message>String</Message>
    <StackTrace>String</StackTrace>
    <Errors>
      <ResponseError>
        <ErrorCode>String</ErrorCode>
        <FieldName>String</FieldName>
        <Message>String</Message>
        <Meta xmlns:d5p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
          <d5p1:KeyValueOfstringstring>
            <d5p1:Key>String</d5p1:Key>
            <d5p1:Value>String</d5p1:Value>
          </d5p1:KeyValueOfstringstring>
        </Meta>
      </ResponseError>
    </Errors>
    <Meta xmlns:d3p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
      <d3p1:KeyValueOfstringstring>
        <d3p1:Key>String</d3p1:Key>
        <d3p1:Value>String</d3p1:Value>
      </d3p1:KeyValueOfstringstring>
    </Meta>
  </ResponseStatus>
</QueryResponseOfCompanyRatingResponseWg5EthtI>