{
  "name": "Клиент участника с сеансом: профиль, история, код для кассы, сайт сеанса и закрытие",
  "description": "Каждый запрос несёт сеанс в Authorization и сайт сеанса в Origin. Запрос не с сайта сеанса — 403 origin_mismatch (класс permission_denied). endSession закрывает сеанс (204); после него у клиента нет сеанса: повторное закрытие ничего не отправляет, а вызов без сеанса и без поставщика — configuration до отправки.",
  "client": {
    "api": "member",
    "credential": {"memberSession": "lms_test_d0f3364baf26.4OuDuCo1m7vWf_OongPoB6orwvXEHwM1vFYHST6ieao"},
    "origin": "https://shop.example.com",
    "baseUrl": "https://api.example.com/"
  },
  "calls": [
    {
      "operation": "getProfile",
      "args": {},
      "expect": {
        "result": {
          "id": "01929c1e-0030-7030-8030-000000000030",
          "status": "active",
          "masked_phone": "+7 *** ***-45-67",
          "first_name": "Анна",
          "registered_at": "2026-09-01T10:00:00Z",
          "referral_code": "ANNA7Q2",
          "balance": {
            "point_type_id": "01929c1e-0031-7031-8031-000000000031",
            "precision": 0,
            "available": 1250,
            "pending": 0,
            "held": 0,
            "spendable": 1250,
            "next_expiration": {"amount": 300, "at": "2026-12-31T21:00:00Z"}
          },
          "tier": {
            "code": "silver",
            "title": "Серебряный",
            "accrual_percent_bp": 500,
            "retained_until": "2027-09-01T00:00:00Z",
            "window_start": "2025-10-13",
            "amount": 1500000,
            "purchases": 12,
            "next": {"code": "gold", "title": "Золотой", "amount_left": 1500000, "purchases_left": 0}
          },
          "stamps": [{"card": "coffee", "title": "Кофейная карта", "goal": 6, "stamps": 4}]
        },
        "meta": {
          "operationId": "getProfile",
          "method": "GET",
          "path": "/api/member/v1/me",
          "status": 200,
          "requestId": "01929c20-0101-7000-8000-000000000101",
          "environment": "sandbox"
        }
      }
    },
    {
      "operation": "getPointsHistoryAll",
      "args": {"limit": 2},
      "expect": {
        "result": [
          {
            "transaction_id": "01929c1e-0040-7040-8040-000000000043",
            "type": "accrual",
            "amount": 50,
            "member_delta": 50,
            "effective_at": "2026-10-12T15:30:00Z",
            "created_at": "2026-10-12T15:30:00Z",
            "reference_type": "receipt",
            "reference_id": "01929c1e-0050-7050-8050-000000000053",
            "reason_code": null
          },
          {
            "transaction_id": "01929c1e-0040-7040-8040-000000000042",
            "type": "redemption",
            "amount": 200,
            "member_delta": -200,
            "effective_at": "2026-10-05T11:00:00Z",
            "created_at": "2026-10-05T11:00:00Z",
            "reference_type": "receipt",
            "reference_id": "01929c1e-0050-7050-8050-000000000052",
            "reason_code": null
          },
          {
            "transaction_id": "01929c1e-0040-7040-8040-000000000041",
            "type": "adjustment",
            "amount": 1400,
            "member_delta": 1400,
            "effective_at": "2026-09-01T10:00:00Z",
            "created_at": "2026-09-01T10:00:00Z",
            "reference_type": null,
            "reference_id": null,
            "reason_code": "goodwill"
          }
        ]
      }
    },
    {
      "operation": "issuePresentationCode",
      "args": {},
      "expect": {
        "result": {"code": "48151623", "expires_at": "2026-10-13T12:02:00Z", "qr_svg": "data:image/svg+xml;base64,PHN2Zy8+"}
      }
    },
    {
      "operation": "getProfile",
      "args": {},
      "expect": {
        "error": {
          "class": "permission_denied",
          "status": 403,
          "code": "origin_mismatch",
          "requestId": "01929c20-0105-7000-8000-000000000105",
          "idempotencyKey": null
        }
      }
    },
    {"operation": "endSession", "args": {}, "expect": {"result": null, "meta": {"operationId": "endSession", "method": "DELETE", "path": "/api/member/v1/session", "status": 204}}},
    {"operation": "endSession", "args": {}, "expect": {"result": null}},
    {"operation": "getProfile", "args": {}, "expect": {"error": {"class": "configuration"}}}
  ],
  "exchanges": [
    {
      "request": {
        "method": "GET",
        "url": "https://api.example.com/api/member/v1/me",
        "headers": {
          "authorization": "Bearer lms_test_d0f3364baf26.4OuDuCo1m7vWf_OongPoB6orwvXEHwM1vFYHST6ieao",
          "accept": "application/json",
          "content-type": null,
          "idempotency-key": null,
          "loyal-merchant": null,
          "origin": "https://shop.example.com"
        }
      },
      "response": {
        "status": 200,
        "headers": {"Content-Type": "application/json", "X-Request-Id": "01929c20-0101-7000-8000-000000000101", "Loyal-Environment": "sandbox"},
        "json": {
          "id": "01929c1e-0030-7030-8030-000000000030",
          "status": "active",
          "masked_phone": "+7 *** ***-45-67",
          "first_name": "Анна",
          "registered_at": "2026-09-01T10:00:00Z",
          "referral_code": "ANNA7Q2",
          "balance": {
            "point_type_id": "01929c1e-0031-7031-8031-000000000031",
            "precision": 0,
            "available": 1250,
            "pending": 0,
            "held": 0,
            "spendable": 1250,
            "next_expiration": {"amount": 300, "at": "2026-12-31T21:00:00Z"}
          },
          "tier": {
            "code": "silver",
            "title": "Серебряный",
            "accrual_percent_bp": 500,
            "retained_until": "2027-09-01T00:00:00Z",
            "window_start": "2025-10-13",
            "amount": 1500000,
            "purchases": 12,
            "next": {"code": "gold", "title": "Золотой", "amount_left": 1500000, "purchases_left": 0}
          },
          "stamps": [{"card": "coffee", "title": "Кофейная карта", "goal": 6, "stamps": 4}]
        }
      }
    },
    {
      "request": {
        "method": "GET",
        "url": "https://api.example.com/api/member/v1/me/history?limit=2",
        "headers": {
          "authorization": "Bearer lms_test_d0f3364baf26.4OuDuCo1m7vWf_OongPoB6orwvXEHwM1vFYHST6ieao",
          "accept": "application/json",
          "content-type": null,
          "idempotency-key": null,
          "loyal-merchant": null,
          "origin": "https://shop.example.com"
        }
      },
      "response": {
        "status": 200,
        "headers": {"Content-Type": "application/json", "X-Request-Id": "01929c20-0102-7000-8000-000000000102", "Loyal-Environment": "sandbox"},
        "json": {
          "data": [
            {
              "transaction_id": "01929c1e-0040-7040-8040-000000000043",
              "type": "accrual",
              "amount": 50,
              "member_delta": 50,
              "effective_at": "2026-10-12T15:30:00Z",
              "created_at": "2026-10-12T15:30:00Z",
              "reference_type": "receipt",
              "reference_id": "01929c1e-0050-7050-8050-000000000053",
              "reason_code": null
            },
            {
              "transaction_id": "01929c1e-0040-7040-8040-000000000042",
              "type": "redemption",
              "amount": 200,
              "member_delta": -200,
              "effective_at": "2026-10-05T11:00:00Z",
              "created_at": "2026-10-05T11:00:00Z",
              "reference_type": "receipt",
              "reference_id": "01929c1e-0050-7050-8050-000000000052",
              "reason_code": null
            }
          ],
          "next_cursor": "eyJ0IjoiMjAyNi0xMC0wNSJ9"
        }
      }
    },
    {
      "request": {
        "method": "GET",
        "url": "https://api.example.com/api/member/v1/me/history?limit=2&cursor=eyJ0IjoiMjAyNi0xMC0wNSJ9",
        "headers": {
          "authorization": "Bearer lms_test_d0f3364baf26.4OuDuCo1m7vWf_OongPoB6orwvXEHwM1vFYHST6ieao",
          "accept": "application/json",
          "content-type": null,
          "idempotency-key": null,
          "loyal-merchant": null,
          "origin": "https://shop.example.com"
        }
      },
      "response": {
        "status": 200,
        "headers": {"Content-Type": "application/json", "X-Request-Id": "01929c20-0103-7000-8000-000000000103", "Loyal-Environment": "sandbox"},
        "json": {
          "data": [
            {
              "transaction_id": "01929c1e-0040-7040-8040-000000000041",
              "type": "adjustment",
              "amount": 1400,
              "member_delta": 1400,
              "effective_at": "2026-09-01T10:00:00Z",
              "created_at": "2026-09-01T10:00:00Z",
              "reference_type": null,
              "reference_id": null,
              "reason_code": "goodwill"
            }
          ],
          "next_cursor": null
        }
      }
    },
    {
      "request": {
        "method": "POST",
        "url": "https://api.example.com/api/member/v1/me/presentation-codes",
        "headers": {
          "authorization": "Bearer lms_test_d0f3364baf26.4OuDuCo1m7vWf_OongPoB6orwvXEHwM1vFYHST6ieao",
          "accept": "application/json",
          "content-type": null,
          "idempotency-key": null,
          "loyal-merchant": null,
          "origin": "https://shop.example.com"
        }
      },
      "response": {
        "status": 201,
        "headers": {"Content-Type": "application/json", "X-Request-Id": "01929c20-0104-7000-8000-000000000104", "Loyal-Environment": "sandbox"},
        "json": {"code": "48151623", "expires_at": "2026-10-13T12:02:00Z", "qr_svg": "data:image/svg+xml;base64,PHN2Zy8+"}
      }
    },
    {
      "request": {
        "method": "GET",
        "url": "https://api.example.com/api/member/v1/me",
        "headers": {
          "authorization": "Bearer lms_test_d0f3364baf26.4OuDuCo1m7vWf_OongPoB6orwvXEHwM1vFYHST6ieao",
          "accept": "application/json",
          "content-type": null,
          "idempotency-key": null,
          "loyal-merchant": null,
          "origin": "https://shop.example.com"
        }
      },
      "response": {
        "status": 403,
        "headers": {"Content-Type": "application/problem+json", "X-Request-Id": "01929c20-0105-7000-8000-000000000105", "Loyal-Environment": "sandbox"},
        "json": {
          "type": "urn:loyal:problem:origin_mismatch",
          "title": "The member session works on its own site only.",
          "status": 403,
          "code": "origin_mismatch",
          "request_id": "01929c20-0105-7000-8000-000000000105"
        }
      }
    },
    {
      "request": {
        "method": "DELETE",
        "url": "https://api.example.com/api/member/v1/session",
        "headers": {
          "authorization": "Bearer lms_test_d0f3364baf26.4OuDuCo1m7vWf_OongPoB6orwvXEHwM1vFYHST6ieao",
          "accept": "application/json",
          "content-type": null,
          "idempotency-key": null,
          "loyal-merchant": null,
          "origin": "https://shop.example.com"
        }
      },
      "response": {
        "status": 204,
        "headers": {"X-Request-Id": "01929c20-0106-7000-8000-000000000106", "Loyal-Environment": "sandbox"}
      }
    }
  ],
  "sleeps": []
}
