Platform API

<back to all web services

GetRelatedItems

Get related items related to the specified object.

Requires Authentication
The following routes are available for this service:
All Verbs/api/relateditems/{ObjectId}
import Foundation
import ServiceStack

/**
* Get related items related to the specified object.
*/
// @Api(Description="Get related items related to the specified object.")
public class GetRelatedItems : PagedModel
{
    /**
    * Object to get related items for.
    */
    // @ApiMember(Description="Object to get related items for.", IsRequired=true, Name="ObjectId")
    public var objectId:String

    /**
    * Significant Only or All
    */
    // @ApiMember(Description="Significant Only or All", IsRequired=true, Name="RelatedItemsLevel")
    public var relatedItemsLevel:String

    /**
    * Return all connections or paged results?
    */
    // @ApiMember(Description="Return all connections or paged results?", Name="IsPagedMode")
    public var isPagedMode:Bool

    required public init(){ super.init() }

    private enum CodingKeys : String, CodingKey {
        case objectId
        case relatedItemsLevel
        case isPagedMode
    }

    required public init(from decoder: Decoder) throws {
        try super.init(from: decoder)
        let container = try decoder.container(keyedBy: CodingKeys.self)
        objectId = try container.decodeIfPresent(String.self, forKey: .objectId)
        relatedItemsLevel = try container.decodeIfPresent(String.self, forKey: .relatedItemsLevel)
        isPagedMode = try container.decodeIfPresent(Bool.self, forKey: .isPagedMode)
    }

    public override func encode(to encoder: Encoder) throws {
        try super.encode(to: encoder)
        var container = encoder.container(keyedBy: CodingKeys.self)
        if objectId != nil { try container.encode(objectId, forKey: .objectId) }
        if relatedItemsLevel != nil { try container.encode(relatedItemsLevel, forKey: .relatedItemsLevel) }
        if isPagedMode != nil { try container.encode(isPagedMode, forKey: .isPagedMode) }
    }
}

public class PagedModel : Codable
{
    /**
    * Page Number to retrieve
    */
    // @ApiMember(DataType="int", Description="Page Number to retrieve", Name="PageNumber")
    public var pageNumber:Int

    /**
    * Number of records to retrieve
    */
    // @ApiMember(DataType="int", Description="Number of records to retrieve", Name="PageSize")
    public var pageSize:Int

    /**
    * Index of field to sort results by
    */
    // @ApiMember(DataType="int", Description="Index of field to sort results by", Name="SortIndex")
    public var sortIndex:Int

    /**
    * Sort Order - Ascending or Descending
    */
    // @ApiMember(DataType="int", Description="Sort Order - Ascending or Descending", Name="SortOrder")
    public var sortOrder:SortOrder

    required public init(){}
}

public enum SortOrder : String, Codable
{
    case Ascending
    case Descending
}

// @ApiResponse(Description="Items related to the object.")
public class GetRelatedItemsResponse : Codable
{
    public var relatedItems:[RelatedItemsModel]
    public var totalRelatedItems:Int
    public var responseStatus:ResponseStatus

    required public init(){}
}

public class RelatedItemsModel : Codable
{
    /**
    * Object linked to the related item.
    */
    // @ApiMember(DataType="Guid", Description="Object linked to the related item.", IsRequired=true, Name="ObjectId")
    public var objectId:String

    /**
    * Related item name.
    */
    // @ApiMember(DataType="string", Description="Related item name.", Name="RelatedItemName")
    public var relatedItemName:String

    /**
    * Related item type.
    */
    // @ApiMember(DataType="string", Description="Related item type.", Name="RelatedItemType")
    public var relatedItemType:String

    /**
    * Date of creation of the related item.
    */
    // @ApiMember(DataType="DateTime", Description="Date of creation of the related item.", IsRequired=true, Name="CreatedAt")
    public var createdAt:Date

    /**
    * Contact who created the related item
    */
    // @ApiMember(DataType="string", Description="Contact who created the related item", Name="CreatedByName")
    public var createdByName:String

    /**
    * Contact who created the related item
    */
    // @ApiMember(DataType="Guid", Description="Contact who created the related item", Name="CreatedById")
    public var createdById:String

    /**
    * Profile photo of the contact who created the related item
    */
    // @ApiMember(DataType="string", Description="Profile photo of the contact who created the related item", Name="CreatedByThumbnailUrl")
    public var createdByThumbnailUrl:String

    /**
    * Relationship between objects linked to the related item
    */
    // @ApiMember(DataType="string", Description="Relationship between objects linked to the related item", Name="Relationship")
    public var relationship:String

    /**
    * Is the related item significant?
    */
    // @ApiMember(DataType="bool", Description="Is the related item significant?", IsRequired=true, Name="IsSignificant")
    public var isSignificant:Bool

    required public init(){}
}


Swift GetRelatedItems 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

HTTP + JSON

The following are sample HTTP requests and responses. The placeholders shown need to be replaced with actual values.

POST /api/relateditems/{ObjectId} HTTP/1.1 
Host: pfapi.pstpf.com.au 
Accept: application/json
Content-Type: application/json
Content-Length: length

{"ObjectId":"00000000-0000-0000-0000-000000000000","RelatedItemsLevel":"00000000-0000-0000-0000-000000000000","IsPagedMode":false,"PageNumber":0,"PageSize":0,"SortIndex":0,"SortOrder":"Ascending"}
HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: length

{"RelatedItems":[{"ObjectId":"00000000-0000-0000-0000-000000000000","RelatedItemName":"String","RelatedItemType":"String","CreatedAt":"0001-01-01T00:00:00.0000000","CreatedByName":"String","CreatedById":"00000000-0000-0000-0000-000000000000","CreatedByThumbnailUrl":"String","Relationship":"String","IsSignificant":false}],"TotalRelatedItems":0,"ResponseStatus":{"ErrorCode":"String","Message":"String","StackTrace":"String","Errors":[{"ErrorCode":"String","FieldName":"String","Message":"String","Meta":{"String":"String"}}],"Meta":{"String":"String"}}}