Current section
Files
Jump to
Current section
Files
lib/docusign/api/payments.ex
# NOTE: This file is auto generated by OpenAPI Generator
# https://openapi-generator.tech
# Do not edit this file manually.
defmodule DocuSign.Api.Payments do
@moduledoc """
API calls for all endpoints tagged `Payments`.
"""
import DocuSign.RequestBuilder
alias DocuSign.Connection
alias DocuSign.Model.BillingPaymentItem
alias DocuSign.Model.BillingPaymentResponse
alias DocuSign.Model.BillingPaymentsResponse
alias DocuSign.Model.ErrorDetails
@doc """
Gets billing payment information for a specific payment.
Retrieves the information for a specified payment. Privileges required: account administrator
### Parameters
- `connection` (DocuSign.Connection): Connection to server
- `account_id` (String.t): The external account number (int) or account ID GUID.
- `payment_id` (String.t): The ID of the payment.
- `opts` (keyword): Optional parameters
### Returns
- `{:ok, DocuSign.Model.BillingPaymentItem.t}` on success
- `{:error, Req.Response.t}` on failure
"""
@spec billing_payments_get_payment(DocuSign.Connection.t(), String.t(), String.t(), keyword()) ::
{:ok, BillingPaymentItem.t()}
| {:error, Req.Response.t()}
def billing_payments_get_payment(connection, account_id, payment_id, _opts \\ []) do
request =
%{}
|> method(:get)
|> url("/v2.1/accounts/#{account_id}/billing_payments/#{payment_id}")
|> Enum.to_list()
connection
|> Connection.request(request)
|> evaluate_response([
{200, BillingPaymentItem},
{400, ErrorDetails}
])
end
@doc """
Gets payment information for one or more payments.
Retrieves a list containing information about one or more payments. If the from date or to date queries are not used, the response returns payment information for the last 365 days. Privileges required: account administrator
### Parameters
- `connection` (DocuSign.Connection): Connection to server
- `account_id` (String.t): The external account number (int) or account ID GUID.
- `opts` (keyword): Optional parameters
- `:from_date` (String.t): Specifies the date/time of the earliest payment in the account to retrieve.
- `:to_date` (String.t): Specifies the date/time of the latest payment in the account to retrieve.
### Returns
- `{:ok, DocuSign.Model.BillingPaymentsResponse.t}` on success
- `{:error, Req.Response.t}` on failure
"""
@spec billing_payments_get_payment_list(DocuSign.Connection.t(), String.t(), keyword()) ::
{:ok, BillingPaymentsResponse.t()}
| {:error, Req.Response.t()}
def billing_payments_get_payment_list(connection, account_id, opts \\ []) do
optional_params = %{
:from_date => :query,
:to_date => :query
}
request =
%{}
|> method(:get)
|> url("/v2.1/accounts/#{account_id}/billing_payments")
|> add_optional_params(optional_params, opts)
|> Enum.to_list()
connection
|> Connection.request(request)
|> evaluate_response([
{200, BillingPaymentsResponse},
{400, ErrorDetails}
])
end
@doc """
Posts a payment to a past due invoice.
Posts a payment to a past due invoice. This method can only be used if the `paymentAllowed` value for a past due invoice is true. This can be determined calling [Billing::listInvoicesPastDue](/docs/esign-rest-api/reference/billing/invoices/listpastdue/). The response returns information for a single payment if a payment ID was used in the endpoint, or a list of payments. If the from date or to date queries or payment ID are not used, the response returns payment information for the last 365 days. If the request was for a single payment ID, the `nextUri` and `previousUri` properties are not returned. Privileges required: account administrator
### Parameters
- `connection` (DocuSign.Connection): Connection to server
- `account_id` (String.t): The external account number (int) or account ID GUID.
- `opts` (keyword): Optional parameters
- `:body` (BillingPaymentRequest):
### Returns
- `{:ok, DocuSign.Model.BillingPaymentResponse.t}` on success
- `{:error, Req.Response.t}` on failure
"""
@spec billing_payments_post_payment(DocuSign.Connection.t(), String.t(), keyword()) ::
{:ok, BillingPaymentResponse.t()}
| {:error, Req.Response.t()}
def billing_payments_post_payment(connection, account_id, opts \\ []) do
optional_params = %{
:body => :body
}
request =
%{}
|> method(:post)
|> url("/v2.1/accounts/#{account_id}/billing_payments")
|> add_optional_params(optional_params, opts)
|> ensure_body()
|> Enum.to_list()
connection
|> Connection.request(request)
|> evaluate_response([
{201, BillingPaymentResponse},
{400, ErrorDetails}
])
end
end