| GET | /v2/collections | ||
|---|---|---|---|
| GET | /v2/collections/{Id} |
import Foundation
import ServiceStack
// @DataContract
public class GetCollectionRequest : V2BaseRequest
{
// @DataMember(Name="id")
public var id:String
required public init(){ super.init() }
private enum CodingKeys : String, CodingKey {
case id
}
required public init(from decoder: Decoder) throws {
try super.init(from: decoder)
let container = try decoder.container(keyedBy: CodingKeys.self)
id = try container.decodeIfPresent(String.self, forKey: .id)
}
public override func encode(to encoder: Encoder) throws {
try super.encode(to: encoder)
var container = encoder.container(keyedBy: CodingKeys.self)
if id != nil { try container.encode(id, forKey: .id) }
}
}
// @DataContract
public class V2BaseRequest : Codable
{
required public init(){}
}
// @DataContract
public class GetCollectionResponse : V2BaseResponse
{
// @DataMember(Name="data")
public var data:UserCollection
required public init(){ super.init() }
private enum CodingKeys : String, CodingKey {
case data
}
required public init(from decoder: Decoder) throws {
try super.init(from: decoder)
let container = try decoder.container(keyedBy: CodingKeys.self)
data = try container.decodeIfPresent(UserCollection.self, forKey: .data)
}
public override func encode(to encoder: Encoder) throws {
try super.encode(to: encoder)
var container = encoder.container(keyedBy: CodingKeys.self)
if data != nil { try container.encode(data, forKey: .data) }
}
}
// @DataContract
public class V2BaseResponse : Codable
{
// @DataMember(Name="responseStatus")
public var responseStatus:ResponseStatus
required public init(){}
}
// @DataContract
public class UserCollection : IUserCollection, Codable
{
// @DataMember(Name="type")
public var type:String
// @DataMember(Name="id")
public var id:String
// @DataMember(Name="baseCode")
public var baseCode:String
// @DataMember(Name="url")
public var url:String
// @DataMember(Name="title")
public var title:String
// @DataMember(Name="linkIds")
public var linkIds:[String]
// @DataMember(Name="collectionSettingsId")
public var collectionSettingsId:String
required public init(){}
}
Swift GetCollectionRequest DTOs
To override the Content-type in your clients, use the HTTP Accept Header, append the .jsv suffix or ?format=jsv
The following are sample HTTP requests and responses. The placeholders shown need to be replaced with actual values.
GET /v2/collections HTTP/1.1 Host: api.booklinker.com Accept: text/jsv
HTTP/1.1 200 OK
Content-Type: text/jsv
Content-Length: length
{
data:
{
type: collection,
id: String,
baseCode: String,
url: String,
title: String,
collectionSettingsId: String
},
responseStatus:
{
errorCode: String,
message: String,
stackTrace: String,
errors:
[
{
errorCode: String,
fieldName: String,
message: String,
meta:
{
String: String
}
}
],
meta:
{
String: String
}
}
}