BokaMera.API.Host

<back to all web services

ReviewQuery

Requires Authentication
Requires any of the roles:bookingsupplier-administrator-write, superadmin
The following routes are available for this service:
GET/rating/reviewsGet ReviewsGet Reviews.
import Foundation
import ServiceStack

// @ApiResponse(Description="You were unauthorized to call this service", StatusCode=401)
// @ValidateRequest(Validator="IsAuthenticated")
public class ReviewQuery : QueryDb2<Review, RatingReviewResponse>, ICompany
{
    /**
    * 
    */
    // @ApiMember(Description="")
    public var companyId:String?

    /**
    * 
    */
    // @ApiMember(Description="")
    public var id:String?

    /**
    * If you want to collect only active reviews
    */
    // @ApiMember(Description="If you want to collect only active reviews")
    public var active:Bool?

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

    private enum CodingKeys : String, CodingKey {
        case companyId
        case id
        case active
    }

    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)
        id = try container.decodeIfPresent(String.self, forKey: .id)
        active = try container.decodeIfPresent(Bool.self, forKey: .active)
    }

    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 id != nil { try container.encode(id, forKey: .id) }
        if active != nil { try container.encode(active, forKey: .active) }
    }
}

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 BaseModel : Codable
{
    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 ReviewQuery 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.

GET /rating/reviews HTTP/1.1 
Host: testapi.bokamera.se 
Accept: text/jsv
HTTP/1.1 200 OK
Content-Type: text/jsv
Content-Length: length

{
	Offset: 0,
	Total: 0,
	Results: 
	[
		{
			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
		}
	}
}