Cochrane+ App API

<back to all web services

GetUsersRatings

Requires Authentication
The following routes are available for this service:
GET/internalrating/getusersratings
import Foundation
import ServiceStack

public class GetUsersRatings : ApiServiceRequest
{
    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)
    }
}

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 GetRatingSubmissionsResponse : ApiServiceResponse
{
    public var ratingSubmissions:[RatingSubmissionListItem] = []

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

    private enum CodingKeys : String, CodingKey {
        case ratingSubmissions
    }

    required public init(from decoder: Decoder) throws {
        try super.init(from: decoder)
        let container = try decoder.container(keyedBy: CodingKeys.self)
        ratingSubmissions = try container.decodeIfPresent([RatingSubmissionListItem].self, forKey: .ratingSubmissions) ?? []
    }

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

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(){}
}

public class RatingSubmissionListItem : Codable
{
    public var id:Int
    public var profileImage:String
    public var templateName:String
    public var username:String
    public var value:Int
    public var comments:String
    public var dateRated:Date

    required public init(){}
}


Swift GetUsersRatings 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 /internalrating/getusersratings HTTP/1.1 
Host: cochraneplus-api-dev.happen.zone 
Accept: text/jsv
HTTP/1.1 200 OK
Content-Type: text/jsv
Content-Length: length

{
	ratingSubmissions: 
	[
		{
			id: 0,
			profileImage: String,
			templateName: String,
			username: String,
			value: 0,
			comments: String,
			dateRated: 0001-01-01
		}
	],
	description: String,
	heading: String,
	wasSuccessful: False,
	modelState: {}
}