{
  "name": "Запрос токена без ответа — не попытка операции: ошибка transport несёт флаг вызова",
  "description": "createLocation (запись без ключа): запрос токена оборвался после отправки, повтор получил 503, второй повтор снова оборвался — transport с mayHaveBeenProcessed = false и без ключа: запрос операции не уходил, обрыв и 503 запроса токена флаг не ставят. Поэтому createLocation можно повторить, не проверяя состояние: повтор получает токен и создаёт точку. adjustMemberPoints с токеном из кэша: первая попытка оборвалась после отправки, повтор получил 401 — токен забыт, а новый получить не удалось (три обрыва) — transport с mayHaveBeenProcessed = true и ключом вызова: первая попытка могла быть обработана. Запрос токена повторяется со своим счётчиком: паузы 500, 1000; затем 500 (повтор операции), 500, 1000 (повторы запроса токена).",
  "client": {
    "api": "management",
    "credential": {
      "clientCredentials": {
        "clientId": "lc_test_4b9ac4f5d6cc6783a2044a5a",
        "clientSecret": "lcs_test__A75hCwHKWYA61AD1WKWOkjtKvU2hRnSKCx_YVFfVos"
      }
    },
    "baseUrl": "https://api.example.com",
    "merchant": "01929c1e-0020-7020-8020-000000000020"
  },
  "calls": [
    {
      "operation": "createLocation",
      "args": {"body": {"code": "msk-01", "name": "Кофейня на Тверской", "address": "Москва, Тверская ул., 1"}},
      "expect": {
        "error": {"class": "transport", "mayHaveBeenProcessed": false, "idempotencyKey": null},
        "meta": {"operationId": "issueToken", "status": 503}
      }
    },
    {
      "operation": "createLocation",
      "args": {"body": {"code": "msk-01", "name": "Кофейня на Тверской", "address": "Москва, Тверская ул., 1"}},
      "expect": {
        "result": {
          "id": "01929c1e-0030-7030-8030-000000000030",
          "code": "msk-01",
          "name": "Кофейня на Тверской",
          "address": "Москва, Тверская ул., 1",
          "timezone": "Europe/Moscow",
          "brand_id": null,
          "legal_entity_id": null,
          "status": "active"
        }
      }
    },
    {
      "operation": "adjustMemberPoints",
      "args": {"member": "01929c1e-0040-7040-8040-000000000040", "body": {"amount": 500, "reason_code": "goodwill"}},
      "expect": {
        "error": {"class": "transport", "mayHaveBeenProcessed": true, "idempotencyKey": "{{idempotency-key}}"},
        "meta": {"operationId": "adjustMemberPoints", "status": 401, "requestId": "01929c20-0003-7000-8000-000000000003"}
      }
    }
  ],
  "exchanges": [
    {
      "request": {
        "method": "POST",
        "url": "https://api.example.com/api/management/v1/oauth/token",
        "headers": {
          "authorization": "Basic bGNfdGVzdF80YjlhYzRmNWQ2Y2M2NzgzYTIwNDRhNWE6bGNzX3Rlc3RfX0E3NWhDd0hLV1lBNjFBRDFXS1dPa2p0S3ZVMmhSblNLQ3hfWVZGZlZvcw==",
          "accept": "application/json",
          "content-type": "application/x-www-form-urlencoded",
          "idempotency-key": null,
          "loyal-merchant": null
        },
        "form": {"grant_type": "client_credentials"}
      },
      "failure": "after_send"
    },
    {
      "request": {
        "method": "POST",
        "url": "https://api.example.com/api/management/v1/oauth/token",
        "headers": {
          "authorization": "Basic bGNfdGVzdF80YjlhYzRmNWQ2Y2M2NzgzYTIwNDRhNWE6bGNzX3Rlc3RfX0E3NWhDd0hLV1lBNjFBRDFXS1dPa2p0S3ZVMmhSblNLQ3hfWVZGZlZvcw==",
          "accept": "application/json",
          "content-type": "application/x-www-form-urlencoded",
          "idempotency-key": null,
          "loyal-merchant": null
        },
        "form": {"grant_type": "client_credentials"}
      },
      "response": {"status": 503, "headers": {"Content-Type": "text/plain"}, "text": "Service Unavailable"}
    },
    {
      "request": {
        "method": "POST",
        "url": "https://api.example.com/api/management/v1/oauth/token",
        "headers": {
          "authorization": "Basic bGNfdGVzdF80YjlhYzRmNWQ2Y2M2NzgzYTIwNDRhNWE6bGNzX3Rlc3RfX0E3NWhDd0hLV1lBNjFBRDFXS1dPa2p0S3ZVMmhSblNLQ3hfWVZGZlZvcw==",
          "accept": "application/json",
          "content-type": "application/x-www-form-urlencoded",
          "idempotency-key": null,
          "loyal-merchant": null
        },
        "form": {"grant_type": "client_credentials"}
      },
      "failure": "after_send"
    },
    {
      "request": {
        "method": "POST",
        "url": "https://api.example.com/api/management/v1/oauth/token",
        "headers": {
          "authorization": "Basic bGNfdGVzdF80YjlhYzRmNWQ2Y2M2NzgzYTIwNDRhNWE6bGNzX3Rlc3RfX0E3NWhDd0hLV1lBNjFBRDFXS1dPa2p0S3ZVMmhSblNLQ3hfWVZGZlZvcw==",
          "accept": "application/json",
          "content-type": "application/x-www-form-urlencoded",
          "idempotency-key": null,
          "loyal-merchant": null
        },
        "form": {"grant_type": "client_credentials"}
      },
      "response": {
        "status": 200,
        "headers": {
          "Content-Type": "application/json",
          "X-Request-Id": "01929c20-0001-7000-8000-000000000001",
          "Loyal-Environment": "sandbox",
          "Cache-Control": "no-store",
          "Pragma": "no-cache"
        },
        "json": {
          "access_token": "lat_test_8NfzE9KomDFUk3lfJjBaLz0-9r7ns5Uo2tYUpmVlUcE",
          "token_type": "Bearer",
          "expires_in": 3600,
          "scope": "merchants programs organization members webhooks reports"
        }
      }
    },
    {
      "request": {
        "method": "POST",
        "url": "https://api.example.com/api/management/v1/locations",
        "headers": {
          "authorization": "Bearer lat_test_8NfzE9KomDFUk3lfJjBaLz0-9r7ns5Uo2tYUpmVlUcE",
          "accept": "application/json",
          "content-type": "application/json",
          "idempotency-key": null,
          "loyal-merchant": "01929c1e-0020-7020-8020-000000000020"
        },
        "json": {"code": "msk-01", "name": "Кофейня на Тверской", "address": "Москва, Тверская ул., 1"}
      },
      "response": {
        "status": 201,
        "headers": {
          "Content-Type": "application/json",
          "X-Request-Id": "01929c20-0002-7000-8000-000000000002",
          "Loyal-Environment": "sandbox"
        },
        "json": {
          "id": "01929c1e-0030-7030-8030-000000000030",
          "code": "msk-01",
          "name": "Кофейня на Тверской",
          "address": "Москва, Тверская ул., 1",
          "timezone": "Europe/Moscow",
          "brand_id": null,
          "legal_entity_id": null,
          "status": "active"
        }
      }
    },
    {
      "request": {
        "method": "POST",
        "url": "https://api.example.com/api/management/v1/members/01929c1e-0040-7040-8040-000000000040/point-adjustments",
        "headers": {
          "authorization": "Bearer lat_test_8NfzE9KomDFUk3lfJjBaLz0-9r7ns5Uo2tYUpmVlUcE",
          "accept": "application/json",
          "content-type": "application/json",
          "idempotency-key": "{{idempotency-key}}",
          "loyal-merchant": "01929c1e-0020-7020-8020-000000000020"
        },
        "json": {"amount": 500, "reason_code": "goodwill"}
      },
      "failure": "after_send"
    },
    {
      "request": {
        "method": "POST",
        "url": "https://api.example.com/api/management/v1/members/01929c1e-0040-7040-8040-000000000040/point-adjustments",
        "headers": {
          "authorization": "Bearer lat_test_8NfzE9KomDFUk3lfJjBaLz0-9r7ns5Uo2tYUpmVlUcE",
          "accept": "application/json",
          "content-type": "application/json",
          "idempotency-key": "{{idempotency-key}}",
          "loyal-merchant": "01929c1e-0020-7020-8020-000000000020"
        },
        "json": {"amount": 500, "reason_code": "goodwill"}
      },
      "response": {
        "status": 401,
        "headers": {
          "Content-Type": "application/problem+json",
          "X-Request-Id": "01929c20-0003-7000-8000-000000000003",
          "Loyal-Environment": "sandbox",
          "WWW-Authenticate": "Bearer realm=\"loyal\""
        },
        "json": {
          "type": "urn:loyal:problem:unauthenticated",
          "title": "A valid access token is required.",
          "status": 401,
          "code": "unauthenticated",
          "request_id": "01929c20-0003-7000-8000-000000000003"
        }
      }
    },
    {
      "request": {
        "method": "POST",
        "url": "https://api.example.com/api/management/v1/oauth/token",
        "headers": {
          "authorization": "Basic bGNfdGVzdF80YjlhYzRmNWQ2Y2M2NzgzYTIwNDRhNWE6bGNzX3Rlc3RfX0E3NWhDd0hLV1lBNjFBRDFXS1dPa2p0S3ZVMmhSblNLQ3hfWVZGZlZvcw==",
          "accept": "application/json",
          "content-type": "application/x-www-form-urlencoded",
          "idempotency-key": null,
          "loyal-merchant": null
        },
        "form": {"grant_type": "client_credentials"}
      },
      "failure": "after_send"
    },
    {
      "request": {
        "method": "POST",
        "url": "https://api.example.com/api/management/v1/oauth/token",
        "headers": {
          "authorization": "Basic bGNfdGVzdF80YjlhYzRmNWQ2Y2M2NzgzYTIwNDRhNWE6bGNzX3Rlc3RfX0E3NWhDd0hLV1lBNjFBRDFXS1dPa2p0S3ZVMmhSblNLQ3hfWVZGZlZvcw==",
          "accept": "application/json",
          "content-type": "application/x-www-form-urlencoded",
          "idempotency-key": null,
          "loyal-merchant": null
        },
        "form": {"grant_type": "client_credentials"}
      },
      "failure": "after_send"
    },
    {
      "request": {
        "method": "POST",
        "url": "https://api.example.com/api/management/v1/oauth/token",
        "headers": {
          "authorization": "Basic bGNfdGVzdF80YjlhYzRmNWQ2Y2M2NzgzYTIwNDRhNWE6bGNzX3Rlc3RfX0E3NWhDd0hLV1lBNjFBRDFXS1dPa2p0S3ZVMmhSblNLQ3hfWVZGZlZvcw==",
          "accept": "application/json",
          "content-type": "application/x-www-form-urlencoded",
          "idempotency-key": null,
          "loyal-merchant": null
        },
        "form": {"grant_type": "client_credentials"}
      },
      "failure": "after_send"
    }
  ],
  "sleeps": [500, 1000, 500, 500, 1000]
}
