View Source ExChargebee.Resource (ex_chargebee v0.4.5)
A macro for generating simple chargebee http interfaces.
Chargebee's API structure is generally consistent, but some endpoints are decidedly atypical.
Typically Endpoints support the following Standard Operations:
- create (POST /resource) (mostly deprecated or internal)
- list (GET /resource)
- retrieve (GET /resource/:id)
- update (POST /resource/:id)
- delete (POST /resource/:id/delete)
To disable any of these operations, pass a list of operations to the :stdops
option.
Some endpoints support additional operations. To add these operations, pass a
list of operations to the :get_operations
, :post_operations
,
:list_operations
, or :post_root_operations
options.
Types of operations:
- Get Operations (GET /resource/:id/:operation)
- Post Operations (POST /resource/:id/:operation)
- List Operations (GET /resource/:operation)
- Post Root Operations (POST /resource/:operation)
A better name for "Post Root Operations" would be "Create Operations", but
that would be confusing because of the create
operation.
Example:
defmodule ExChargebee.Subscription do
use ExChargebee.Resource,
post_operations: [
:add_charge_at_term_end,
:cancel_for_items,
:change_term_end,
:charge_future_renewals,
:delete,
:edit_advance_invoice_schedule,
:import_contract_term,
:import_for_items,
:override_billing_profile,
:pause,
:reactivate,
:regenerate_invoice,
:remove_advance_invoice_schedule,
:remove_coupons,
:remove_scheduled_cancellation,
:remove_scheduled_changes,
:remove_scheduled_pause,
:remove_scheduled_resumption,
:resume,
:retrieve_advance_invoice_schedule,
:subscription_for_items,
:update_for_items
],
get_operations: [:contract_terms, :discounts, :retrieve_with_scheduled_changes]
def import_unbilled_charges(params, opts \ []) do
post_resource("import_unbilled_charges", "/import_unbilled_charges", params, opts)
end
end