BokaMera.API.Host

<back to all web services

NewsItemQuery

The following routes are available for this service:
GET/newsFind news items for a company
import Foundation
import ServiceStack

public class NewsItemQuery : QueryDb2<NewsItem, NewsItemQueryResponse>
{
    /**
    * Enter the company you want to see news for, if blank and you are an admin, your company id will be used
    */
    // @ApiMember(Description="Enter the company you want to see news for, if blank and you are an admin, your company id will be used", ParameterType="query")
    public var companyId:String?

    /**
    * Enter the From Date you want to see news from, only allowed if admin
    */
    // @ApiMember(DataType="dateTime", Description="Enter the From Date you want to see news from, only allowed if admin", ParameterType="query")
    public var from:Date?

    /**
    * Enter the To Date you want to see news to, only allowed if admin
    */
    // @ApiMember(DataType="dateTime", Description="Enter the To Date you want to see news to, only allowed if admin", ParameterType="query")
    public var to:Date?

    /**
    * Use this parameter if you want to only show active news
    */
    // @ApiMember(DataType="boolean", Description="Use this parameter if you want to only show active news")
    public var active:Bool?

    /**
    * The homeage sitepath.
    */
    // @ApiMember(Description="The homeage sitepath.")
    public var sitePath:String

    /**
    * If you want to remove Html tags from newsbody and show as plain text.
    */
    // @ApiMember(Description="If you want to remove Html tags from newsbody and show as plain text.")
    public var plainText:Bool

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

    private enum CodingKeys : String, CodingKey {
        case companyId
        case from
        case to
        case active
        case sitePath
        case plainText
    }

    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)
        from = try container.decodeIfPresent(Date.self, forKey: .from)
        to = try container.decodeIfPresent(Date.self, forKey: .to)
        active = try container.decodeIfPresent(Bool.self, forKey: .active)
        sitePath = try container.decodeIfPresent(String.self, forKey: .sitePath)
        plainText = try container.decodeIfPresent(Bool.self, forKey: .plainText)
    }

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

public class NewsItem : BaseModel, IInterval
{
    // @Ignore()
    public var active:Bool

    // @Required()
    public var companyId:String?

    public var id:Int
    // @Required()
    public var heading:String?

    // @Required()
    public var body:String?

    public var imageUrl:String
    // @Required()
    public var updated:Date?

    // @Required()
    public var created:Date?

    public var modifiedDate:Date?
    // @Required()
    public var from:Date?

    // @Required()
    public var to:Date?

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

    private enum CodingKeys : String, CodingKey {
        case active
        case companyId
        case id
        case heading
        case body
        case imageUrl
        case updated
        case created
        case modifiedDate
        case from
        case to
    }

    required public init(from decoder: Decoder) throws {
        try super.init(from: decoder)
        let container = try decoder.container(keyedBy: CodingKeys.self)
        active = try container.decodeIfPresent(Bool.self, forKey: .active)
        companyId = try container.decodeIfPresent(String.self, forKey: .companyId)
        id = try container.decodeIfPresent(Int.self, forKey: .id)
        heading = try container.decodeIfPresent(String.self, forKey: .heading)
        body = try container.decodeIfPresent(String.self, forKey: .body)
        imageUrl = try container.decodeIfPresent(String.self, forKey: .imageUrl)
        updated = try container.decodeIfPresent(Date.self, forKey: .updated)
        created = try container.decodeIfPresent(Date.self, forKey: .created)
        modifiedDate = try container.decodeIfPresent(Date.self, forKey: .modifiedDate)
        from = try container.decodeIfPresent(Date.self, forKey: .from)
        to = try container.decodeIfPresent(Date.self, forKey: .to)
    }

    public override func encode(to encoder: Encoder) throws {
        try super.encode(to: encoder)
        var container = encoder.container(keyedBy: CodingKeys.self)
        if active != nil { try container.encode(active, forKey: .active) }
        if companyId != nil { try container.encode(companyId, forKey: .companyId) }
        if id != nil { try container.encode(id, forKey: .id) }
        if heading != nil { try container.encode(heading, forKey: .heading) }
        if body != nil { try container.encode(body, forKey: .body) }
        if imageUrl != nil { try container.encode(imageUrl, forKey: .imageUrl) }
        if updated != nil { try container.encode(updated, forKey: .updated) }
        if created != nil { try container.encode(created, forKey: .created) }
        if modifiedDate != nil { try container.encode(modifiedDate, forKey: .modifiedDate) }
        if from != nil { try container.encode(from, forKey: .from) }
        if to != nil { try container.encode(to, forKey: .to) }
    }
}

public class BaseModel : Codable
{
    required public init(){}
}

public class NewsItemQueryResponse : Codable
{
    /**
    * The news item id
    */
    // @ApiMember(Description="The news item id")
    public var id:Int

    /**
    * Heading of the news item
    */
    // @ApiMember(Description="Heading of the news item")
    public var heading:String

    /**
    * Body of the news item
    */
    // @ApiMember(Description="Body of the news item")
    public var body:String

    /**
    * Url to a image associated with the news
    */
    // @ApiMember(Description="Url to a image associated with the news")
    public var imageUrl:Uri

    /**
    * The timestamp from which the newsitem should be visible from
    */
    // @ApiMember(Description="The timestamp from which the newsitem should be visible from", IsRequired=true)
    public var from:Date

    /**
    * The timestamp to which the newsitem should be visible to
    */
    // @ApiMember(Description="The timestamp to which the newsitem should be visible to", IsRequired=true)
    public var to:Date

    /**
    * The timestamp when news was created
    */
    // @ApiMember(Description="The timestamp when news was created", IsRequired=true)
    public var created:Date

    public var responseStatus:ResponseStatus

    required public init(){}
}

public class AccessKeyTypeResponse : Codable
{
    public var id:Int
    public var keyType:String
    public var Description:String

    required public init(){}
}


Swift NewsItemQuery DTOs

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

HTTP + CSV

The following are sample HTTP requests and responses. The placeholders shown need to be replaced with actual values.

GET /news HTTP/1.1 
Host: api.bokamera.se 
Accept: text/csv
HTTP/1.1 200 OK
Content-Type: text/csv
Content-Length: length

{"Offset":0,"Total":0,"Results":[{"Id":0,"Heading":"String","Body":"String","ResponseStatus":{"ErrorCode":"String","Message":"String","StackTrace":"String","Errors":[{"ErrorCode":"String","FieldName":"String","Message":"String","Meta":{"String":"String"}}],"Meta":{"String":"String"}}}],"Meta":{"String":"String"},"ResponseStatus":{"ErrorCode":"String","Message":"String","StackTrace":"String","Errors":[{"ErrorCode":"String","FieldName":"String","Message":"String","Meta":{"String":"String"}}],"Meta":{"String":"String"}}}