This example shows how to GET (read) metadata for currencies filtered by the runtime attribute filterRuntimeAttribute , then metadata for currencies by the orderBy runtime attribute.
Add a runtime attribute to the Currency Type.
Sample Code
INSERT_UPDATE AttributeDescriptor; qualifier[unique = true]; attributeType(code); enclosingType(code)[unique = true]; autocreate; partOf; unique; optional; generate;
; filterRuntimeAttribute ; java.lang.String ; Currency ; false ; false ; false ; true ; false ;
INSERT_UPDATE IntegrationObject; code[unique = true] ; integrationType(code);
; FilterRuntimeAttributeIO ; INBOUND ;
INSERT_UPDATE IntegrationObjectItem; integrationObject(code)[unique = true]; code[unique = true]; type(code); root[default = false];
; FilterRuntimeAttributeIO ; Currency ; Currency ; true ;
INSERT_UPDATE IntegrationObjectItemAttribute; integrationObjectItem(integrationObject(code), code)[unique = true]; attributeName[unique = true]; attributeDescriptor(enclosingType(code), qualifier); returnIntegrationObjectItem(integrationObject(code), code); unique[default = false];
; FilterRuntimeAttributeIO:Currency ; isocode ; Currency:isocode ; ; true ;
; FilterRuntimeAttributeIO:Currency ; symbol ; Currency:symbol ; ; ;
; FilterRuntimeAttributeIO:Currency ; filterRuntimeAttribute ; Currency:filterRuntimeAttribute ; ; ;
POST currencies with different values for the runtime attributes.
Sample Code
URL: {{fullURL}}/FilterRuntimeAttributeIO/Currencies
First request body:
{
"isocode":"currency1",
"symbol":"symbol1",
"filterRuntimeAttribute": "filtervalue1"
}
Second request body:
{
"isocode":"currency2",
"symbol":"symbol2",
"filterRuntimeAttribute": "filtervalue2"
}
GET currencies filtered by the runtime attribute.
Sample Code
URL: {{fullURL}}/FilterRuntimeAttributeIO/Currencies?$filter=filterRuntimeAttribute eq 'filtervalue1'
Respose 200 OK with body:
{
"d": {
"results": [
{
"__metadata": {
"id": "https://localhost:9002/odata2webservices/FilterRuntimeAttributeIO/Currencies('currency1')",
"uri": "https://localhost:9002/odata2webservices/FilterRuntimeAttributeIO/Currencies('currency1')",
"type": "HybrisCommerceOData.Currency"
},
"symbol": "symbol1",
"isocode": "currency1",
"filterRuntimeAttribute": "filtervalue1",
"integrationKey": "currency1"
}
]
}
}
GET currencies orderBy runtime attribute.
Sample Code
URL: {{fullURL}}/FilterRuntimeAttributeIO/Currencies?$orderby=filterRuntimeAttribute
Response 200 OK with body:
{
"d": {
"results": [
{
"__metadata": {
"id": "https://localhost:9002/odata2webservices/FilterRuntimeAttributeIO/Currencies('EUR')",
"uri": "https://localhost:9002/odata2webservices/FilterRuntimeAttributeIO/Currencies('EUR')",
"type": "HybrisCommerceOData.Currency"
},
"symbol": "€",
"isocode": "EUR",
"filterRuntimeAttribute": null,
"integrationKey": "EUR"
},
{
"__metadata": {
"id": "https://localhost:9002/odata2webservices/FilterRuntimeAttributeIO/Currencies('USD')",
"uri": "https://localhost:9002/odata2webservices/FilterRuntimeAttributeIO/Currencies('USD')",
"type": "HybrisCommerceOData.Currency"
},
"symbol": "$",
"isocode": "USD",
"filterRuntimeAttribute": null,
"integrationKey": "USD"
},
{
"__metadata": {
"id": "https://localhost:9002/odata2webservices/FilterRuntimeAttributeIO/Currencies('currency1')",
"uri": "https://localhost:9002/odata2webservices/FilterRuntimeAttributeIO/Currencies('currency1')",
"type": "HybrisCommerceOData.Currency"
},
"symbol": "symbol1",
"isocode": "currency1",
"filterRuntimeAttribute": "filtervalue1",
"integrationKey": "currency1"
},
{
"__metadata": {
"id": "https://localhost:9002/odata2webservices/FilterRuntimeAttributeIO/Currencies('currency2')",
"uri": "https://localhost:9002/odata2webservices/FilterRuntimeAttributeIO/Currencies('currency2')",
"type": "HybrisCommerceOData.Currency"
},
"symbol": "symbol2",
"isocode": "currency2",
"filterRuntimeAttribute": "filtervalue2",
"integrationKey": "currency2"
}
]
}
}