{
  "version": "3.0",
  "entities": [
    {
      "name": "contact",
      "schemas": {
        "fooshop": {
          "identity": {
            "strategy": "external_id",
            "field": "id"
          },
          "field_mappings": [
            {
              "source": "$.email",
              "target": "$.canonical.email"
            },
            {
              "source": "$.firstName",
              "target": "$.canonical.firstname"
            },
            {
              "source": "$.lastName",
              "target": "$.canonical.lastname"
            },
            {
              "source": "$.shopDomain",
              "target": "$.canonical.company_domain"
            }
          ]
        },
        "hubspot": {
          "object_type": "contacts",
          "identity": {
            "strategy": "by_email",
            "property": "email"
          },
          "field_mappings": [
            {
              "source": "$.canonical.email",
              "target": "email"
            },
            {
              "source": "$.canonical.firstname",
              "target": "firstname"
            },
            {
              "source": "$.canonical.lastname",
              "target": "lastname"
            },
            {
              "source": "$.canonical.company_domain",
              "target": "fooshop_shop_domain"
            }
          ]
        }
      }
    },
    {
      "name": "order",
      "schemas": {
        "fooshop": {
          "identity": {
            "strategy": "external_id",
            "field": "id"
          },
          "field_mappings": [
            {
              "source": "$.id",
              "target": "$.canonical.id"
            },
            {
              "source": "$.totalAmount",
              "target": "$.canonical.amount"
            },
            {
              "source": "$.customerEmail",
              "target": "$.canonical.customer_email"
            },
            {
              "source": "$.status",
              "target": "$.canonical.status"
            }
          ]
        },
        "hubspot": {
          "object_type": "deals",
          "identity": {
            "strategy": "external_id",
            "property": "fooshop_order_id"
          },
          "field_mappings": [
            {
              "source": "$.canonical.id",
              "target": "fooshop_order_id"
            },
            {
              "source": "$.canonical.amount",
              "target": "amount"
            }
          ]
        }
      }
    }
  ],
  "flows": [
    {
      "name": "fooshop_signup",
      "source": "fooshop_events",
      "event_type": "signup",
      "steps": [
        {
          "id": "to_canonical",
          "action": "transform",
          "entity": "contact",
          "from_schema": "fooshop",
          "to_schema": "canonical"
        },
        {
          "id": "upsert_contact",
          "action": "upsert",
          "target": "hubspot",
          "entity": "contact",
          "data": "$.canonical"
        }
      ]
    },
    {
      "name": "fooshop_order_paid",
      "source": "fooshop_events",
      "event_type": "order.paid",
      "steps": [
        {
          "id": "contact_to_canonical",
          "action": "transform",
          "entity": "contact",
          "from_schema": "fooshop",
          "to_schema": "canonical"
        },
        {
          "id": "order_to_canonical",
          "action": "transform",
          "entity": "order",
          "from_schema": "fooshop",
          "to_schema": "canonical"
        },
        {
          "id": "compute_stage",
          "action": "plugin",
          "module": "plugins.fooshop.shop_stage",
          "function": "compute_shop_stage"
        },
        {
          "id": "upsert_contact",
          "action": "upsert",
          "target": "hubspot",
          "entity": "contact",
          "data": "$.canonical"
        },
        {
          "id": "upsert_deal",
          "action": "upsert",
          "target": "hubspot",
          "entity": "order",
          "data": "$.canonical",
          "associations": [
            {
              "to_step": "upsert_contact",
              "type": "contact_to_deal"
            }
          ]
        }
      ]
    }
  ],
  "settings": {}
}
