// Notify new subscription
###
POST http://localhost:3000/dev/notification/subscription/new  HTTP/1.1x
content-type: application/json
Authorization: Bearer f890f065cec35612e60ac02359ede24ffksflak339393933lll

{
    "event": {
        "session_variables": {
            "x-hasura-role": "admin"
        },
        "op": "INSERT",
        "data": {
            "old": {},
            "new": {
                "cancellation_by_type": null,
                "payment_provider": "n2b",
                "trial_expires_at": null,
                "original_transaction": null,
                "cancellation_request_at": "2021-12-08T19:01:10.546+00:00",
                "token": null,
                "subscribed_at": "2021-11-24T20:23:23+00:00",
                "cancellation_by_id": "7b7c0f11-065c-49a7-b564-0760c7f7e52f",
                "patient_id": "7b7c0f11-065c-49a7-b564-0760c7f7e52f",
                "teleconsultation_renews_at": "2022-11-24T20:23:23+00:00",
                "updated_at": "2021-12-08T19:01:10.557832+00:00",
                "cancellation_other_reason": null,
                "expires_at": "2021-12-08T19:01:10.546+00:00",
                "created_at": "2021-11-24T20:23:24.86+00:00",
                "cancellation_at": "2021-12-08T19:01:10.546+00:00",
                "id": "d6720849-fb0f-4aa0-b5f4-771cac18ff35",
                "cancellation_reason_id": "I7KiqHjHMVBc24M6idDQ",
                "plan_id": "32eabbe1-1b2c-4d9d-a169-f76012312764"
            }
        },
        "trace_context": {
            "trace_id": "4023fb1fc4992aef",
            "span_id": "55ad5e7386e6ce8b"
        }
    },
    "created_at": "2021-12-08T19:01:10.557832Z",
    "id": "2a40e6d1-1672-4c34-8142-c6302efbfe5a",
    "delivery_info": {
        "max_retries": 3,
        "current_retry": 0
    },
    "trigger": {
        "name": "notify_new_subscription"
    },
    "table": {
        "schema": "public",
        "name": "subscription"
    }
}


// Notify cancelled subscription
###
POST http://localhost:3000/dev/notification/subscription/cancelled  HTTP/1.1x
content-type: application/json
Authorization: Bearer f890f065cec35612e60ac02359ede24ffksflak339393933lll

{
    "event": {
        "session_variables": {
            "x-hasura-role": "admin"
        },
        "op": "UPDATE",
        "data": {
            "old": {
                "cancellation_by_type": null,
                "payment_provider": "smartfit",
                "trial_expires_at": null,
                "original_transaction": null,
                "cancellation_request_at": null,
                "token": null,
                "subscribed_at": "2021-11-24T20:23:23+00:00",
                "cancellation_by_id": null,
                "patient_id": "jDdSs7Mhq5geJDP9yUFFkNlc5bd2",
                "teleconsultation_renews_at": "2022-11-24T20:23:23+00:00",
                "updated_at": "2021-12-04T17:42:36.221791+00:00",
                "cancellation_other_reason": null,
                "expires_at": null,
                "created_at": "2021-11-24T20:23:24.86+00:00",
                "cancellation_at": null,
                "id": "5531cbac-81a2-4315-a89f-5d74243e3cda",
                "cancellation_reason_id": null,
                "plan_id": "008ebe66-0799-4756-aaa0-d1a6c625701a"
            },
            "new": {
                "cancellation_by_type": null,
                "payment_provider": "smartfit",
                "trial_expires_at": null,
                "original_transaction": null,
                "cancellation_request_at": "2021-12-08T19:01:10.546+00:00",
                "token": null,
                "subscribed_at": "2021-11-24T20:23:23+00:00",
                "cancellation_by_id": "jDdSs7Mhq5geJDP9yUFFkNlc5bd2",
                "patient_id": "jDdSs7Mhq5geJDP9yUFFkNlc5bd2",
                "teleconsultation_renews_at": "2022-11-24T20:23:23+00:00",
                "updated_at": "2021-12-08T19:01:10.557832+00:00",
                "cancellation_other_reason": null,
                "expires_at": "2021-12-08T19:01:10.546+00:00",
                "created_at": "2021-11-24T20:23:24.86+00:00",
                "cancellation_at": "2021-12-08T19:01:10.546+00:00",
                "id": "5531cbac-81a2-4315-a89f-5d74243e3cda",
                "cancellation_reason_id": "I7KiqHjHMVBc24M6idDQ",
                "plan_id": "008ebe66-0799-4756-aaa0-d1a6c625701a"
            }
        },
        "trace_context": {
            "trace_id": "4023fb1fc4992aef",
            "span_id": "55ad5e7386e6ce8b"
        }
    },
    "created_at": "2021-12-08T19:01:10.557832Z",
    "id": "2a40e6d1-1672-4c34-8142-c6302efbfe5a",
    "delivery_info": {
        "max_retries": 3,
        "current_retry": 0
    },
    "trigger": {
        "name": "notify_cancelled_subscription"
    },
    "table": {
        "schema": "public",
        "name": "subscription"
    }
}

// Notify subscription's transaction failed
###
POST http://localhost:3000/stag/notification/subscription/transaction/new  HTTP/1.1x
content-type: application/json
Authorization: Bearer f890f065cec35612e60ac02359ede2fkfakeieofk3938so2sksj

{
    "event": {
        "session_variables": {
            "x-hasura-role": "admin"
        },
        "op": "UPDATE",
        "data": {
            "old": {},
            "new": {
                "payment_provider": "n2b",
                "status": "failed",
                "amount": 19.95,
                "error_code": "9",
                "discount": 0,
                "data": null,
                "installments": 1,
                "payment_id": 579,
                "card_number": "1111",
                "card_type": "credit",
                "fee": 0,
                "due_at": "2022-06-09T04:20:00.152+00:00",
                "patient_id": "KA9FFMLtBjMFGoNMwOw3D4cDiMg1",
                "subscription_id": "b6a4a741-351b-48f3-8d38-ffba78af00f5",
                "error_message": "Error Interno 1017 - Tipo o longitud inválido(a) - psp_PaymentMethodId",
                "updated_at": "2022-06-14T04:47:19.025865+00:00",
                "installment_number": 6,
                "created_at": "2022-06-14T04:47:19.025865+00:00",
                "id": "7c9ef48c-ea62-4161-95c5-5afeb89c4da3",
                "paid_at": null
            }
        },
        "trace_context": {
            "trace_id": "4023fb1fc4992aef",
            "span_id": "55ad5e7386e6ce8b"
        }
    },
    "trigger": {
      "name": "notify_failed_subscription_transaction"
    }, 
    "id": "05110c1d-6c1b-4d95-97b8-0c938650d556", 
    "table": {
      "name": "subscription_transaction", 
      "schema": "public"
    }, 
    "created_at": "2022-06-08T23:57:57.442437Z"
}