{
  "name": "Запрос токена повторяется по maxRetries клиента, а не вызова",
  "description": "Клиент с maxRetries = 1. Первый вызов с options.maxRetries = 3: запрос токена получает 503, повторяется через 500 мс (единственный повтор клиента) и снова получает 503 — ошибка server, запроса операции нет: повторы вызова на запрос токена не действуют. Неудача не кэшируется. Второй вызов с options.maxRetries = 0: запрос токена получает 503 и всё равно повторяется через 500 мс по настройкам клиента, получает токен, и операция выполняется.",
  "client": {
    "api": "management",
    "credential": {
      "clientCredentials": {
        "clientId": "lc_test_4b9ac4f5d6cc6783a2044a5a",
        "clientSecret": "lcs_test__A75hCwHKWYA61AD1WKWOkjtKvU2hRnSKCx_YVFfVos"
      }
    },
    "baseUrl": "https://api.example.com",
    "maxRetries": 1,
    "merchant": "01929c1e-0020-7020-8020-000000000020"
  },
  "calls": [
    {
      "operation": "getLocation",
      "args": {"location": "01929c1e-0030-7030-8030-000000000030"},
      "options": {"maxRetries": 3},
      "expect": {
        "error": {
          "class": "server",
          "status": 503,
          "code": "http_503",
          "requestId": "01929c20-0002-7000-8000-000000000002",
          "idempotencyKey": null
        },
        "meta": {"operationId": "issueToken", "status": 503, "requestId": "01929c20-0002-7000-8000-000000000002"}
      }
    },
    {
      "operation": "getLocation",
      "args": {"location": "01929c1e-0030-7030-8030-000000000030"},
      "options": {"maxRetries": 0},
      "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"
        },
        "meta": {"operationId": "getLocation", "status": 200, "requestId": "01929c20-0005-7000-8000-000000000005"}
      }
    }
  ],
  "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"}
      },
      "response": {
        "status": 503,
        "headers": {
          "Content-Type": "application/problem+json",
          "X-Request-Id": "01929c20-0001-7000-8000-000000000001",
          "Loyal-Environment": "sandbox"
        },
        "json": {
          "type": "urn:loyal:problem:http_503",
          "title": "Service Unavailable",
          "status": 503,
          "code": "http_503",
          "request_id": "01929c20-0001-7000-8000-000000000001"
        }
      }
    },
    {
      "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": "application/problem+json",
          "X-Request-Id": "01929c20-0002-7000-8000-000000000002",
          "Loyal-Environment": "sandbox"
        },
        "json": {
          "type": "urn:loyal:problem:http_503",
          "title": "Service Unavailable",
          "status": 503,
          "code": "http_503",
          "request_id": "01929c20-0002-7000-8000-000000000002"
        }
      }
    },
    {
      "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": "application/problem+json",
          "X-Request-Id": "01929c20-0003-7000-8000-000000000003",
          "Loyal-Environment": "sandbox"
        },
        "json": {
          "type": "urn:loyal:problem:http_503",
          "title": "Service Unavailable",
          "status": 503,
          "code": "http_503",
          "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"}
      },
      "response": {
        "status": 200,
        "headers": {
          "Content-Type": "application/json",
          "X-Request-Id": "01929c20-0004-7000-8000-000000000004",
          "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": "GET",
        "url": "https://api.example.com/api/management/v1/locations/01929c1e-0030-7030-8030-000000000030",
        "headers": {
          "authorization": "Bearer lat_test_8NfzE9KomDFUk3lfJjBaLz0-9r7ns5Uo2tYUpmVlUcE",
          "accept": "application/json",
          "content-type": null,
          "idempotency-key": null,
          "loyal-merchant": "01929c1e-0020-7020-8020-000000000020"
        }
      },
      "response": {
        "status": 200,
        "headers": {
          "Content-Type": "application/json",
          "X-Request-Id": "01929c20-0005-7000-8000-000000000005",
          "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"
        }
      }
    }
  ],
  "sleeps": [500, 500]
}
