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 .xml suffix or ?format=xml

HTTP + XML

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: application/xml
HTTP/1.1 200 OK
Content-Type: application/xml
Content-Length: length

<QueryResponseOfNewsItemQueryResponseWg5EthtI xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.servicestack.net/types">
  <Offset>0</Offset>
  <Total>0</Total>
  <Results xmlns:d2p1="http://schemas.datacontract.org/2004/07/BokaMera.API.ServiceModel.Dtos">
    <d2p1:NewsItemQueryResponse>
      <d2p1:Body>String</d2p1:Body>
      <d2p1:Created>0001-01-01T00:00:00</d2p1:Created>
      <d2p1:From>0001-01-01T00:00:00</d2p1:From>
      <d2p1:Heading>String</d2p1:Heading>
      <d2p1:Id>0</d2p1:Id>
      <d2p1:ImageUrl i:nil="true" />
      <d2p1:ResponseStatus>
        <ErrorCode>String</ErrorCode>
        <Message>String</Message>
        <StackTrace>String</StackTrace>
        <Errors>
          <ResponseError>
            <ErrorCode>String</ErrorCode>
            <FieldName>String</FieldName>
            <Message>String</Message>
            <Meta xmlns:d7p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
              <d7p1:KeyValueOfstringstring>
                <d7p1:Key>String</d7p1:Key>
                <d7p1:Value>String</d7p1:Value>
              </d7p1:KeyValueOfstringstring>
            </Meta>
          </ResponseError>
        </Errors>
        <Meta xmlns:d5p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
          <d5p1:KeyValueOfstringstring>
            <d5p1:Key>String</d5p1:Key>
            <d5p1:Value>String</d5p1:Value>
          </d5p1:KeyValueOfstringstring>
        </Meta>
      </d2p1:ResponseStatus>
      <d2p1:To>0001-01-01T00:00:00</d2p1:To>
    </d2p1:NewsItemQueryResponse>
  </Results>
  <Meta xmlns:d2p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
    <d2p1:KeyValueOfstringstring>
      <d2p1:Key>String</d2p1:Key>
      <d2p1:Value>String</d2p1:Value>
    </d2p1:KeyValueOfstringstring>
  </Meta>
  <ResponseStatus>
    <ErrorCode>String</ErrorCode>
    <Message>String</Message>
    <StackTrace>String</StackTrace>
    <Errors>
      <ResponseError>
        <ErrorCode>String</ErrorCode>
        <FieldName>String</FieldName>
        <Message>String</Message>
        <Meta xmlns:d5p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
          <d5p1:KeyValueOfstringstring>
            <d5p1:Key>String</d5p1:Key>
            <d5p1:Value>String</d5p1:Value>
          </d5p1:KeyValueOfstringstring>
        </Meta>
      </ResponseError>
    </Errors>
    <Meta xmlns:d3p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
      <d3p1:KeyValueOfstringstring>
        <d3p1:Key>String</d3p1:Key>
        <d3p1:Value>String</d3p1:Value>
      </d3p1:KeyValueOfstringstring>
    </Meta>
  </ResponseStatus>
</QueryResponseOfNewsItemQueryResponseWg5EthtI>