#!/usr/bin/partner2-test -w
{
   "name" : "Получение правил по id",
   "options" : {
      "fields" : {
         "__NOTE__" : [
            {
               "login" : "доступно только для менеджера!!",
               "owner_id" : "доступно только для менеджера!!"
            }
         ],
         "business_rules" : [
            "actions",
            "available_fields",
            "blocks",
            "blocks_count",
            "caption",
            "conditions",
            "cpm",
            "create_date",
            "editable_fields",
            "fields_depends",
            "is_deleted",
            "is_stopped",
            "multistate",
            "multistate_name",
            "position",
            "public_id",
            "rule_id",
            "status",
            "owner_id"
         ]
      },
      "mock_bk" : true,
      "read_only" : true
   },
   "testcase" : "",
   "tests" : [
      {
         "request" : {
            "method" : "get",
            "name" : "Попытка получить недозволеные поля под юзером $TOKEN",
            "token" : "mocked-yan-partner",
            "url" : "/v1/business_rules/10?fields[business_rules]=login"
         },
         "response" : {
            "body" : {
               "errors" : [
                  {
                     "detail" : "Unexpected fields: login",
                     "id" : "1",
                     "title" : "Bad Request"
                  }
               ]
            },
            "content_type" : "application/vnd.api+json",
            "status" : "400"
         }
      },
      {
         "request" : {
            "method" : "get",
            "name" : "Все поля под юзером $TOKEN",
            "token" : "mocked-yan-partner",
            "url" : "/v1/business_rules/10?$FIELDS[business_rules]"
         },
         "response" : {
            "body" : {
               "data" : {
                  "attributes" : {
                     "actions" : {
                        "archive" : "Archive",
                        "edit" : "Edit",
                        "move" : "Move",
                        "stop" : "Stop"
                     },
                     "available_fields" : {
                        "actions" : true,
                        "available_fields" : true,
                        "blocks" : true,
                        "blocks_count" : true,
                        "caption" : true,
                        "conditions" : true,
                        "cpm" : true,
                        "create_date" : true,
                        "editable_fields" : true,
                        "fields_depends" : true,
                        "is_deleted" : true,
                        "is_stopped" : true,
                        "multistate" : true,
                        "multistate_name" : true,
                        "owner_id" : true,
                        "position" : true,
                        "public_id" : true,
                        "rule_id" : true,
                        "send_time" : true,
                        "status" : true,
                        "update_time" : true
                     },
                     "blocks" : [
                        "R-A-41443-1",
                        "D-A-142898-1"
                     ],
                     "blocks_count" : 2,
                     "caption" : "Rule #10 - working (mocked-yan-partner)",
                     "conditions" : {
                        "browsers" : [
                           2,
                           88
                        ],
                        "devices" : [
                           "desktop",
                           "smarttv"
                        ],
                        "query_args" : {
                           "puid1" : [
                              "foo",
                              "bar"
                           ],
                           "puid63" : [
                              "baz"
                           ]
                        },
                        "regions" : [
                           1,
                           255
                        ],
                        "systems" : [
                           15,
                           33
                        ],
                        "urls" : [
                           "http://foo.com",
                           "https://bar.net"
                        ]
                     },
                     "cpm" : 99,
                     "create_date" : "2017-11-20 08:56:18",
                     "editable_fields" : {
                        "blocks" : true,
                        "caption" : true,
                        "conditions" : true,
                        "cpm" : true
                     },
                     "fields_depends" : {
                        "depends" : {},
                        "required" : {}
                     },
                     "is_deleted" : false,
                     "is_stopped" : false,
                     "multistate" : 1,
                     "multistate_name" : "Working.",
                     "owner_id" : 1009,
                     "position" : 1,
                     "rule_id" : 10,
                     "send_time" : "2017-12-20 10:05:59",
                     "status" : "sync",
                     "update_time" : "2017-12-20 10:01:59"
                  },
                  "id" : "10",
                  "relationships" : {},
                  "type" : "business_rules"
               },
               "links" : {
                  "add_fields" : "https://127.0.0.1:80/v1/business_rules/add_fields",
                  "self" : "https://127.0.0.1:80/v1/business_rules/10"
               },
               "meta" : {
                  "fields" : [
                     "actions",
                     "available_fields",
                     "blocks",
                     "blocks_count",
                     "caption",
                     "conditions",
                     "cpm",
                     "create_date",
                     "editable_fields",
                     "fields_depends",
                     "is_deleted",
                     "is_stopped",
                     "multistate",
                     "multistate_name",
                     "owner_id",
                     "position",
                     "rule_id",
                     "send_time",
                     "status",
                     "update_time"
                  ]
               }
            },
            "content_type" : "application/vnd.api+json",
            "status" : "200"
         }
      }
   ]
}
