Requires any of the roles: | bookingsupplier-administrator-write, superadmin |
POST | /licenses/company | Add new license to a company | Add a new license to the company for the logged in user. |
---|
import Foundation
import ServiceStack
// @ApiResponse(Description="You were unauthorized to call this service", StatusCode=401)
// @ValidateRequest(Validator="IsAuthenticated")
public class CreateLicense : 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?
/**
* Id of the license type
*/
// @ApiMember(Description="Id of the license type", IsRequired=true)
public var typeId:Int?
/**
* Any metadata connected to the license. In example for domain license set the requested domain name here.
*/
// @ApiMember(Description="Any metadata connected to the license. In example for domain license set the requested domain name here.", IsRequired=true)
public var metaData:String
/**
* If you want to update your company billing information. Note, if no billing information is added before, you need to set this.
*/
// @ApiMember(Description="If you want to update your company billing information. Note, if no billing information is added before, you need to set this.")
public var billingInformation:BillingInformationResponse
required public init(){}
}
public class BillingInformationResponse : Codable
{
/**
* The company id.
*/
// @ApiMember(Description="The company id.")
public var companyId:String
/**
* The prefered billing method.
*/
// @ApiMember(Description="The prefered billing method.", IsRequired=true)
public var billingMethodId:Int
/**
* The name that should be printed on the billing information, normally this would be your company name.
*/
// @ApiMember(Description="The name that should be printed on the billing information, normally this would be your company name.")
public var name:String
/**
* If you want to add the attention to the billing address.
*/
// @ApiMember(Description="If you want to add the attention to the billing address.")
public var attention:String
/**
* The street for the billing adress. This is required when having postal invoice as billing method.
*/
// @ApiMember(Description="The street for the billing adress. This is required when having postal invoice as billing method.")
public var street1:String
/**
* The street for the billing adress.
*/
// @ApiMember(Description="The street for the billing adress.")
public var street2:String
/**
* The zip code (postal code) for the billing adress. This is required when having postal invoice as billing method.
*/
// @ApiMember(Description="The zip code (postal code) for the billing adress. This is required when having postal invoice as billing method.")
public var zipCode:String
/**
* The city for the billing adress. This is required when having postal invoice as billing method.
*/
// @ApiMember(Description="The city for the billing adress. This is required when having postal invoice as billing method.")
public var city:String
/**
* The country for the billing adress. This is required when having postal invoice as billing method.
*/
// @ApiMember(Description="The country for the billing adress. This is required when having postal invoice as billing method.")
public var countryId:String
/**
* The billing email. This is required when having email invoice as billing method.
*/
// @ApiMember(Description="The billing email. This is required when having email invoice as billing method.")
public var email:String
/**
* The company global location number.
*/
// @ApiMember(Description="The company global location number.")
public var gln:String
/**
* You're internal rereference.
*/
// @ApiMember(Description="You're internal rereference.")
public var referenceLine1:String
/**
* You're internal rereference.
*/
// @ApiMember(Description="You're internal rereference.")
public var referenceLine2:String
/**
* The billing payment terms in days. This is default 15 days.
*/
// @ApiMember(Description="The billing payment terms in days. This is default 15 days.")
public var paymentTermsDays:Int
/**
* The company vat registration number.
*/
// @ApiMember(Description="The company vat registration number.")
public var vatRegistrationNumber:String
/**
* The billing method options to choose from
*/
// @ApiMember(Description="The billing method options to choose from")
public var billingMethodOptions:[BillingMethod] = []
required public init(){}
}
public class BillingMethod : BaseModel
{
public var billingMethodCountriesRelation:[BillingMethodCountriesRelation] = []
// @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 billingMethodCountriesRelation
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)
billingMethodCountriesRelation = try container.decodeIfPresent([BillingMethodCountriesRelation].self, forKey: .billingMethodCountriesRelation) ?? []
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 billingMethodCountriesRelation.count > 0 { try container.encode(billingMethodCountriesRelation, forKey: .billingMethodCountriesRelation) }
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 BaseModel : Codable
{
required public init(){}
}
public class BillingMethodCountriesRelation : BaseModel
{
// @Required()
public var billingMethodId:Int?
// @Required()
public var countryId:String?
public var modifiedDate:Date?
required public init(){ super.init() }
private enum CodingKeys : String, CodingKey {
case billingMethodId
case countryId
case modifiedDate
}
required public init(from decoder: Decoder) throws {
try super.init(from: decoder)
let container = try decoder.container(keyedBy: CodingKeys.self)
billingMethodId = try container.decodeIfPresent(Int.self, forKey: .billingMethodId)
countryId = try container.decodeIfPresent(String.self, forKey: .countryId)
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 billingMethodId != nil { try container.encode(billingMethodId, forKey: .billingMethodId) }
if countryId != nil { try container.encode(countryId, forKey: .countryId) }
if modifiedDate != nil { try container.encode(modifiedDate, forKey: .modifiedDate) }
}
}
public class CompanyLicenseQueryResponse : Codable
{
public var id:Int
public var typeId:Int
public var type:LicenseTypeQueryResponse
public var validFrom:Date
public var validTo:Date
public var metaData:String
public var active:Bool
public var canceled:Bool
public var updated:Date
public var created:Date
required public init(){}
}
public class LicenseTypeQueryResponse : Codable
{
/**
* The license type id
*/
// @ApiMember(Description="The license type id")
public var id:Int
/**
* The license type name
*/
// @ApiMember(Description="The license type name")
public var name:String
/**
* The license type description
*/
// @ApiMember(Description="The license type description")
public var Description:String
/**
* If the license type is not a standard license but instead an extra license option. An example would be sending new letter license.
*/
// @ApiMember(Description="If the license type is not a standard license but instead an extra license option. An example would be sending new letter license.")
public var isExtraLicenseOption:Bool
/**
* The period of notice for the license in days.
*/
// @ApiMember(Description="The period of notice for the license in days.")
public var periodOfNoticeDays:Int
/**
* The license items for the license type
*/
// @ApiMember(Description="The license items for the license type")
public var items:[LicenseItemsResponse] = []
/**
* The license prices in each country for the license type
*/
// @ApiMember(Description="The license prices in each country for the license type")
public var prices:[LicensePrice] = []
required public init(){}
}
public class LicenseItemsResponse : Codable
{
public var id:Int
public var name:String
public var allowedItems:Int
required public init(){}
}
public class LicensePrice : BaseModel
{
// @Ignore()
public var country:Country
// @Ignore()
public var monthlyPayment:Bool
// @Required()
public var licenseTypeId:Int?
// @Required()
public var countryId:String?
// @Required()
public var price:Int?
public var modifiedDate:Date?
required public init(){ super.init() }
private enum CodingKeys : String, CodingKey {
case country
case monthlyPayment
case licenseTypeId
case countryId
case price
case modifiedDate
}
required public init(from decoder: Decoder) throws {
try super.init(from: decoder)
let container = try decoder.container(keyedBy: CodingKeys.self)
country = try container.decodeIfPresent(Country.self, forKey: .country)
monthlyPayment = try container.decodeIfPresent(Bool.self, forKey: .monthlyPayment)
licenseTypeId = try container.decodeIfPresent(Int.self, forKey: .licenseTypeId)
countryId = try container.decodeIfPresent(String.self, forKey: .countryId)
price = try container.decodeIfPresent(Int.self, forKey: .price)
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 country != nil { try container.encode(country, forKey: .country) }
if monthlyPayment != nil { try container.encode(monthlyPayment, forKey: .monthlyPayment) }
if licenseTypeId != nil { try container.encode(licenseTypeId, forKey: .licenseTypeId) }
if countryId != nil { try container.encode(countryId, forKey: .countryId) }
if price != nil { try container.encode(price, forKey: .price) }
if modifiedDate != nil { try container.encode(modifiedDate, forKey: .modifiedDate) }
}
}
public class Country : BaseModel
{
// @References(typeof(Currency))
public var currencyId:String
public var currencyInfo:Currency
// @Required()
public var name:String?
public var culture:String
public var timeZone:String
public var modifiedDate:Date?
// @Required()
public var id:String?
required public init(){ super.init() }
private enum CodingKeys : String, CodingKey {
case currencyId
case currencyInfo
case name
case culture
case timeZone
case modifiedDate
case id
}
required public init(from decoder: Decoder) throws {
try super.init(from: decoder)
let container = try decoder.container(keyedBy: CodingKeys.self)
currencyId = try container.decodeIfPresent(String.self, forKey: .currencyId)
currencyInfo = try container.decodeIfPresent(Currency.self, forKey: .currencyInfo)
name = try container.decodeIfPresent(String.self, forKey: .name)
culture = try container.decodeIfPresent(String.self, forKey: .culture)
timeZone = try container.decodeIfPresent(String.self, forKey: .timeZone)
modifiedDate = try container.decodeIfPresent(Date.self, forKey: .modifiedDate)
id = try container.decodeIfPresent(String.self, forKey: .id)
}
public override func encode(to encoder: Encoder) throws {
try super.encode(to: encoder)
var container = encoder.container(keyedBy: CodingKeys.self)
if currencyId != nil { try container.encode(currencyId, forKey: .currencyId) }
if currencyInfo != nil { try container.encode(currencyInfo, forKey: .currencyInfo) }
if name != nil { try container.encode(name, forKey: .name) }
if culture != nil { try container.encode(culture, forKey: .culture) }
if timeZone != nil { try container.encode(timeZone, forKey: .timeZone) }
if modifiedDate != nil { try container.encode(modifiedDate, forKey: .modifiedDate) }
if id != nil { try container.encode(id, forKey: .id) }
}
}
public class Currency : BaseModel
{
// @Required()
public var name:String?
// @Required()
public var currencySign:String?
// @Required()
public var active:Bool?
public var modifiedDate:Date?
// @Required()
public var id:String?
required public init(){ super.init() }
private enum CodingKeys : String, CodingKey {
case name
case currencySign
case active
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)
currencySign = try container.decodeIfPresent(String.self, forKey: .currencySign)
active = try container.decodeIfPresent(Bool.self, forKey: .active)
modifiedDate = try container.decodeIfPresent(Date.self, forKey: .modifiedDate)
id = try container.decodeIfPresent(String.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 currencySign != nil { try container.encode(currencySign, forKey: .currencySign) }
if active != nil { try container.encode(active, forKey: .active) }
if modifiedDate != nil { try container.encode(modifiedDate, forKey: .modifiedDate) }
if id != nil { try container.encode(id, forKey: .id) }
}
}
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 /licenses/company HTTP/1.1
Host: api.bokamera.se
Accept: application/xml
Content-Type: application/xml
Content-Length: length
<CreateLicense xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/BokaMera.API.ServiceModel.Dtos">
<BillingInformation>
<Attention>String</Attention>
<BillingMethodId>0</BillingMethodId>
<BillingMethodOptions xmlns:d3p1="http://schemas.datacontract.org/2004/07/BokaMera.API.ServiceModel.Db">
<d3p1:BillingMethod>
<d3p1:BillingMethodCountriesRelation>
<d3p1:BillingMethodCountriesRelation>
<d3p1:BillingMethodId>0</d3p1:BillingMethodId>
<d3p1:CountryId>String</d3p1:CountryId>
<d3p1:ModifiedDate xmlns:d7p1="http://schemas.datacontract.org/2004/07/System">
<d7p1:DateTime>0001-01-01T00:00:00Z</d7p1:DateTime>
<d7p1:OffsetMinutes>0</d7p1:OffsetMinutes>
</d3p1:ModifiedDate>
</d3p1:BillingMethodCountriesRelation>
</d3p1:BillingMethodCountriesRelation>
<d3p1:Description>String</d3p1:Description>
<d3p1:Id>0</d3p1:Id>
<d3p1:ModifiedDate xmlns:d5p1="http://schemas.datacontract.org/2004/07/System">
<d5p1:DateTime>0001-01-01T00:00:00Z</d5p1:DateTime>
<d5p1:OffsetMinutes>0</d5p1:OffsetMinutes>
</d3p1:ModifiedDate>
<d3p1:Name>String</d3p1:Name>
</d3p1:BillingMethod>
</BillingMethodOptions>
<City>String</City>
<CompanyId>00000000-0000-0000-0000-000000000000</CompanyId>
<CountryId>String</CountryId>
<Email>String</Email>
<GLN>String</GLN>
<Name>String</Name>
<PaymentTermsDays>0</PaymentTermsDays>
<ReferenceLine1>String</ReferenceLine1>
<ReferenceLine2>String</ReferenceLine2>
<Street1>String</Street1>
<Street2>String</Street2>
<VatRegistrationNumber>String</VatRegistrationNumber>
<ZipCode>String</ZipCode>
</BillingInformation>
<CompanyId>00000000-0000-0000-0000-000000000000</CompanyId>
<MetaData>String</MetaData>
<TypeId>0</TypeId>
</CreateLicense>
HTTP/1.1 200 OK Content-Type: application/xml Content-Length: length <CompanyLicenseQueryResponse xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/BokaMera.API.ServiceModel.Dtos"> <Active>false</Active> <Canceled>false</Canceled> <Created>0001-01-01T00:00:00</Created> <Id>0</Id> <MetaData>String</MetaData> <Type> <Description>String</Description> <Id>0</Id> <IsExtraLicenseOption>false</IsExtraLicenseOption> <Items> <LicenseItemsResponse> <AllowedItems>0</AllowedItems> <Id>0</Id> <Name>String</Name> </LicenseItemsResponse> </Items> <Name>String</Name> <PeriodOfNoticeDays>0</PeriodOfNoticeDays> <Prices xmlns:d3p1="http://schemas.datacontract.org/2004/07/BokaMera.API.ServiceModel.Db"> <d3p1:LicensePrice> <d3p1:Country> <d3p1:Culture>String</d3p1:Culture> <d3p1:CurrencyId>String</d3p1:CurrencyId> <d3p1:CurrencyInfo> <d3p1:Active>false</d3p1:Active> <d3p1:CurrencySign>String</d3p1:CurrencySign> <d3p1:Id>String</d3p1:Id> <d3p1:ModifiedDate xmlns:d7p1="http://schemas.datacontract.org/2004/07/System"> <d7p1:DateTime>0001-01-01T00:00:00Z</d7p1:DateTime> <d7p1:OffsetMinutes>0</d7p1:OffsetMinutes> </d3p1:ModifiedDate> <d3p1:Name>String</d3p1:Name> </d3p1:CurrencyInfo> <d3p1:Id>String</d3p1:Id> <d3p1:ModifiedDate xmlns:d6p1="http://schemas.datacontract.org/2004/07/System"> <d6p1:DateTime>0001-01-01T00:00:00Z</d6p1:DateTime> <d6p1:OffsetMinutes>0</d6p1:OffsetMinutes> </d3p1:ModifiedDate> <d3p1:Name>String</d3p1:Name> <d3p1:TimeZone>String</d3p1:TimeZone> </d3p1:Country> <d3p1:CountryId>String</d3p1:CountryId> <d3p1:LicenseTypeId>0</d3p1:LicenseTypeId> <d3p1:ModifiedDate xmlns:d5p1="http://schemas.datacontract.org/2004/07/System"> <d5p1:DateTime>0001-01-01T00:00:00Z</d5p1:DateTime> <d5p1:OffsetMinutes>0</d5p1:OffsetMinutes> </d3p1:ModifiedDate> <d3p1:Price>0</d3p1:Price> </d3p1:LicensePrice> </Prices> </Type> <TypeId>0</TypeId> <Updated>0001-01-01T00:00:00</Updated> <ValidFrom>0001-01-01T00:00:00</ValidFrom> <ValidTo>0001-01-01T00:00:00</ValidTo> </CompanyLicenseQueryResponse>