| POST | /customerarticle | Create a new CustomerArticle. | Create a new CustomerArticle directly with price, status, and customer. |
|---|
import Foundation
import ServiceStack
// @ApiResponse(Description="You were unauthorized to call this service", StatusCode=401)
// @ValidateRequest(Validator="IsAuthenticated")
public class CreateCustomerArticle : ICompany, Codable
{
/**
* 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 article id to base this customer article on
*/
// @ApiMember(Description="The article id to base this customer article on", IsRequired=true)
public var articleId:Int
/**
* The customer id to assign the article to
*/
// @ApiMember(Description="The customer id to assign the article to", IsRequired=true)
public var customerId:String
/**
* The status of the customer article
*/
// @ApiMember(Description="The status of the customer article")
public var statusId:CustomerArticleStatusEnum?
/**
* Optional price override. If not provided, uses the article price.
*/
// @ApiMember(Description="Optional price override. If not provided, uses the article price.")
public var price:Double?
/**
* Optional VAT override. If not provided, uses the article VAT.
*/
// @ApiMember(Description="Optional VAT override. If not provided, uses the article VAT.")
public var vat:Double?
/**
* Optional currency override. If not provided, uses the article currency.
*/
// @ApiMember(Description="Optional currency override. If not provided, uses the article currency.")
public var currencyId:String
required public init(){}
}
public enum CustomerArticleStatusEnum : Int, Codable
{
case AwaitingPayment = 1
case AwaitingPaymentFromProvider = 2
case AwaitingPaymentNoTimeLimit = 3
case Active = 4
case Off = 5
}
public class CustomerArticleResponse : Codable
{
public var id:Int
public var companyId:String
public var articleId:Int?
public var price:Double?
public var vat:Double?
public var currencyId:String
public var statusId:Int
public var statusName:String
public var customerId:String?
public var createdDate:Date
public var updatedDate:Date
public var article:ArticleResponse
public var customer:CustomerArticleCustomerResponse
public var company:CustomerArticleCompanyResponse
public var paymentLog:[PaymentLogResponse] = []
public var responseStatus:ResponseStatus
required public init(){}
}
public class ArticleResponse : Codable
{
public var companyId:String
public var id:Int
public var name:String
public var articleTypeId:Int
public var Description:String
public var imageUrl:String
public var active:Bool
public var amount:Int
public var price:Double
public var currencyId:String
public var sortOrder:Int
public var updatedDate:Date
public var createdDate:Date
public var duration:Int
public var services:[ArticleServiceRelation] = []
public var serviceIds:[Int] = []
public var priceSign:String
public var vat:Double?
public var validDays:Int
public var sendNotification:Bool
public var notificationEmail:String
required public init(){}
}
public class ArticleServiceRelation : BaseModel
{
// @Required()
public var companyId:String?
public var id:Int
// @Required()
public var serviceId:Int?
// @Required()
public var articleId:Int?
required public init(){ super.init() }
private enum CodingKeys : String, CodingKey {
case companyId
case id
case serviceId
case articleId
}
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)
serviceId = try container.decodeIfPresent(Int.self, forKey: .serviceId)
articleId = try container.decodeIfPresent(Int.self, forKey: .articleId)
}
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 serviceId != nil { try container.encode(serviceId, forKey: .serviceId) }
if articleId != nil { try container.encode(articleId, forKey: .articleId) }
}
}
public class BaseModel : Codable
{
required public init(){}
}
public class CustomerArticleCustomerResponse : Codable
{
public var id:String
public var firstname:String
public var lastname:String
public var email:String
public var phone:String
required public init(){}
}
public class CustomerArticleCompanyResponse : Codable
{
public var id:String
public var name:String
public var logoType:String
public var email:String
public var phone:String
public var city:String
public var street1:String
public var zipCode:String
public var countryId:String
required public init(){}
}
public class PaymentLogResponse : Codable
{
public var id:Int
public var amount:Double?
public var amountCredited:Double?
public var currencyId:String
public var comments:String
public var created:Date
public var updated:Date
required public init(){}
}
Swift CreateCustomerArticle DTOs
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.
POST /customerarticle HTTP/1.1
Host: api.bokamera.se
Accept: application/json
Content-Type: application/json
Content-Length: length
{"CompanyId":"00000000-0000-0000-0000-000000000000","ArticleId":0,"StatusId":"0","Price":0,"VAT":0,"CurrencyId":"String"}
HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: length
{"Id":0,"ArticleId":0,"Price":0,"VAT":0,"CurrencyId":"String","StatusId":0,"StatusName":"String","CustomerId":"00000000-0000-0000-0000-000000000000","Article":{"Id":0,"Name":"String","ArticleTypeId":0,"Description":"String","ImageUrl":"String","Active":false,"Amount":0,"Price":0,"CurrencyId":"String","SortOrder":0,"Duration":0,"Services":[{"Id":0,"ServiceId":0,"ArticleId":0}],"ServiceIds":[0],"PriceSign":"String","VAT":0,"ValidDays":0,"SendNotification":false,"NotificationEmail":"String"},"Customer":{"Firstname":"String","Lastname":"String","Email":"String","Phone":"String"},"Company":{"Name":"String","LogoType":"String","Email":"String","Phone":"String","City":"String","Street1":"String","ZipCode":"String","CountryId":"String"},"PaymentLog":[{"Id":0,"Amount":0,"AmountCredited":0,"CurrencyId":"String","Comments":"String"}],"ResponseStatus":{"ErrorCode":"String","Message":"String","StackTrace":"String","Errors":[{"ErrorCode":"String","FieldName":"String","Message":"String","Meta":{"String":"String"}}],"Meta":{"String":"String"}}}