Here you can find all the Rule sets combinations for an Achievement creation POST via API. The Achievement has to have at least 1 rule sets with an actions that is award this achievement.
Resource URL:
https://<apphost>.competitionlabs.com/api/<your-space-name>/achievements
X-API-KEY | Your unique API key | Yes |
Content-Type | application/json | Yes |
Request URL parameters
Post body ruleSets parameter
Parameter | Type | Required | Description |
---|
ruleSets
| Array [Object]
| Yes
| A list of RuleSets | Type | Required | Description |
priority | Integer | Yes | A value to display the rules in order |
scope | String | Yes | What model it belongs to for example contest or achievement |
onMatchThen | String | No | Only Required when "Custom points" action is selected in a contest creation |
onMatchConstant | String | No | Only Required when "Custom points" action is selected in a contest creation |
action | String | Yes | Displays the rule set.
Award this achievement
"action": "member.achievement"
|
conditions
| Array [Object]
| Yes
| | Type | Required | Description
|
matchCondition | Enum | Yes | Whether the rules must all evaluate as True or False or at least one of the rules must be True or False to satisfy the rule |
mustEvaluateTo | Boolean | Yes | The value the rule(s) must evaluate to for the rule to be satisfied |
rules
| Array [Object]
| Yes
| MainRule model. | Type | Required | Description |
fact | String | Yes | Displays the facts of the rule.
The count of events where the nested condition(s) evaluate to TRUE for the event
"fact": "event.count"
The average source value for events where the nested condition(s) evaluate to TRUE for the event
"fact": "avg.event.source.value"
The sum of all the source values for events where the nested condition(s) evaluate to TRUE for the event
"fact": "sum.event.source.value"
The largest source value in events where the nested condition(s) evaluate to TRUE for the event
"fact": "max.event.source.value"
The smallest source value in events where the nested condition(s) evaluate to TRUE for the event
"fact": "min.event.source.value"
The average points for all matching events
"fact": "avg.event.points.value"
The sum of all the points for events where the nested condition(s) evaluate to TRUE for the event
"fact": "sum.event.points.value"
The largest point value for all matching events
"fact": "max.event.points.value"
The smallest point in events where the nested condition(s) evaluate to TRUE for the event
"fact": "min.event.points.value"
|
operator | String | Yes | Part of the rule which operates the fact ex. is, more than, less than etc.
For "The count of events where the nested condition(s) evaluate to TRUE for the event"
is equal to or more than
"operator": ">="
is more than
"operator": ">"
is
operator": "=="
is less than or equal to
operator": "<="
is less than
operator": "<"
For "The average source value for events where the nested condition(s) evaluate to TRUE for the event"
is equal to or more than
"operator": ">="
is more than
"operator": ">"
is
operator": "=="
is less than or equal to
operator": "<="
is less than
operator": "<"
For "The sum of all the source values for events where the nested condition(s) evaluate to TRUE for the event"
is equal to or more than
"operator": ">="
is more than
"operator": ">"
is
operator": "=="
is less than or equal to
operator": "<="
is less than
operator": "<"
For "The largest source value in events where the nested condition(s) evaluate to TRUE for the event"
is equal to or more than
"operator": ">="
is more than
"operator": ">"
is
operator": "=="
is less than or equal to
operator": "<="
is less than
operator": "<"
For "The smallest source value in events where the nested condition(s) evaluate to TRUE for the event"
is equal to or more than
"operator": ">="
is more than
"operator": ">"
is
operator": "=="
is less than or equal to
operator": "<="
is less than
operator": "<"
For "The average points for all matching events"
is equal to or more than
"operator": ">="
is more than
"operator": ">"
is
operator": "=="
is less than or equal to
operator": "<="
is less than
operator": "<"
For "The sum of all the points for events where the nested condition(s) evaluate to TRUE for the event"
is equal to or more than
"operator": ">="
is more than
"operator": ">"
is
operator": "=="
is less than or equal to
operator": "<="
is less than
operator": "<"
For "The largest point value for all matching events"
is equal to or more than
"operator": ">="
is more than
"operator": ">"
is
operator": "=="
is less than or equal to
operator": "<="
is less than
operator": "<"
For "The smallest point in events where the nested condition(s) evaluate to TRUE for the event"
is equal to or more than
"operator": ">="
is more than
"operator": ">"
is
operator": "=="
is less than or equal to
operator": "<="
is less than
operator": "<"
|
constant | String | Yes | A rules value that defines the fact ex. if the fact is "the action" then the constant is "win". All constants are variables. |
subConditions | Array [Object] | Optional | subConditionSet model. Works the same as Main condition set model. Continue below |
Parameter | Type | Required | Description |
---|
subConditions
| Array [Object]
| Yes
| subConditionSet model. | Type | Required | Description |
matchCondition | Enum | Yes | Whether the rules must all evaluate as True or False or at least one of the rules must be True or False to satisfy the rule |
mustEvaluateTo | Boolean | Yes | The value the rule(s) must evaluate to for the rule to be satisfied |
subRules
| Array [Object]
| Yes
| | Type | Required | Description
|
fact | String | Yes | Valid rules facts, ex. the action, the product, the sum of events etc.
The external event reference id
"fact": "event.external.id"
The action is example is BET, WIN and so on
"fact": "event.action.type"
The product or the games
"fact": "event.product.id"
The event source value
"fact": "event.source.value"
The event points value
"fact": "event.points.value"
The event transaction timeStamp in minutes
"fact": "event.transaction.timeStamp"
The external event reference id
"fact": "event.external.id"
The action is example is BET, WIN and so on
"fact": "event.action.type"
The product or the games
"fact": "event.product.id"
The event source value
"fact": "event.source.value"
The event points value
"fact": "event.points.value"
The event transaction timeStamp in minutes
"fact": "event.transaction.timeStamp"
The external event reference id
"fact": "event.external.id"
The action is example is BET, WIN and so on
"fact": "event.action.type"
The product or the games
"fact": "event.product.id"
The event source value
"fact": "event.source.value"
The event points value
"fact": "event.points.value"
The event transaction timeStamp in minutes
"fact": "event.transaction.timeStamp"
The external event reference id
"fact": "event.external.id"
The action is example is BET, WIN and so on
"fact": "event.action.type"
The product or the games
"fact": "event.product.id"
The event source value
"fact": "event.source.value"
The event points value
"fact": "event.points.value"
The event transaction timeStamp in minutes
"fact": "event.transaction.timeStamp"
The external event reference id
"fact": "event.external.id"
The action is example is BET, WIN and so on
"fact": "event.action.type"
The product or the games
"fact": "event.product.id"
The event source value
"fact": "event.source.value"
The event points value
"fact": "event.points.value"
The event transaction timeStamp in minutes
"fact": "event.transaction.timeStamp"
The external event reference id
"fact": "event.external.id"
The action is example is BET, WIN and so on
"fact": "event.action.type"
The product or the games
"fact": "event.product.id"
The event source value
"fact": "event.source.value"
The event points value
"fact": "event.points.value"
The event transaction timeStamp in minutes
"fact": "event.transaction.timeStamp"
The external event reference id
"fact": "event.external.id"
The action is example is BET, WIN and so on
"fact": "event.action.type"
The product or the games
"fact": "event.product.id"
The event source value
"fact": "event.source.value"
The event points value
"fact": "event.points.value"
The event transaction timeStamp in minutes
"fact": "event.transaction.timeStamp"
The external event reference id
"fact": "event.external.id"
The action is example is BET, WIN and so on
"fact": "event.action.type"
The product or the games
"fact": "event.product.id"
The event source value
"fact": "event.source.value"
The event points value
"fact": "event.points.value"
The event transaction timeStamp in minutes
"fact": "event.transaction.timeStamp"
The external event reference id
"fact": "event.external.id"
The action is example is BET, WIN and so on
"fact": "event.action.type"
The product or the games
"fact": "event.product.id"
The event source value
"fact": "event.source.value"
The event points value
"fact": "event.points.value"
The event transaction timeStamp in minutes
"fact": "event.transaction.timeStamp"
|
operator | String | Yes | Part of the rule which operates the fact ex. is, more than, less than etc.
For "The external event reference id"
is
"operator": "=="
For "The action"
is
"operator": "=="
For "The product"
is
"operator": "=="
For "The event source value"
is equal to or more than
"operator": ">="
is more than
"operator": ">"
is equal to
operator": "=="
is less than or equal to
operator": "<="
is less than
operator": "<"
For "The event points value"
is equal to or more than
"operator": ">="
is more than
"operator": ">"
is equal to
operator": "=="
is less than or equal to
operator": "<="
is less than
operator": "<"
For "The event transaction timeStamp in minutes"
is less than
operator": "<"
is less than or equal to
operator": "<="
|
constant | String | Yes | A rules value that defines the fact ex. if the fact is "the action" then the constant is "win" |
EXAMPLE
"ruleSets": [
{
"jsonClass": "RuleSet",
"priority": 1,
"scope": "achievement",
"action": "member.achievement",
"conditions": [
{
"jsonClass": "MainConditionSet",
"matchCondition": "All",
"mustEvaluateTo": true,
"rules": [
{
"jsonClass": "MainRule",
"fact": "event.count",
"operator": ">=",
"constant": "5",
"subConditions": [
{
"jsonClass": "SubConditionSet",
"matchCondition": "All",
"mustEvaluateTo": true,
"subRules": [
{
"jsonClass": "SubRule",
"fact": "event.action.type",
"operator": "==",
"constant": "bet"
}
]
}
]
}
]
}
]
}
],
curl
--header "X-API-KEY: <your-api-key>"
--header "Content-Type: application/json"
--request POST https://app.competitionlabs.com/api/<your-space-name>/achievements
-d '{ "rewards": [],"achievement": { "jsonClass": "Achievement","name": "test3","description": "","initialState": 0,"icon": "IOOrTGgBJK8hOXbLqdcV","ruleSets": [{"jsonClass": "RuleSet","priority": 1,"scope": "achievement","action": "member.achievement","conditions": [{"jsonClass": "MainConditionSet","matchCondition": "All","mustEvaluateTo": true,"rules": [{"jsonClass": "MainRule","fact": "event.count","operator": ">=","constant": "5","id": "GOZjIW0BzPEHrdkQtkCd","subConditions": [{"jsonClass": "SubConditionSet","matchCondition": "All","mustEvaluateTo": true,"subRules": [{"jsonClass": "SubRule","fact": "event.external.id","operator": "==", "constant": "bet"}]}]}]}]}],"deprecated": false,"dependantOn": [],"minimumShouldMatch": 0,"scheduling": {"scheduleType": "Once","every": [],"startDate": "2019-09-11T17:33:00.000+00:00","onlyAggregateOnActiveDays": false},"achievementLiveStatus": "Live", "category": [], "memberGroups": [], "metadata": [], "translations": {}, "translatableFields": [ "name", "description"]}}'
{
"data": {
"jsonClass": "Achievement",
"name": "Test",
"accountId": "0sn4DmUBkPH_lz9GgxBM",
"description": "",
"initialState": 0,
"icon": "RIaekmsBbFCgxOIxCpQv",
"ruleSets": [
{
"jsonClass": "RuleSet",
"priority": 1,
"scope": "achievement",
"action": "member.achievement",
"conditions": [
{
"jsonClass": "MainConditionSet",
"matchCondition": "All",
"mustEvaluateTo": true,
"rules": [
{
"jsonClass": "MainRule",
"fact": "event.count",
"operator": ">=",
"constant": "5",
"subConditions": [
{
"jsonClass": "SubConditionSet",
"matchCondition": "All",
"mustEvaluateTo": true,
"subRules": [
{
"jsonClass": "SubRule",
"fact": "event.action.type",
"operator": "==",
"constant": "bet"
}
]
}
]
}
]
}
]
}
],
"deprecated": false,
"dependantOn": [],
"minimumShouldMatch": 0,
"scheduling": {
"scheduleType": "Once",
"scheduleOccurrencesLimit": 1,
"every": [],
"startDate": "2019-10-31T09:34:00.000+0000",
"onlyAggregateOnActiveDays": false
},
"achievementLiveStatus": "Live",
"category": [],
"memberGroups": [],
"metadata": [],
"created": "2019-10-31T09:35:02.773+0000",
"id": "4vorIW4ByrynV-OgGNp1",
"translations": {},
"translatableFields": [
"name",
"description"
]
}
}