GET | /clients | Get all clients |
---|
import Foundation
import ServiceStack
// @DataContract
public class GetClients : PagedRequest
{
/**
* Filter the results to those that have a State matching the state specified
*/
// @DataMember
// @ApiMember(Description="Filter the results to those that have a State matching the state specified", ParameterType="query")
public var state:ClientState
/**
* Filter the results to those that have a IsValidateMe flag matching the specified value
*/
// @DataMember
// @ApiMember(Description="Filter the results to those that have a IsValidateMe flag matching the specified value", ParameterType="query")
public var isValidateMe:Bool?
/**
* Filter the results to those that have a Name including the specified value
*/
// @DataMember
// @ApiMember(Description="Filter the results to those that have a Name including the specified value", ParameterType="query")
public var name:String
/**
* Filter the results to those that were created after (or on) this date
*/
// @DataMember
// @ApiMember(Description="Filter the results to those that were created after (or on) this date", ParameterType="query")
public var dateFrom:Date
/**
* Filter the results to those that were created before this date
*/
// @DataMember
// @ApiMember(Description="Filter the results to those that were created before this date", ParameterType="query")
public var dateTo:Date
/**
* If the searches are being accessed by a sub user, specify their username here to only return searches they have permissions to view
*/
// @DataMember
// @ApiMember(Description="If the searches are being accessed by a sub user, specify their username here to only return searches they have permissions to view", ParameterType="query")
public var subUserName:String
required public init(){ super.init() }
private enum CodingKeys : String, CodingKey {
case state
case isValidateMe
case name
case dateFrom
case dateTo
case subUserName
}
required public init(from decoder: Decoder) throws {
try super.init(from: decoder)
let container = try decoder.container(keyedBy: CodingKeys.self)
state = try container.decodeIfPresent(ClientState.self, forKey: .state)
isValidateMe = try container.decodeIfPresent(Bool.self, forKey: .isValidateMe)
name = try container.decodeIfPresent(String.self, forKey: .name)
dateFrom = try container.decodeIfPresent(Date.self, forKey: .dateFrom)
dateTo = try container.decodeIfPresent(Date.self, forKey: .dateTo)
subUserName = try container.decodeIfPresent(String.self, forKey: .subUserName)
}
public override func encode(to encoder: Encoder) throws {
try super.encode(to: encoder)
var container = encoder.container(keyedBy: CodingKeys.self)
if state != nil { try container.encode(state, forKey: .state) }
if isValidateMe != nil { try container.encode(isValidateMe, forKey: .isValidateMe) }
if name != nil { try container.encode(name, forKey: .name) }
if dateFrom != nil { try container.encode(dateFrom, forKey: .dateFrom) }
if dateTo != nil { try container.encode(dateTo, forKey: .dateTo) }
if subUserName != nil { try container.encode(subUserName, forKey: .subUserName) }
}
}
// @DataContract
public class PagedRequest : BaseRequest
{
/**
* The maximum number of records to be returned in one page
*/
// @DataMember(Name="page[limit]")
// @ApiMember(Description="The maximum number of records to be returned in one page", ParameterType="query")
public var page_limit_:Int
/**
* The starting point in the list of records from where the data should be fetched. Zero based index.
*/
// @DataMember(Name="page[offset]")
// @ApiMember(Description="The starting point in the list of records from where the data should be fetched. Zero based index.", ParameterType="query")
public var page_offset_:Int
/**
* The term to determine the order in which the data is returned
*/
// @DataMember
// @ApiMember(Description="The term to determine the order in which the data is returned", ParameterType="query")
public var sort:String
required public init(){ super.init() }
private enum CodingKeys : String, CodingKey {
case page_limit_
case page_offset_
case sort
}
required public init(from decoder: Decoder) throws {
try super.init(from: decoder)
let container = try decoder.container(keyedBy: CodingKeys.self)
page_limit_ = try container.decodeIfPresent(Int.self, forKey: .page_limit_)
page_offset_ = try container.decodeIfPresent(Int.self, forKey: .page_offset_)
sort = try container.decodeIfPresent(String.self, forKey: .sort)
}
public override func encode(to encoder: Encoder) throws {
try super.encode(to: encoder)
var container = encoder.container(keyedBy: CodingKeys.self)
if page_limit_ != nil { try container.encode(page_limit_, forKey: .page_limit_) }
if page_offset_ != nil { try container.encode(page_offset_, forKey: .page_offset_) }
if sort != nil { try container.encode(sort, forKey: .sort) }
}
}
// @DataContract
public class BaseRequest : IBaseRequest, Codable
{
/**
* The authentication credentials
*/
// @DataMember
// @ApiMember(Description="The authentication credentials", IsRequired=true, ParameterType="header, body")
public var authentication:Authentication
required public init(){}
}
// @DataContract
public class Authentication : Codable
{
/**
* The API User ID provided by us when you signed up to use our API
*/
// @DataMember
// @ApiMember(Description="The API User ID provided by us when you signed up to use our API", IsRequired=true, ParameterType="header, body")
public var apiUserId:String
/**
* The API User Key provided by us when you signed up to use our API
*/
// @DataMember
// @ApiMember(Description="The API User Key provided by us when you signed up to use our API", IsRequired=true, ParameterType="header, body")
public var apiUserKey:String
required public init(){}
}
// @DataContract(Name="ClientState", Namespace="http://schemas.servicestack.net/types")
public enum ClientState : String, Codable
{
case Undefined
case PendingCompletion
case PendingOcr
case PendingVerification
case Verified
}
// @DataContract
public class GetClientsResponse : Codable
{
// @DataMember
public var data:GetClientsData
required public init(){}
}
public class GetClientsData : PagedResponse<GetClients>
{
public var clients:ArrayOfClientShort
required public init(){ super.init() }
private enum CodingKeys : String, CodingKey {
case clients
}
required public init(from decoder: Decoder) throws {
try super.init(from: decoder)
let container = try decoder.container(keyedBy: CodingKeys.self)
clients = try container.decodeIfPresent(ArrayOfClientShort.self, forKey: .clients)
}
public override func encode(to encoder: Encoder) throws {
try super.encode(to: encoder)
var container = encoder.container(keyedBy: CodingKeys.self)
if clients != nil { try container.encode(clients, forKey: .clients) }
}
}
public class PagedResponse<T : Codable> : BaseResponse
{
/**
* The response Metadata
*/
// @ApiMember(Description="The response Metadata")
public var meta:Meta<T>
required public init(){ super.init() }
private enum CodingKeys : String, CodingKey {
case meta
}
required public init(from decoder: Decoder) throws {
try super.init(from: decoder)
let container = try decoder.container(keyedBy: CodingKeys.self)
meta = try container.decodeIfPresent(Meta<T>.self, forKey: .meta)
}
public override func encode(to encoder: Encoder) throws {
try super.encode(to: encoder)
var container = encoder.container(keyedBy: CodingKeys.self)
if meta != nil { try container.encode(meta, forKey: .meta) }
}
}
public class BaseResponse : IBaseDataResponse, IHasResponseStatus, Codable
{
/**
* The status of the response
*/
// @ApiMember(Description="The status of the response")
public var responseStatus:ResponseStatus
required public init(){}
}
public class ArrayOfResponseError : List<ResponseError>
{
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 Meta<T : Codable> : Codable
{
/**
* Pagination links
*/
// @ApiMember(Description="Pagination links")
public var links:MetaLinks
/**
* The total number of records for the query
*/
// @ApiMember(Description="The total number of records for the query")
public var totalCount:Int?
/**
* The maximum number of records to be returned in one page
*/
// @ApiMember(Description="The maximum number of records to be returned in one page")
public var pageLimit:Int?
/**
* The starting point in the list of records from where the data should be fetched. Zero based index.
*/
// @ApiMember(Description="The starting point in the list of records from where the data should be fetched. Zero based index.")
public var pageOffset:Int?
required public init(){}
}
public class MetaLinks : Links
{
/**
* The link to the first page of records
*/
// @ApiMember(Description="The link to the first page of records")
public var first:String
/**
* The link to the last page of records
*/
// @ApiMember(Description="The link to the last page of records")
public var last:String
/**
* The link to the next page of records, if applicable
*/
// @ApiMember(Description="The link to the next page of records, if applicable")
public var next:String
/**
* The link to the last page of records, if applicable
*/
// @ApiMember(Description="The link to the last page of records, if applicable")
public var prev:String
required public init(){ super.init() }
private enum CodingKeys : String, CodingKey {
case first
case last
case next
case prev
}
required public init(from decoder: Decoder) throws {
try super.init(from: decoder)
let container = try decoder.container(keyedBy: CodingKeys.self)
first = try container.decodeIfPresent(String.self, forKey: .first)
last = try container.decodeIfPresent(String.self, forKey: .last)
next = try container.decodeIfPresent(String.self, forKey: .next)
prev = try container.decodeIfPresent(String.self, forKey: .prev)
}
public override func encode(to encoder: Encoder) throws {
try super.encode(to: encoder)
var container = encoder.container(keyedBy: CodingKeys.self)
if first != nil { try container.encode(first, forKey: .first) }
if last != nil { try container.encode(last, forKey: .last) }
if next != nil { try container.encode(next, forKey: .next) }
if prev != nil { try container.encode(prev, forKey: .prev) }
}
}
public class Links : Codable
{
// @ApiMember()
public var `self`:String
required public init(){}
}
public class ArrayOfClientShort : List<ClientShort>
{
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 ClientShort : Codable
{
public var id:Int
public var dateCreated:Date
public var name:String
public var reference:String
public var isValidateMe:Bool
public var state:ClientState
public var links:Links
public var numOfDocuments:Int
public var photo:Image
required public init(){}
}
public class Image : Codable
{
public var id:Int
public var name:String
public var ocrId:Int?
public var url:String
required public init(){}
}
To override the Content-type in your clients, use the HTTP Accept Header, append the .json suffix or ?format=json
To embed the response in a jsonp callback, append ?callback=myCallback
The following are sample HTTP requests and responses. The placeholders shown need to be replaced with actual values.
GET /clients HTTP/1.1 Host: api.sanctionssearch.com Accept: application/json
HTTP/1.1 200 OK Content-Type: application/json Content-Length: length {"data":{"clients":[{"id":0,"dateCreated":"\/Date(-62135596800000-0000)\/","name":"String","reference":"String","isValidateMe":false,"state":"Undefined","links":{"self":"String"},"numOfDocuments":0,"photo":{"id":0,"name":"String","ocrId":0,"url":"String"}}],"meta":{"links":{"first":"String","last":"String","next":"String","prev":"String","self":"String"},"totalCount":0,"pageLimit":0,"pageOffset":0},"responseStatus":{"errorCode":"String","message":"String","stackTrace":"String","errors":[{"errorCode":"String","fieldName":"String","message":"String","meta":{"String":"String"}}],"meta":{"String":"String"}}}}