GET | /supplier/search |
---|
import Foundation
import ServiceStack
public class BrowseSupplierByVatNumberOrDuns : IGet, Codable
{
public var vatNumber:String
public var country:String
public var dunsNumber:String
required public init(){}
}
public class BrowseSupplierResponse : ResponseBase
{
public var supplier:SupplierDetails
required public init(){ super.init() }
private enum CodingKeys : String, CodingKey {
case supplier
}
required public init(from decoder: Decoder) throws {
try super.init(from: decoder)
let container = try decoder.container(keyedBy: CodingKeys.self)
supplier = try container.decodeIfPresent(SupplierDetails.self, forKey: .supplier)
}
public override func encode(to encoder: Encoder) throws {
try super.encode(to: encoder)
var container = encoder.container(keyedBy: CodingKeys.self)
if supplier != nil { try container.encode(supplier, forKey: .supplier) }
}
}
public class ResponseBase : Codable
{
public var responseStatus:ResponseStatus
required public init(){}
}
public class SupplierDetails : SupplierBase
{
public var id:Int
public var ownerId:Int
public var countryName:String
public var countryCode:String
public var status:SupplierStatus
public var meta:[String:String] = [:]
required public init(){ super.init() }
private enum CodingKeys : String, CodingKey {
case id
case ownerId
case countryName
case countryCode
case status
case meta
}
required public init(from decoder: Decoder) throws {
try super.init(from: decoder)
let container = try decoder.container(keyedBy: CodingKeys.self)
id = try container.decodeIfPresent(Int.self, forKey: .id)
ownerId = try container.decodeIfPresent(Int.self, forKey: .ownerId)
countryName = try container.decodeIfPresent(String.self, forKey: .countryName)
countryCode = try container.decodeIfPresent(String.self, forKey: .countryCode)
status = try container.decodeIfPresent(SupplierStatus.self, forKey: .status)
meta = try container.decodeIfPresent([String:String].self, forKey: .meta) ?? [:]
}
public override func encode(to encoder: Encoder) throws {
try super.encode(to: encoder)
var container = encoder.container(keyedBy: CodingKeys.self)
if id != nil { try container.encode(id, forKey: .id) }
if ownerId != nil { try container.encode(ownerId, forKey: .ownerId) }
if countryName != nil { try container.encode(countryName, forKey: .countryName) }
if countryCode != nil { try container.encode(countryCode, forKey: .countryCode) }
if status != nil { try container.encode(status, forKey: .status) }
if meta.count > 0 { try container.encode(meta, forKey: .meta) }
}
}
public class SupplierBase : ModifyRequestBase
{
public var vatNumber:String
public var euTaxNumber:String
public var groupTaxNumber:String
public var businessType:Int
public var countryId:Int
public var name:String
public var shortName:String
public var registrationNumber:String
public var establishedDate:Date
public var registrationDate:Date
public var duns:String
public var operatingLicenseNumber:String
public var isAccounting:Bool
public var isSmallTaxPayer:Bool
public var email:String
public var phoneNumber:String
public var website:String
required public init(){ super.init() }
private enum CodingKeys : String, CodingKey {
case vatNumber
case euTaxNumber
case groupTaxNumber
case businessType
case countryId
case name
case shortName
case registrationNumber
case establishedDate
case registrationDate
case duns
case operatingLicenseNumber
case isAccounting
case isSmallTaxPayer
case email
case phoneNumber
case website
}
required public init(from decoder: Decoder) throws {
try super.init(from: decoder)
let container = try decoder.container(keyedBy: CodingKeys.self)
vatNumber = try container.decodeIfPresent(String.self, forKey: .vatNumber)
euTaxNumber = try container.decodeIfPresent(String.self, forKey: .euTaxNumber)
groupTaxNumber = try container.decodeIfPresent(String.self, forKey: .groupTaxNumber)
businessType = try container.decodeIfPresent(Int.self, forKey: .businessType)
countryId = try container.decodeIfPresent(Int.self, forKey: .countryId)
name = try container.decodeIfPresent(String.self, forKey: .name)
shortName = try container.decodeIfPresent(String.self, forKey: .shortName)
registrationNumber = try container.decodeIfPresent(String.self, forKey: .registrationNumber)
establishedDate = try container.decodeIfPresent(Date.self, forKey: .establishedDate)
registrationDate = try container.decodeIfPresent(Date.self, forKey: .registrationDate)
duns = try container.decodeIfPresent(String.self, forKey: .duns)
operatingLicenseNumber = try container.decodeIfPresent(String.self, forKey: .operatingLicenseNumber)
isAccounting = try container.decodeIfPresent(Bool.self, forKey: .isAccounting)
isSmallTaxPayer = try container.decodeIfPresent(Bool.self, forKey: .isSmallTaxPayer)
email = try container.decodeIfPresent(String.self, forKey: .email)
phoneNumber = try container.decodeIfPresent(String.self, forKey: .phoneNumber)
website = try container.decodeIfPresent(String.self, forKey: .website)
}
public override func encode(to encoder: Encoder) throws {
try super.encode(to: encoder)
var container = encoder.container(keyedBy: CodingKeys.self)
if vatNumber != nil { try container.encode(vatNumber, forKey: .vatNumber) }
if euTaxNumber != nil { try container.encode(euTaxNumber, forKey: .euTaxNumber) }
if groupTaxNumber != nil { try container.encode(groupTaxNumber, forKey: .groupTaxNumber) }
if businessType != nil { try container.encode(businessType, forKey: .businessType) }
if countryId != nil { try container.encode(countryId, forKey: .countryId) }
if name != nil { try container.encode(name, forKey: .name) }
if shortName != nil { try container.encode(shortName, forKey: .shortName) }
if registrationNumber != nil { try container.encode(registrationNumber, forKey: .registrationNumber) }
if establishedDate != nil { try container.encode(establishedDate, forKey: .establishedDate) }
if registrationDate != nil { try container.encode(registrationDate, forKey: .registrationDate) }
if duns != nil { try container.encode(duns, forKey: .duns) }
if operatingLicenseNumber != nil { try container.encode(operatingLicenseNumber, forKey: .operatingLicenseNumber) }
if isAccounting != nil { try container.encode(isAccounting, forKey: .isAccounting) }
if isSmallTaxPayer != nil { try container.encode(isSmallTaxPayer, forKey: .isSmallTaxPayer) }
if email != nil { try container.encode(email, forKey: .email) }
if phoneNumber != nil { try container.encode(phoneNumber, forKey: .phoneNumber) }
if website != nil { try container.encode(website, forKey: .website) }
}
}
public class ModifyRequestBase : IConcurrencyStamp, Codable
{
public var concurrencyStamp:String
required public init(){}
}
public enum SupplierStatus : Int, Codable
{
case Registered = 0
case AwaitingVeoliaConfirmation = 1
case Active = 2
case Rejected = 3
case Locked = 4
case Deleted = 5
}
Swift BrowseSupplierByVatNumberOrDuns DTOs
To override the Content-type in your clients, use the HTTP Accept Header, append the .other suffix or ?format=other
The following are sample HTTP requests and responses. The placeholders shown need to be replaced with actual values.
GET /supplier/search HTTP/1.1 Host: szallitoiportal-be.veolia.hu Accept: text/jsonl
HTTP/1.1 200 OK Content-Type: text/jsonl Content-Length: length {"Supplier":{"Id":0,"OwnerId":0,"CountryName":"String","CountryCode":"String","Status":0,"Meta":{"String":"String"},"VatNumber":"String","EUTaxNumber":"String","GroupTaxNumber":"String","BusinessType":0,"CountryId":0,"Name":"String","ShortName":"String","RegistrationNumber":"String","EstablishedDate":"0001-01-01T00:00:00.0000000","RegistrationDate":"0001-01-01T00:00:00.0000000","Duns":"String","OperatingLicenseNumber":"String","IsAccounting":false,"IsSmallTaxPayer":false,"Email":"String","PhoneNumber":"String","Website":"String","ConcurrencyStamp":"String"},"ResponseStatus":{"ErrorCode":"String","Message":"String","StackTrace":"String","Errors":[{"ErrorCode":"String","FieldName":"String","Message":"String","Meta":{"String":"String"}}],"Meta":{"String":"String"}}}