(used for deducting tasks)

Request parameters

  • tenant — (mandatory) - business tenant, e.g. "zegoal"

  • account_id — (conditional) - Account ID

  • account_name — (conditional) - Account Name

  • account_code — (conditional) - Account Code

  • id — (optional; default hash()) - unique ID of this event

  • operation — (optional; default end) - type of operation (or reservation): start, end or extend; currently only value end properly works start — (optional; default now()) - start date—time of event *

  • type - (optional; default "") - event type, e.g. USAGE, RECURRING, CHARGE_ONETIMEFEE

  • subtype — (optional; no default) - event sybtype (where applicable), e.g. SMS or VOICE for USAGE type

  • business_name — (optional; default "") - business name of a rule that is expected to be applied; important to be provided for event types RECURRING and CHARGE_ONETIMEFEE

  • value — (optional; default 0) - quantity that has to be processed, means "seconds" for voice call, "bytes" for SMS, "percentage" of coverage that should be applied for recurring operation processing etc.

One of conditional parameters: account_id, or account_name, or account_code - is mandatory to be provided.

Response parameters

Response of ProcessEvent API contains plenty of details from Rating Engine. Currently you will not need them (later maybe as well). Just check processing_result in order to figure out whether request was successfully processed or not.


Request:

{
  "tenant": "zegoal",
  "type": "CHARGE_ONETIMEFEE",
  "value": "1",
  "operation": "end",
  "account_id": 13,
  "business_name": "DEDUCT_TASK"
}
CODE



Response

{
   "processing_result":    {
      "text": "ok",
      "status": "ok",
      "result_text": "ok",
      "result_code": "",
      "code": 0
   },
   "processing_date": "2019-04-25 16:08:35",
   "ProcessEvent":    {
      "response":       {
         "technical":          {
            "tenant": "zegoal",
            "rating_id": "q92E5qlJkXjr",
            "process_start_date": "2019-04-25 16:08:35",
            "calc_start_date": "2019-04-25 16:08:36",
            "calc_end_date": "2019-04-25 16:08:37",
            "TZ": "Europe/Minsk"
         },
         "rating":          {
            "total":             {
               "total_cost_tax": 0,
               "total_cost_net": 0,
               "total_cost_gross": 0
            },
            "rules": [            {
               "service": "",
               "rule_name": "START_DEDUCT_TASK",
               "rule_id": 3,
               "prorate_cost": "",
               "multiplier": "",
               "multiplied_cost": "",
               "initial_cost": -1,
               "full_cost": -5,
               "dependency": "",
               "covered_percentage": 5,
               "balances": [               {
                  "pockets": [                  {
                     "pocket_label": "START",
                     "pocket_before":                      {
                        "value": 200,
                        "pocket_start": "undefined",
                        "pocket_end": "2019-05-01 00:00:00"
                     },
                     "pocket_after":                      {
                        "value": 195,
                        "pocket_start": "undefined",
                        "pocket_end": "2019-05-01 00:00:00"
                     }
                  }],
                  "balance_unit": "CNT",
                  "balance_name": "TASKS",
                  "balance_id": 2,
                  "balance_before": {"balance_value_before": 400},
                  "balance_after": {"balance_value_after": 400}
               }]
            }],
            "result": "ok",
            "extra_operations":             {
               "result": false,
               "details": []
            }
         },
         "input_enriched": {"current_time": "2019-04-25 16:08:35"},
         "account_profile":          {
            "services":             [
                              {
                  "to": "",
                  "state": "ACT",
                  "service": "START",
                  "refid": 15,
                  "from": "2019-04-25 16:07:53",
                  "account": 15
               },
                              {
                  "to": "",
                  "state": "ACT",
                  "service": "START",
                  "refid": 16,
                  "from": "2019-04-25 16:07:54",
                  "account": 15
               }
            ],
            "personal_rules":             [
                              {
                  "sold_product_id": 15,
                  "rule":                   {
                     "type": "RECURRING",
                     "subtype": "",
                     "service": "START",
                     "recurrent_obj":                      {
                        "periodic_operation": true,
                        "period": "monthly_1st_to_1st",
                        "affect_next_trigger": true
                     },
                     "rate_mode": "CHARGING",
                     "prorate": true,
                     "priority": 100,
                     "price_obj": [                     {
                        "trigger_action": ["START_monthly_tasks"],
                        "size": 100,
                        "priority": 100,
                        "overriden_cost": -12,
                        "original_cost": -12,
                        "multiplier": 4,
                        "init_size": 0,
                        "init_cost": 0,
                        "id": 1,
                        "cost": -48
                     }],
                     "price_id": 1,
                     "pocket_obj": {"use_pockets": "time_valid"},
                     "override_allowed": true,
                     "offering_code": "START",
                     "name": 1,
                     "multiplier_allowed": true,
                     "dependency": "",
                     "coverage": {"partial": false},
                     "code": "START_monthly_payment",
                     "business_name": "START",
                     "balance_type": "Money_BYN",
                     "balance": ["Money_BYN"]
                  },
                  "product_id": 15,
                  "price_id": 1,
                  "pd_offering_id": 1,
                  "multiplier": 4,
                  "account": 15
               },
                              {
                  "sold_product_id": 16,
                  "rule":                   {
                     "type": "RECURRING",
                     "subtype": "",
                     "service": "START",
                     "recurrent_obj":                      {
                        "periodic_operation": true,
                        "period": "monthly_1st_to_1st",
                        "affect_next_trigger": true
                     },
                     "rate_mode": "CHARGING",
                     "prorate": true,
                     "priority": 100,
                     "price_obj": [                     {
                        "trigger_action": ["START_monthly_tasks"],
                        "size": 100,
                        "priority": 100,
                        "overriden_cost": -12,
                        "original_cost": -12,
                        "multiplier": 4,
                        "init_size": 0,
                        "init_cost": 0,
                        "id": 1,
                        "cost": -48
                     }],
                     "price_id": 1,
                     "pocket_obj": {"use_pockets": "time_valid"},
                     "override_allowed": true,
                     "offering_code": "START",
                     "name": 1,
                     "multiplier_allowed": true,
                     "dependency": "",
                     "coverage": {"partial": false},
                     "code": "START_monthly_payment",
                     "business_name": "START",
                     "balance_type": "Money_BYN",
                     "balance": ["Money_BYN"]
                  },
                  "product_id": 16,
                  "price_id": 1,
                  "pd_offering_id": 1,
                  "multiplier": 4,
                  "account": 15
               }
            ],
            "params": [{"code": ""}],
            "creation_date": "2019-04-25 16:07:31",
            "category": "Postpaid",
            "balances":             [
                              {
                  "total_value_before": 0,
                  "total_value_after": 0,
                  "pockets": [                  {
                     "value": 0,
                     "start": "",
                     "reserved": 0,
                     "max": 0,
                     "label": "",
                     "end": ""
                  }],
                  "name": "USERS",
                  "balance": "USERS",
                  "account": 15
               },
                              {
                  "total_value_before": 400,
                  "total_value_after": 400,
                  "pockets":                   [
                                          {
                        "value": 0,
                        "start": "",
                        "reserved": 0,
                        "max": 0,
                        "label": "",
                        "end": ""
                     },
                                          {
                        "value": 200,
                        "start": "undefined",
                        "reserved": 0,
                        "max": 0,
                        "label": "START",
                        "end": "2019-05-01 00:00:00"
                     },
                                          {
                        "value": 200,
                        "start": "undefined",
                        "reserved": 0,
                        "max": 0,
                        "label": "START",
                        "end": "2019-05-01 00:00:00"
                     }
                  ],
                  "name": "TASKS",
                  "balance": "TASKS",
                  "account": 15
               },
                              {
                  "total_value_before": 0,
                  "total_value_after": 0,
                  "pockets": [                  {
                     "value": 0,
                     "start": "",
                     "reserved": 0,
                     "max": 0,
                     "label": "",
                     "end": ""
                  }],
                  "name": "Money_BYN",
                  "balance": "Money_BYN",
                  "account": 15
               }
            ],
            "account": 15
         }
      },
      "request":       {
         "value": "5",
         "type": "CHARGE_ONETIMEFEE",
         "tenant": "zegoal",
         "subtype": "",
         "operation": "end",
         "id": "",
         "business_name": "DEDUCT_TASK",
         "account_id": 15
      }
   }
}
CODE


Response (error):

{
  "processing_result": {
    "text": "Error happened during Event charging",
    "status": "error",
    "code": 1
  },
  "processing_date": "2018-01-10 15:47:46 +02:00",
  "ProcessEvent": {
    "response": {
      "charge_event": {
        "x_result": "unsatisfied event",
        "tax": {
          "net": 277.647059,
          "VAT": 55.529412,
          "PF": 20.823529
        },
        "rating_id": "WR8EvrQ290rW",
        "process_start_date": "2018-01-10 15:47:43",
        "operations": […],
        "extra_operations": {…},
        "event": {…},
        "coverage": […],
        …
      }
    },
    "request": {
      "value": 1,
      "type": "CHARGE_ONETIMEFEE",
      "tenant": "taskvizor",
      "operation": "end",
      "id": "qwerty234",
      "business_name": "DEDUCT_TASK",
      "account": 500
    }
  }
}
CODE