POST | /eaccounting/articles | Create a new article in e-accounting system |
---|
import Foundation
import ServiceStack
public class CreateEAccountingArticle : BaseArticleDto, ICompany
{
public var serviceId:Int
public var companyId:String?
required public init(){ super.init() }
private enum CodingKeys : String, CodingKey {
case serviceId
case companyId
}
required public init(from decoder: Decoder) throws {
try super.init(from: decoder)
let container = try decoder.container(keyedBy: CodingKeys.self)
serviceId = try container.decodeIfPresent(Int.self, forKey: .serviceId)
companyId = try container.decodeIfPresent(String.self, forKey: .companyId)
}
public override func encode(to encoder: Encoder) throws {
try super.encode(to: encoder)
var container = encoder.container(keyedBy: CodingKeys.self)
if serviceId != nil { try container.encode(serviceId, forKey: .serviceId) }
if companyId != nil { try container.encode(companyId, forKey: .companyId) }
}
}
public class BaseArticleDto : Codable
{
public var articleId:String
public var articlePrice:Double
public var articleName:String
public var createdDate:Date
required public init(){}
}
public class EAccountingArticleQueryResponse : BaseArticleDto
{
public var unitId:String
public var codingId:String
public var vatRate:String
public var vatRatePercent:String
public var currencySign:String
required public init(){ super.init() }
private enum CodingKeys : String, CodingKey {
case unitId
case codingId
case vatRate
case vatRatePercent
case currencySign
}
required public init(from decoder: Decoder) throws {
try super.init(from: decoder)
let container = try decoder.container(keyedBy: CodingKeys.self)
unitId = try container.decodeIfPresent(String.self, forKey: .unitId)
codingId = try container.decodeIfPresent(String.self, forKey: .codingId)
vatRate = try container.decodeIfPresent(String.self, forKey: .vatRate)
vatRatePercent = try container.decodeIfPresent(String.self, forKey: .vatRatePercent)
currencySign = try container.decodeIfPresent(String.self, forKey: .currencySign)
}
public override func encode(to encoder: Encoder) throws {
try super.encode(to: encoder)
var container = encoder.container(keyedBy: CodingKeys.self)
if unitId != nil { try container.encode(unitId, forKey: .unitId) }
if codingId != nil { try container.encode(codingId, forKey: .codingId) }
if vatRate != nil { try container.encode(vatRate, forKey: .vatRate) }
if vatRatePercent != nil { try container.encode(vatRatePercent, forKey: .vatRatePercent) }
if currencySign != nil { try container.encode(currencySign, forKey: .currencySign) }
}
}
Swift CreateEAccountingArticle DTOs
To override the Content-type in your clients, use the HTTP Accept Header, append the .xml suffix or ?format=xml
The following are sample HTTP requests and responses. The placeholders shown need to be replaced with actual values.
POST /eaccounting/articles HTTP/1.1
Host: api.bokamera.se
Accept: application/xml
Content-Type: application/xml
Content-Length: length
<EAccountingDtos.CreateEAccountingArticle xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/BokaMera.API.ServiceModel.Dtos">
<ArticleId>00000000-0000-0000-0000-000000000000</ArticleId>
<ArticleName>String</ArticleName>
<ArticlePrice>0</ArticlePrice>
<CreatedDate>0001-01-01T00:00:00</CreatedDate>
<CompanyId>00000000-0000-0000-0000-000000000000</CompanyId>
<ServiceId>0</ServiceId>
</EAccountingDtos.CreateEAccountingArticle>
HTTP/1.1 200 OK Content-Type: application/xml Content-Length: length <EAccountingDtos.EAccountingArticleQueryResponse xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/BokaMera.API.ServiceModel.Dtos"> <ArticleId>00000000-0000-0000-0000-000000000000</ArticleId> <ArticleName>String</ArticleName> <ArticlePrice>0</ArticlePrice> <CreatedDate>0001-01-01T00:00:00</CreatedDate> <CodingId>String</CodingId> <CurrencySign>String</CurrencySign> <UnitId>String</UnitId> <VatRate>String</VatRate> <VatRatePercent>String</VatRatePercent> </EAccountingDtos.EAccountingArticleQueryResponse>