{
  "name": "Update confirmed HubSpot phone",
  "description": "Apply the signed-in customer’s server-confirmed phone change and verify the saved value.",
  "entry": "gate",
  "blocks": [
    {
      "key": "gate",
      "name": "Check confirmation",
      "steps": [
        {
          "kind": "set",
          "content": {
            "assignments": [
              {
                "type": "value",
                "variableID": "333333333333333333333333",
                "value": "not_run"
              },
              {
                "type": "value",
                "variableID": "444444444444444444444444",
                "value": ""
              },
              {
                "type": "value",
                "variableID": "555555555555555555555555",
                "value": ""
              }
            ]
          }
        },
        {
          "kind": "condition",
          "content": {
            "items": [
              {
                "label": "Confirmed permitted change",
                "matchAll": true,
                "assertions": [
                  {
                    "lhs": {
                      "variableID": "111111111111111111111111"
                    },
                    "operation": "is_not_empty",
                    "rhs": ""
                  },
                  {
                    "lhs": {
                      "variableID": "222222222222222222222222"
                    },
                    "operation": "is_not_empty",
                    "rhs": ""
                  }
                ],
                "to": "write"
              }
            ],
            "elsePath": true
          }
        }
      ]
    },
    {
      "key": "write",
      "name": "Apply confirmed phone",
      "steps": [
        {
          "kind": "api",
          "content": {
            "apiToolID": "666666666666666666666666",
            "inputs": [
              {
                "apiToolInputVariableID": "777777777777777777777777",
                "required": false,
                "defaultValue": "{hubspot_api_token}"
              },
              {
                "apiToolInputVariableID": "888888888888888888888888",
                "required": false,
                "defaultValue": "{hubspot_contact_id}"
              },
              {
                "apiToolInputVariableID": "999999999999999999999999",
                "required": false,
                "defaultValue": "{hubspot_confirmed_phone}"
              }
            ],
            "failPath": true
          },
          "links": {
            "next": "readback",
            "fail": "unverified"
          }
        }
      ]
    },
    {
      "key": "readback",
      "name": "Read saved contact",
      "steps": [
        {
          "kind": "api",
          "content": {
            "apiToolID": "aaaaaaaaaaaaaaaaaaaaaaaa",
            "inputs": [
              {
                "apiToolInputVariableID": "bbbbbbbbbbbbbbbbbbbbbbbb",
                "required": false,
                "defaultValue": "{hubspot_api_token}"
              },
              {
                "apiToolInputVariableID": "cccccccccccccccccccccccc",
                "required": false,
                "defaultValue": "{hubspot_contact_id}"
              }
            ],
            "captureResponse": [
              {
                "path": "id",
                "variableOrEntityID": "444444444444444444444444"
              },
              {
                "path": "properties.phone",
                "variableOrEntityID": "555555555555555555555555"
              }
            ],
            "failPath": true
          },
          "links": {
            "next": "verify",
            "fail": "unverified"
          }
        }
      ]
    },
    {
      "key": "verify",
      "name": "Compare readback",
      "steps": [
        {
          "kind": "condition",
          "content": {
            "items": [
              {
                "label": "Same contact and phone",
                "matchAll": true,
                "assertions": [
                  {
                    "lhs": {
                      "variableID": "444444444444444444444444"
                    },
                    "operation": "is",
                    "rhs": "{hubspot_contact_id}"
                  },
                  {
                    "lhs": {
                      "variableID": "555555555555555555555555"
                    },
                    "operation": "is",
                    "rhs": "{hubspot_confirmed_phone}"
                  }
                ],
                "to": "updated"
              }
            ],
            "elsePath": true
          },
          "links": {
            "else": "unverified"
          }
        }
      ]
    },
    {
      "key": "updated",
      "name": "Verified update",
      "steps": [
        {
          "kind": "set",
          "content": {
            "assignments": [
              {
                "type": "value",
                "variableID": "333333333333333333333333",
                "value": "updated"
              }
            ]
          }
        }
      ]
    },
    {
      "key": "unverified",
      "name": "No verified outcome",
      "steps": [
        {
          "kind": "set",
          "content": {
            "assignments": [
              {
                "type": "value",
                "variableID": "333333333333333333333333",
                "value": "unverified"
              }
            ]
          }
        }
      ]
    }
  ]
}
