{
  "apiVersion": 63,
  "status": "Active",
  "label": "HubSpot Contact Contact Patch",
  "description": "Creates or PATCHes the linked HubSpot contact after a NexusCRM Contact save when outbound HubSpot sync is enabled.",
  "start": {
    "locationX": 40,
    "locationY": 0,
    "object": "Contact",
    "triggerType": "RecordAfterSave",
    "recordTriggerType": "CreateAndUpdate",
    "filterLogic": "1",
    "filters": [
      {
        "field": "HubSpot_Sync_Enabled__c",
        "operator": "EqualTo",
        "value": true
      }
    ],
    "connector": {
      "targetReference": "RouteContactOutboundPatch"
    }
  },
  "decisions": [
    {
      "name": "RouteContactOutboundPatch",
      "label": "Route Contact outbound patch",
      "locationX": 40,
      "locationY": 80,
      "defaultConnector": {
        "targetReference": "PatchHubSpotContact"
      },
      "defaultConnectorLabel": "Default Contact patch",
      "rules": [
        {
          "name": "ContactTitleChanged",
          "conditionLogic": "and",
          "conditions": [
            {
              "leftValueReference": "$Record__Prior.Id",
              "operator": "IsNotBlank"
            },
            {
              "leftValueReference": "$Record.HubSpot_Id__c",
              "operator": "IsNotBlank"
            },
            {
              "leftValueReference": "$Record.Title",
              "operator": "NotEqualTo",
              "rightValue": {
                "elementReference": "$Record__Prior.Title"
              }
            }
          ],
          "connector": {
            "targetReference": "PatchHubSpotContact"
          },
          "label": "Contact Title changed"
        }
      ]
    }
  ],
  "actionCalls": [
    {
      "name": "PatchHubSpotContact",
      "label": "Patch HubSpot contact",
      "locationX": 40,
      "locationY": 180,
      "actionName": "PushToConnector",
      "actionType": "PushToConnector",
      "inputParameters": [
        {
          "name": "profileName",
          "value": {
            "stringValue": "hubspot-crm-contact-write"
          }
        },
        {
          "name": "profileOwnerPack",
          "value": {
            "stringValue": "hubspot-crm-connector"
          }
        },
        {
          "name": "sourceObject",
          "value": {
            "stringValue": "Contact"
          }
        },
        {
          "name": "targetObject",
          "value": {
            "stringValue": "contacts"
          }
        },
        {
          "name": "actionType",
          "value": {
            "stringValue": "PushToConnector"
          }
        },
        {
          "name": "bodyRoot",
          "value": {
            "stringValue": "properties"
          }
        },
        {
          "name": "destinationSlotId",
          "value": {
            "stringValue": "hubspot-contact"
          }
        },
        {
          "name": "remoteId",
          "value": {
            "elementReference": "$Record.HubSpot_Id__c"
          }
        },
        {
          "name": "updatePathTemplate",
          "value": {
            "stringValue": "/crm/v3/objects/contacts/{remoteId}"
          }
        },
        {
          "name": "sourceRecord",
          "value": {
            "elementReference": "$Record"
          }
        }
      ]
    }
  ]
}
