{
  "arazzo": "1.0.1",
  "info": {
    "title": "Book the first mentoring session with Marian",
    "summary": "Price a package, find free times, book the first paid session.",
    "description": "For a person who already had the free intro call and has agreed the price. Without an earlier intro the final step answers 409 intro_required; run the same steps with event `intro` first (skip the price step) to book the free intro.",
    "version": "1.4.0"
  },
  "sourceDescriptions": [
    {
      "name": "mentoring",
      "url": "https://api.marian.coach/v1/mentoring/openapi.json",
      "type": "openapi"
    }
  ],
  "workflows": [
    {
      "workflowId": "price_slots_book_first_session",
      "summary": "Price N sessions, list free times, book the first session.",
      "inputs": {
        "type": "object",
        "required": [
          "sessions",
          "name",
          "email",
          "timezone"
        ],
        "properties": {
          "sessions": {
            "type": "integer",
            "minimum": 1,
            "maximum": 48,
            "default": 6,
            "description": "Sessions in the package including the first."
          },
          "name": {
            "type": "string"
          },
          "email": {
            "type": "string",
            "format": "email"
          },
          "timezone": {
            "type": "string",
            "description": "IANA zone, e.g. Europe/London."
          },
          "goals": {
            "type": "string"
          },
          "idempotency_key": {
            "type": "string",
            "description": "Unique per booking attempt."
          }
        }
      },
      "steps": [
        {
          "stepId": "price",
          "description": "Tell the person what the package costs before anything is booked.",
          "operationId": "$sourceDescriptions.mentoring.get_mentoring_price",
          "parameters": [
            {
              "name": "sessions",
              "in": "query",
              "value": "$inputs.sessions"
            }
          ],
          "successCriteria": [
            {
              "condition": "$statusCode == 200"
            }
          ],
          "outputs": {
            "total": "$response.body#/total/amount",
            "currency": "$response.body#/total/currency"
          }
        },
        {
          "stepId": "slots",
          "description": "Free times for the first session in the person's time zone; the person picks one.",
          "operationId": "$sourceDescriptions.mentoring.list_free_slots",
          "parameters": [
            {
              "name": "event",
              "in": "path",
              "value": "first-session"
            },
            {
              "name": "timezone",
              "in": "query",
              "value": "$inputs.timezone"
            }
          ],
          "successCriteria": [
            {
              "condition": "$statusCode == 200"
            },
            {
              "context": "$response.body",
              "condition": "$[?count(@.slots) > 0]",
              "type": "jsonpath"
            }
          ],
          "outputs": {
            "start": "$response.body#/slots/0"
          }
        },
        {
          "stepId": "book",
          "description": "Book the chosen time. Only after the person agreed to price and time.",
          "operationId": "$sourceDescriptions.mentoring.book_event",
          "parameters": [
            {
              "name": "event",
              "in": "path",
              "value": "first-session"
            },
            {
              "name": "Idempotency-Key",
              "in": "header",
              "value": "$inputs.idempotency_key"
            }
          ],
          "requestBody": {
            "contentType": "application/json",
            "payload": {
              "name": "$inputs.name",
              "email": "$inputs.email",
              "start": "$steps.slots.outputs.start",
              "timezone": "$inputs.timezone",
              "goals": "$inputs.goals",
              "sessions": "$inputs.sessions"
            }
          },
          "successCriteria": [
            {
              "condition": "$statusCode == 200"
            }
          ],
          "outputs": {
            "uid": "$response.body#/uid",
            "start": "$response.body#/start",
            "meeting_url": "$response.body#/meeting_url"
          }
        }
      ],
      "outputs": {
        "total": "$steps.price.outputs.total",
        "uid": "$steps.book.outputs.uid",
        "start": "$steps.book.outputs.start"
      }
    }
  ]
}