| GET,PUT,POST | /{Workspace}/InventoryItemType | ||
|---|---|---|---|
| GET,PUT,POST | /{Workspace}/InventoryItemType/{ObjectId} |
import Foundation
import ServiceStack
public class InventoryItemType : InventoryTreeNode
{
public var type:String
public var objectId:String
public var workspace:String
public var externalId:String
public var created:String
public var lastUpdated:String
public var itemType:String
public var desc:String
public var vendorNum:String
public var purchasingUOM:String
public var salesUOM:String
public var reorderLevel:Int?
public var reorderQty:Int?
public var defaultUnitCost:Double?
public var defaultUnitPrice:Double?
public var barcode:String
public var useSerialNumbers:Bool?
public var template:String
public var data:[String:String] = [:]
public var enabled:Bool?
public var parentCategoryId:String
public var includeInactive:Bool
required public init(){ super.init() }
private enum CodingKeys : String, CodingKey {
case type
case objectId
case workspace
case externalId
case created
case lastUpdated
case itemType
case desc
case vendorNum
case purchasingUOM
case salesUOM
case reorderLevel
case reorderQty
case defaultUnitCost
case defaultUnitPrice
case barcode
case useSerialNumbers
case template
case data
case enabled
case parentCategoryId
case includeInactive
}
required public init(from decoder: Decoder) throws {
try super.init(from: decoder)
let container = try decoder.container(keyedBy: CodingKeys.self)
type = try container.decodeIfPresent(String.self, forKey: .type)
objectId = try container.decodeIfPresent(String.self, forKey: .objectId)
workspace = try container.decodeIfPresent(String.self, forKey: .workspace)
externalId = try container.decodeIfPresent(String.self, forKey: .externalId)
created = try container.decodeIfPresent(String.self, forKey: .created)
lastUpdated = try container.decodeIfPresent(String.self, forKey: .lastUpdated)
itemType = try container.decodeIfPresent(String.self, forKey: .itemType)
desc = try container.decodeIfPresent(String.self, forKey: .desc)
vendorNum = try container.decodeIfPresent(String.self, forKey: .vendorNum)
purchasingUOM = try container.decodeIfPresent(String.self, forKey: .purchasingUOM)
salesUOM = try container.decodeIfPresent(String.self, forKey: .salesUOM)
reorderLevel = try container.decodeIfPresent(Int.self, forKey: .reorderLevel)
reorderQty = try container.decodeIfPresent(Int.self, forKey: .reorderQty)
defaultUnitCost = try container.decodeIfPresent(Double.self, forKey: .defaultUnitCost)
defaultUnitPrice = try container.decodeIfPresent(Double.self, forKey: .defaultUnitPrice)
barcode = try container.decodeIfPresent(String.self, forKey: .barcode)
useSerialNumbers = try container.decodeIfPresent(Bool.self, forKey: .useSerialNumbers)
template = try container.decodeIfPresent(String.self, forKey: .template)
data = try container.decodeIfPresent([String:String].self, forKey: .data) ?? [:]
enabled = try container.decodeIfPresent(Bool.self, forKey: .enabled)
parentCategoryId = try container.decodeIfPresent(String.self, forKey: .parentCategoryId)
includeInactive = try container.decodeIfPresent(Bool.self, forKey: .includeInactive)
}
public override func encode(to encoder: Encoder) throws {
try super.encode(to: encoder)
var container = encoder.container(keyedBy: CodingKeys.self)
if type != nil { try container.encode(type, forKey: .type) }
if objectId != nil { try container.encode(objectId, forKey: .objectId) }
if workspace != nil { try container.encode(workspace, forKey: .workspace) }
if externalId != nil { try container.encode(externalId, forKey: .externalId) }
if created != nil { try container.encode(created, forKey: .created) }
if lastUpdated != nil { try container.encode(lastUpdated, forKey: .lastUpdated) }
if itemType != nil { try container.encode(itemType, forKey: .itemType) }
if desc != nil { try container.encode(desc, forKey: .desc) }
if vendorNum != nil { try container.encode(vendorNum, forKey: .vendorNum) }
if purchasingUOM != nil { try container.encode(purchasingUOM, forKey: .purchasingUOM) }
if salesUOM != nil { try container.encode(salesUOM, forKey: .salesUOM) }
if reorderLevel != nil { try container.encode(reorderLevel, forKey: .reorderLevel) }
if reorderQty != nil { try container.encode(reorderQty, forKey: .reorderQty) }
if defaultUnitCost != nil { try container.encode(defaultUnitCost, forKey: .defaultUnitCost) }
if defaultUnitPrice != nil { try container.encode(defaultUnitPrice, forKey: .defaultUnitPrice) }
if barcode != nil { try container.encode(barcode, forKey: .barcode) }
if useSerialNumbers != nil { try container.encode(useSerialNumbers, forKey: .useSerialNumbers) }
if template != nil { try container.encode(template, forKey: .template) }
if data.count > 0 { try container.encode(data, forKey: .data) }
if enabled != nil { try container.encode(enabled, forKey: .enabled) }
if parentCategoryId != nil { try container.encode(parentCategoryId, forKey: .parentCategoryId) }
if includeInactive != nil { try container.encode(includeInactive, forKey: .includeInactive) }
}
}
public class InventoryTreeNode : Codable
{
public var type:String
public var descendantCount:Int
required public init(){}
}
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 /{Workspace}/InventoryItemType HTTP/1.1
Host: dev.fieldsquared.com
Accept: application/json
Content-Type: application/json
Content-Length: length
{"Type":"ItemType","ObjectId":"String","Workspace":"String","ExternalId":"String","Created":"String","LastUpdated":"String","ItemType":"String","Desc":"String","VendorNum":"String","PurchasingUOM":"String","SalesUOM":"String","ReorderLevel":0,"ReorderQty":0,"DefaultUnitCost":0,"DefaultUnitPrice":0,"Barcode":"String","UseSerialNumbers":false,"Template":"String","Data":{"String":"String"},"Enabled":false,"ParentCategoryId":"String","IncludeInactive":false,"DescendantCount":0}