BokaMera.API.Host

<back to all web services

NewsletterTemplatesQuery

Requires Authentication
Requires any of the roles:bookingsupplier-administrator-write, superadmin, bookingsupplier-administrator-read
The following routes are available for this service:
GET/newsletter/templatesGet company newsletter templatesGet all company newsletter templates.
import Foundation
import ServiceStack

// @ApiResponse(Description="You were unauthorized to call this service", StatusCode=401)
// @ValidateRequest(Validator="IsAuthenticated")
public class NewsletterTemplatesQuery : QueryDb2<NewsletterTemplate, NewsletterTemplatesQueryResponse>, ICompany
{
    /**
    * The company id, if empty will use the company id for the user you are logged in with.
    */
    // @ApiMember(Description="The company id, if empty will use the company id for the user you are logged in with.")
    public var companyId:String?

    /**
    * The newsletter template id.
    */
    // @ApiMember(Description="The newsletter template id.")
    public var id:Int?

    /**
    * If you want to include the message send method information
    */
    // @ApiMember(DataType="boolean", Description="If you want to include the message send method information", ParameterType="query")
    public var includeSendMethodInformation:Bool

    /**
    * If you want to include the email template information
    */
    // @ApiMember(DataType="boolean", Description="If you want to include the email template information", ParameterType="query")
    public var includeEmailTemplateInformation:Bool

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

    private enum CodingKeys : String, CodingKey {
        case companyId
        case id
        case includeSendMethodInformation
        case includeEmailTemplateInformation
    }

    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)
        id = try container.decodeIfPresent(Int.self, forKey: .id)
        includeSendMethodInformation = try container.decodeIfPresent(Bool.self, forKey: .includeSendMethodInformation)
        includeEmailTemplateInformation = try container.decodeIfPresent(Bool.self, forKey: .includeEmailTemplateInformation)
    }

    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 id != nil { try container.encode(id, forKey: .id) }
        if includeSendMethodInformation != nil { try container.encode(includeSendMethodInformation, forKey: .includeSendMethodInformation) }
        if includeEmailTemplateInformation != nil { try container.encode(includeEmailTemplateInformation, forKey: .includeEmailTemplateInformation) }
    }
}

public class NewsletterTemplate : BaseModel
{
    public var sendMethod:SendMethod
    public var emailTemplate:EmailTemplate
    // @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 sendMethodId:Int?

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

    public var modifiedDate:Date?

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

    private enum CodingKeys : String, CodingKey {
        case sendMethod
        case emailTemplate
        case companyId
        case id
        case heading
        case body
        case imageUrl
        case sendMethodId
        case emailTemplateId
        case created
        case modifiedDate
    }

    required public init(from decoder: Decoder) throws {
        try super.init(from: decoder)
        let container = try decoder.container(keyedBy: CodingKeys.self)
        sendMethod = try container.decodeIfPresent(SendMethod.self, forKey: .sendMethod)
        emailTemplate = try container.decodeIfPresent(EmailTemplate.self, forKey: .emailTemplate)
        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)
        sendMethodId = try container.decodeIfPresent(Int.self, forKey: .sendMethodId)
        emailTemplateId = try container.decodeIfPresent(Int.self, forKey: .emailTemplateId)
        created = try container.decodeIfPresent(Date.self, forKey: .created)
        modifiedDate = try container.decodeIfPresent(Date.self, forKey: .modifiedDate)
    }

    public override func encode(to encoder: Encoder) throws {
        try super.encode(to: encoder)
        var container = encoder.container(keyedBy: CodingKeys.self)
        if sendMethod != nil { try container.encode(sendMethod, forKey: .sendMethod) }
        if emailTemplate != nil { try container.encode(emailTemplate, forKey: .emailTemplate) }
        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 sendMethodId != nil { try container.encode(sendMethodId, forKey: .sendMethodId) }
        if emailTemplateId != nil { try container.encode(emailTemplateId, forKey: .emailTemplateId) }
        if created != nil { try container.encode(created, forKey: .created) }
        if modifiedDate != nil { try container.encode(modifiedDate, forKey: .modifiedDate) }
    }
}

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

public class SendMethod : BaseModel
{
    // @Required()
    public var name:String?

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

    public var modifiedDate:Date?
    public var id:Int

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

    private enum CodingKeys : String, CodingKey {
        case name
        case Description
        case modifiedDate
        case id
    }

    required public init(from decoder: Decoder) throws {
        try super.init(from: decoder)
        let container = try decoder.container(keyedBy: CodingKeys.self)
        name = try container.decodeIfPresent(String.self, forKey: .name)
        Description = try container.decodeIfPresent(String.self, forKey: .Description)
        modifiedDate = try container.decodeIfPresent(Date.self, forKey: .modifiedDate)
        id = try container.decodeIfPresent(Int.self, forKey: .id)
    }

    public override func encode(to encoder: Encoder) throws {
        try super.encode(to: encoder)
        var container = encoder.container(keyedBy: CodingKeys.self)
        if name != nil { try container.encode(name, forKey: .name) }
        if Description != nil { try container.encode(Description, forKey: .Description) }
        if modifiedDate != nil { try container.encode(modifiedDate, forKey: .modifiedDate) }
        if id != nil { try container.encode(id, forKey: .id) }
    }
}

public class EmailTemplate : BaseModel
{
    // @Required()
    public var name:String?

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

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

    // @Required()
    public var type:Int?

    public var modifiedDate:Date?
    public var id:Int

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

    private enum CodingKeys : String, CodingKey {
        case name
        case Description
        case body
        case type
        case modifiedDate
        case id
    }

    required public init(from decoder: Decoder) throws {
        try super.init(from: decoder)
        let container = try decoder.container(keyedBy: CodingKeys.self)
        name = try container.decodeIfPresent(String.self, forKey: .name)
        Description = try container.decodeIfPresent(String.self, forKey: .Description)
        body = try container.decodeIfPresent(String.self, forKey: .body)
        type = try container.decodeIfPresent(Int.self, forKey: .type)
        modifiedDate = try container.decodeIfPresent(Date.self, forKey: .modifiedDate)
        id = try container.decodeIfPresent(Int.self, forKey: .id)
    }

    public override func encode(to encoder: Encoder) throws {
        try super.encode(to: encoder)
        var container = encoder.container(keyedBy: CodingKeys.self)
        if name != nil { try container.encode(name, forKey: .name) }
        if Description != nil { try container.encode(Description, forKey: .Description) }
        if body != nil { try container.encode(body, forKey: .body) }
        if type != nil { try container.encode(type, forKey: .type) }
        if modifiedDate != nil { try container.encode(modifiedDate, forKey: .modifiedDate) }
        if id != nil { try container.encode(id, forKey: .id) }
    }
}

public class NewsletterTemplatesQueryResponse : Codable
{
    /**
    * The newsletter template id
    */
    // @ApiMember(Description="The newsletter template id")
    public var id:Int

    /**
    * The newsletter template heading.
    */
    // @ApiMember(Description="The newsletter template heading.")
    public var heading:String

    /**
    * The newsletter template body.
    */
    // @ApiMember(Description="The newsletter template body.")
    public var body:String

    /**
    * The email template the newsletter uses.
    */
    // @ApiMember(Description="The email template the newsletter uses.")
    public var emailTemplateId:Int?

    /**
    * Send Method. 1 = Email, 2 = SMS
    */
    // @ApiMember(Description="Send Method. 1 = Email, 2 = SMS")
    public var sendMethodId:Int

    /**
    * The newsletter template image url.
    */
    // @ApiMember(Description="The newsletter template image url.")
    public var imageUrl:String

    /**
    * The newsletter created date.
    */
    // @ApiMember(Description="The newsletter created date.")
    public var created:Date

    /**
    * Send method information.
    */
    // @ApiMember(Description="Send method information.")
    public var sendMethodInformation:NewsletterSendMethodQueryResponse

    /**
    * Email template information.
    */
    // @ApiMember(Description="Email template information.")
    public var emailTemplateInformation:NewsletterEmailTemplatesQueryResponse

    required public init(){}
}

public class NewsletterSendMethodQueryResponse : Codable
{
    /**
    * The send method id
    */
    // @ApiMember(Description="The send method id")
    public var id:Int

    /**
    * The send method name.
    */
    // @ApiMember(Description="The send method name.")
    public var name:String

    /**
    * The send method description.
    */
    // @ApiMember(Description="The send method description.")
    public var Description:String

    required public init(){}
}

public class NewsletterEmailTemplatesQueryResponse : Codable
{
    /**
    * The email template id
    */
    // @ApiMember(Description="The email template id")
    public var id:Int

    /**
    * The email template name.
    */
    // @ApiMember(Description="The email template name.")
    public var name:String

    /**
    * The email template description.
    */
    // @ApiMember(Description="The email template description.")
    public var Description:String

    /**
    * The email template html content.
    */
    // @ApiMember(Description="The email template html content.")
    public var body:String

    required public init(){}
}

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

    required public init(){}
}


Swift NewsletterTemplatesQuery 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 /newsletter/templates HTTP/1.1 
Host: testapi.bokamera.se 
Accept: application/xml
HTTP/1.1 200 OK
Content-Type: application/xml
Content-Length: length

<QueryResponseOfNewsletterTemplatesQueryResponseWg5EthtI 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:NewsletterTemplatesQueryResponse>
      <d2p1:Body>String</d2p1:Body>
      <d2p1:Created>0001-01-01T00:00:00</d2p1:Created>
      <d2p1:EmailTemplateId>0</d2p1:EmailTemplateId>
      <d2p1:EmailTemplateInformation>
        <d2p1:Body>String</d2p1:Body>
        <d2p1:Description>String</d2p1:Description>
        <d2p1:Id>0</d2p1:Id>
        <d2p1:Name>String</d2p1:Name>
      </d2p1:EmailTemplateInformation>
      <d2p1:Heading>String</d2p1:Heading>
      <d2p1:Id>0</d2p1:Id>
      <d2p1:ImageUrl>String</d2p1:ImageUrl>
      <d2p1:SendMethodId>0</d2p1:SendMethodId>
      <d2p1:SendMethodInformation>
        <d2p1:Description>String</d2p1:Description>
        <d2p1:Id>0</d2p1:Id>
        <d2p1:Name>String</d2p1:Name>
      </d2p1:SendMethodInformation>
    </d2p1:NewsletterTemplatesQueryResponse>
  </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>
</QueryResponseOfNewsletterTemplatesQueryResponseWg5EthtI>