How toWeb Service Developer Guide

Web Service Developer Guide

Sana Commerce 8.2
Your provider

Criterion Types

In the Sana Commerce web service five types of filtering criterion are available:

Criterion type Description
EqualCriterion Checks whether the filtered field matches the given exact value.
ContainsCriterion Checks whether the filtered field contains the given value.
BetweenCriterion Checks whether the filtered field fits in the range of two given values.
GreaterCriterion Checks whether the filtered field is greater than the given value.
LessCriterion Checks whether the filtered field is less than the given value.

The table below provides the criteria format for the request in XML:

Criterion type XML
EqualCriterion
<Criterion i:type="EqualCriterion">
  <Value i:type="a:int" xmlns:a="http://www.w3.org/2001/XMLSchema">1</Value>
  <Not>false</Not>
</Criterion>
ContainsCriterion
<Criterion i:type="ContainsCriterion">
  <Value i:type="a:int" xmlns:a="http://www.w3.org/2001/XMLSchema">1</Value>
  <Not>false</Not>
</Criterion>
BetweenCriterion
<Criterion i:type="BetweenCriterion">
  <HighValue i:type="a:int" xmlns="http://schemas.datacontract.org/2004/07/Sana.Filtering" xmlns:a="http://www.w3.org/2001/XMLSchema">10</HighValue>
  <LowValue i:type="a:int" xmlns="http://schemas.datacontract.org/2004/07/Sana.Filtering" xmlns:a="http://www.w3.org/2001/XMLSchema">1</LowValue>
</Criterion>
GreaterCriterion
<Criterion i:type="GreaterCriterion">
  <Value i:type="a:int" xmlns:a="http://www.w3.org/2001/XMLSchema">1</Value>
  <StrictGreater>false</StrictGreater>
</Criterion>
LessCriterion
<Criterion i:type="LessCriterion">
  <Value i:type="a:int" xmlns:a="http://www.w3.org/2001/XMLSchema">1</Value>
  <StrictLess>false</StrictLess>
</Criterion>

The table below provides the criteria format for the request in JSON:

Criterion type JSON
EqualCriterion
{
"__type":"EqualCriterion",
"Value":1,
"Not":false
}
ContainsCriterion
{
"__type":"ContainsCriterion",
"Value":1,
"Not":false
}
BetweenCriterion
{
"__type":"BetweenCriterion",
"HighValue":10,
"LowValue":1
}
GreaterCriterion
{
"__type":"GreaterCriterion",
"Value":1,
"StrictGreater":false
}
LessCriterion
{
"__type":"LessCriterion",
"Value":1,
"StrictLess":false
}

The type of the criterion must be specified in the i:type attribute in the XML format or in the "__type" property in JSON:

XML JSON
<Criterion i:type="EqualCriterion">
"__type":"EqualCriterion"


In XML the 'i' namespace used in the i:type attribute must be set in the root ProductListLoadOptions node:
<ProductListLoadOptions xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
    ...
         <Value i:type="a:int" xmlns:a="http://www.w3.org/2001/XMLSchema">1</Value>


In JSON the '__type' property must be set before any other properties in the object. Otherwise, the request will not be parsed correctly.

The correct example:

{
    "__type":"EqualCriterion",
    "Value":1,
    "Not":false
}

The incorrect example:

{
    "Value":1,
    "__type":"EqualCriterion",   
    "Not":false
}

There are additional properties for different criteria. The table below provides the explanation of these properties for each criterion type:

Criterion type Criterion property Explanation
EqualCriterion Value The actual value of the filter.
Not Can be true or false.
If false then the comparison is straight. This means that the filter is an equivalent to 'if equals'.
If true then the comparison is inverted. This means that the filter is an equivalent to 'if NOT equals'.
ContainsCriterion Value The actual value of the filter.
Not Can be true or false.
If false then the comparison is straight. This means that the filter is an equivalent to 'if contains'.
If true then the comparison is inverted. This means that the filter is an equivalent to 'if NOT contains'.
BetweenCriterion HighValue The higher value of the range.
LowValue The lower value of the range.
GreaterCriterion Value The actual value of the filter.
StrictGreater Can be true or false.
If true then the comparison is strict. This means that the filter is an equivalent to 'if greater'.
If false then the comparison is not strict. This means that the filter is an equivalent to 'if greater or equal'.
LessCriterion Value The actual value of the filter.
StrictGreater Can be true or false.
If true then the comparison is strict. This means that the filter is an equivalent to 'if less'.
If false then the comparison is not strict. This means that the filter is an equivalent to 'if less or equal'.
How toWeb Service Developer Guide