recurly v0.2.1 Recurly.Webhooks
Module responsible for parsing webhooks: https://dev.recurly.com/page/webhooks
Each webhook has it’s own type. These types are returned from Recurly.Webhooks.parse/1
respectively.
- BillingInfoUpdatedNotification
- CanceledAccountNotification
- CanceledSubscriptionNotification
- ClosedInvoiceNotification
- ExpiredSubscriptionNotification
- FailedPaymentNotification
- NewAccountNotification
- NewInvoiceNotification
- NewSubscriptionNotification
- PastDueInvoiceNotification
- ProcessingInvoiceNotification
- ProcessingPaymentNotification
- ReactivatedAccountNotification
- RenewedSubscriptionNotification
- ScheduledPaymentNotification
- SuccessfulPaymentNotification
- SuccessfulRefundNotification
- UpdatedSubscriptionNotification
- VoidPaymentNotification
Summary
Functions
Gives you the name of the notification from the xml
Parses an xml document containing a webhook
Functions
Gives you the name of the notification from the xml
Parameters
xml_doc
String webhook xml
Examples
xml_doc = """
<?xml version="1.0" encoding="UTF-8"?>
<canceled_account_notification>
<account>
<account_code>1</account_code>
<username nil="true"></username>
<email>verena@example.com</email>
<first_name>Verena</first_name>
<last_name>Example</last_name>
<company_name nil="true"></company_name>
</account>
</canceled_account_notification>
"""
"canceled_account_notification" = Recurly.Webhooks.parse(xml_doc)
Parses an xml document containing a webhook
Parameters
xml_doc
String webhook xml
Examples
xml_doc = """
<?xml version="1.0" encoding="UTF-8"?>
<canceled_account_notification>
<account>
<account_code>1</account_code>
<username nil="true"></username>
<email>verena@example.com</email>
<first_name>Verena</first_name>
<last_name>Example</last_name>
<company_name nil="true"></company_name>
</account>
</canceled_account_notification>
"""
alias Recurly.Webhooks
notification = Webhooks.parse(xml_doc)
# It may be helpful to pattern match against the possible types
case Webhooks.parse(xml_doc) do
%Webhooks.CanceledAccountNotification{} n -> IO.inspect(n.account)
%Webhooks.CanceledSubscriptionNotification{} n -> IO.inspect(n.subscription)
# ... etc
_ -> IO.puts("not handled")
end