| GET,PUT,POST | /{Workspace}/InventoryCategory | ||
|---|---|---|---|
| GET,PUT,POST | /{Workspace}/InventoryCategory/{ObjectId} | 
import Foundation
import ServiceStack
public class InventoryCategory : InventoryTreeNode
{
    public var type:String
    public var objectId:String
    public var workspace:String
    public var itemCategory:String
    public var hideFor:[String] = []
    public var showFor:[String] = []
    public var parentCategoryId:String
    public var enabled:Bool?
    public var childNodes:[InventoryTreeNode] = []
    public var includeInactive:Bool
    required public init(){ super.init() }
    private enum CodingKeys : String, CodingKey {
        case type
        case objectId
        case workspace
        case itemCategory
        case hideFor
        case showFor
        case parentCategoryId
        case enabled
        case childNodes
        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)
        itemCategory = try container.decodeIfPresent(String.self, forKey: .itemCategory)
        hideFor = try container.decodeIfPresent([String].self, forKey: .hideFor) ?? []
        showFor = try container.decodeIfPresent([String].self, forKey: .showFor) ?? []
        parentCategoryId = try container.decodeIfPresent(String.self, forKey: .parentCategoryId)
        enabled = try container.decodeIfPresent(Bool.self, forKey: .enabled)
        childNodes = try container.decodeIfPresent([InventoryTreeNode].self, forKey: .childNodes) ?? []
        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 itemCategory != nil { try container.encode(itemCategory, forKey: .itemCategory) }
        if hideFor.count > 0 { try container.encode(hideFor, forKey: .hideFor) }
        if showFor.count > 0 { try container.encode(showFor, forKey: .showFor) }
        if parentCategoryId != nil { try container.encode(parentCategoryId, forKey: .parentCategoryId) }
        if enabled != nil { try container.encode(enabled, forKey: .enabled) }
        if childNodes.count > 0 { try container.encode(childNodes, forKey: .childNodes) }
        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 .jsv suffix or ?format=jsv
The following are sample HTTP requests and responses. The placeholders shown need to be replaced with actual values.
POST /{Workspace}/InventoryCategory HTTP/1.1 
Host: dev.fieldsquared.com 
Accept: text/jsv
Content-Type: text/jsv
Content-Length: length
{
	Type: Category,
	ObjectId: String,
	Workspace: String,
	ItemCategory: String,
	HideFor: 
	[
		String
	],
	ShowFor: 
	[
		String
	],
	ParentCategoryId: String,
	Enabled: False,
	ChildNodes: 
	[
		{
			
		}
	],
	IncludeInactive: False,
	DescendantCount: 0
}