diff options
author | Antoine A <> | 2023-10-24 14:17:57 +0000 |
---|---|---|
committer | Antoine A <> | 2023-10-24 15:02:23 +0000 |
commit | ce0012414a783f720fe5283c0a5cbfee2d6718a3 (patch) | |
tree | 71818036de50c7b03d762a323814aa2b44d6844c | |
parent | 8b37ab93263939c4fadda30753f1809d816cf825 (diff) | |
download | docs-ce0012414a783f720fe5283c0a5cbfee2d6718a3.tar.gz docs-ce0012414a783f720fe5283c0a5cbfee2d6718a3.tar.bz2 docs-ce0012414a783f720fe5283c0a5cbfee2d6718a3.zip |
Fix core bank spec and harmonise style
-rw-r--r-- | core/api-bank-integration.rst | 35 | ||||
-rw-r--r-- | core/api-bank-revenue.rst | 2 | ||||
-rw-r--r-- | core/api-bank-wire.rst | 86 | ||||
-rw-r--r-- | core/api-corebank.rst | 339 |
4 files changed, 238 insertions, 224 deletions
diff --git a/core/api-bank-integration.rst b/core/api-bank-integration.rst index 630f5bb3..0950b7c4 100644 --- a/core/api-bank-integration.rst +++ b/core/api-bank-integration.rst @@ -30,8 +30,6 @@ to tightly integrate with GNU Taler. Get configuration information about the bank. - **Request:** - **Response:** :http:statuscode:`200 OK`: @@ -72,7 +70,7 @@ for the withdrawal operation (the ``wopid``) to interact with the withdrawal ope Query information about a withdrawal operation, identified by the ``wopid``. - **Request** + **Request:** :query long_poll_ms: *Optional.* If specified, the bank will wait up to ``long_poll_ms`` @@ -80,12 +78,13 @@ for the withdrawal operation (the ``wopid``) to interact with the withdrawal ope response. A client must never rely on this behavior, as the bank may return a response immediately. - **Response** + **Response:** :http:statuscode:`200 OK`: The withdrawal operation is known to the bank, and details are given in the `BankWithdrawalOperationStatus` response body. + **Details:** .. ts:def:: BankWithdrawalOperationStatus @@ -124,19 +123,7 @@ for the withdrawal operation (the ``wopid``) to interact with the withdrawal ope .. http:post:: ${BANK_API_BASE_URL}/withdrawal-operation/${wopid} - **Request** The body of this request must have the format of a `BankWithdrawalOperationPostRequest`. - - **Response** - - :http:statuscode:`200 OK`: - The bank has accepted the withdrawal operation parameters chosen by the wallet. - The response is a `BankWithdrawalOperationPostResponse`. - :http:statuscode:`404 Not found`: - The bank does not know about a withdrawal operation with the specified ``wopid``. - :http:statuscode:`409 Conflict` (New): - The wallet selected a different exchange or reserve public key under the same withdrawal ID. - - **Details** + **Request:** .. ts:def:: BankWithdrawalOperationPostRequest @@ -149,6 +136,20 @@ for the withdrawal operation (the ``wopid``) to interact with the withdrawal ope selected_exchange: string; } + **Response:** + + :http:statuscode:`200 OK`: + The bank has accepted the withdrawal operation parameters chosen by the wallet. + The response is a `BankWithdrawalOperationPostResponse`. + :http:statuscode:`404 Not found`: + The bank does not know about a withdrawal operation with the specified ``wopid``. + :http:statuscode:`409 Conflict` (New): + The wallet selected a different exchange or reserve public key under the same withdrawal ID. + + **Details:** + + + .. ts:def:: BankWithdrawalOperationPostResponse interface BankWithdrawalOperationPostResponse { diff --git a/core/api-bank-revenue.rst b/core/api-bank-revenue.rst index e266bced..393c0ea1 100644 --- a/core/api-bank-revenue.rst +++ b/core/api-bank-revenue.rst @@ -91,6 +91,8 @@ Querying the transaction history :http:statuscode:`404 Not found`: The endpoint is wrong or the user name is unknown. The bank replies with an `ErrorDetail` object. + **Details:** + .. ts:def:: MerchantIncomingHistory interface MerchantIncomingHistory { diff --git a/core/api-bank-wire.rst b/core/api-bank-wire.rst index 441537ca..a3474597 100644 --- a/core/api-bank-wire.rst +++ b/core/api-bank-wire.rst @@ -45,7 +45,31 @@ Making Transactions To make the API idempotent, the client must include a nonce. Requests with the same nonce are rejected unless the request is the same. - **Request:** The body of this request must have the format of a `TransferRequest`. + **Request:** + + .. ts:def:: TransferRequest + + interface TransferRequest { + // Nonce to make the request idempotent. Requests with the same + // ``transaction_uid`` that differ in any of the other fields + // are rejected. + request_uid: HashCode; + + // Amount to transfer. + amount: Amount; + + // Base URL of the exchange. Shall be included by the bank gateway + // in the appropriate section of the wire transfer details. + exchange_base_url: string; + + // Wire transfer identifier chosen by the exchange, + // used by the merchant to identify the Taler order(s) + // associated with this wire transfer. + wtid: ShortHashCode; + + // The recipient's account identifier as a payto URI. + credit_account: string; + } **Response:** @@ -82,31 +106,6 @@ Making Transactions } - .. ts:def:: TransferRequest - - interface TransferRequest { - // Nonce to make the request idempotent. Requests with the same - // ``transaction_uid`` that differ in any of the other fields - // are rejected. - request_uid: HashCode; - - // Amount to transfer. - amount: Amount; - - // Base URL of the exchange. Shall be included by the bank gateway - // in the appropriate section of the wire transfer details. - exchange_base_url: string; - - // Wire transfer identifier chosen by the exchange, - // used by the merchant to identify the Taler order(s) - // associated with this wire transfer. - wtid: ShortHashCode; - - // The recipient's account identifier as a payto URI. - credit_account: string; - } - - -------------------------------- Querying the transaction history -------------------------------- @@ -170,6 +169,8 @@ Querying the transaction history :http:statuscode:`404 Not found`: The endpoint is wrong or the user name is unknown. The bank replies with an `ErrorDetail` object. + **Details:** + .. ts:def:: IncomingHistory interface IncomingHistory { @@ -297,6 +298,8 @@ Querying the transaction history :http:statuscode:`404 Not found`: The endpoint is wrong or the user name is unknown. The bank replies with an `ErrorDetail` object. + **Details:** + .. ts:def:: OutgoingHistory interface OutgoingHistory { @@ -350,21 +353,7 @@ exposed by bank gateways in production. Simulate a transfer from a customer to the exchange. This API is *not* idempotent since it's only used in testing. - **Request:** The body of this request must have the format of a `AddIncomingRequest`. - - **Response:** - - :http:statuscode:`200 OK`: - The request has been correctly handled, so the funds have been transferred to - the recipient's account. The body is a `AddIncomingResponse`. - :http:statuscode:`400 Bad request`: - The request is malformed. The bank replies with an `ErrorDetail` object. - :http:statuscode:`401 Unauthorized`: - Authentication failed, likely the credentials are wrong. - :http:statuscode:`404 Not found`: - The endpoint is wrong or the user name is unknown. The bank replies with an `ErrorDetail` object. - :http:statuscode:`409 Conflict`: - The 'reserve_pub' argument was used previously in another transfer, and the specification mandates that reserve public keys must not be reused. + **Request:** .. ts:def:: AddIncomingRequest @@ -383,6 +372,21 @@ exposed by bank gateways in production. debit_account: string; } + **Response:** + + :http:statuscode:`200 OK`: + The request has been correctly handled, so the funds have been transferred to + the recipient's account. The body is a `AddIncomingResponse`. + :http:statuscode:`400 Bad request`: + The request is malformed. The bank replies with an `ErrorDetail` object. + :http:statuscode:`401 Unauthorized`: + Authentication failed, likely the credentials are wrong. + :http:statuscode:`404 Not found`: + The endpoint is wrong or the user name is unknown. The bank replies with an `ErrorDetail` object. + :http:statuscode:`409 Conflict`: + The 'reserve_pub' argument was used previously in another transfer, and the specification mandates that reserve public keys must not be reused. + + **Details:** .. ts:def:: AddIncomingResponse diff --git a/core/api-corebank.rst b/core/api-corebank.rst index e1df169e..e352869f 100644 --- a/core/api-corebank.rst +++ b/core/api-corebank.rst @@ -63,6 +63,11 @@ Config **Response:** + :http:statuscode:`200 OK`: + Response is a `Config`. + + **Details:** + .. ts:def:: Config interface Config { @@ -106,9 +111,6 @@ Config } - :http:statuscode:`200 OK`: - Response is a `Config`. - Account Management ------------------ @@ -305,16 +307,21 @@ Account Management accounts from donation receivers. As such, this request is unauthenticated. - **Request:** + **Request:** - :query start: *Optional.* - Row identifier to explicitly set the *starting point* of the query. - :query delta: *Optional.* - The *delta* value that determines the range of the query. + :query start: *Optional.* + Row identifier to explicitly set the *starting point* of the query. + :query delta: *Optional.* + The *delta* value that determines the range of the query. - **Response** + **Response:** + + :http:statuscode:`200 OK`: + Response is a `PublicAccountsResponse`. + :http:statuscode:`204 No content`: + No public account. - **Details** + **Details:** .. ts:def:: PublicAccountsResponse @@ -334,11 +341,6 @@ Account Management account_name: string; } - :http:statuscode:`200 OK`: - Response is a `PublicAccountsResponse`. - :http:statuscode:`204 No content`: - No public account. - .. http:get:: /accounts Obtains a list of the accounts registered at the bank. @@ -399,11 +401,11 @@ Account Management .. http:get:: /accounts/$USERNAME - Obtains information relative to the account owned by - ``$USERNAME``. The request is available to the administrator - and ``$USERNAME`` itself. + Obtains information relative to the account owned by + ``$USERNAME``. The request is available to the administrator + and ``$USERNAME`` itself. - **Response:** + **Response:** :http:statuscode:`200 OK`: The bank responds with an `AccountData` object. @@ -415,74 +417,68 @@ Account Management :http:statuscode:`404 Not found`: Username not found - **Details:** + **Details:** - .. ts:def:: AccountData + .. ts:def:: AccountData - interface AccountData { - // Legal name of the account owner. - name: string; + interface AccountData { + // Legal name of the account owner. + name: string; - // Available balance on the account. - balance: Balance; + // Available balance on the account. + balance: Balance; - // payto://-URI of the account. - payto_uri: string; + // payto://-URI of the account. + payto_uri: string; - // Number indicating the max debit allowed for the requesting user. - debit_threshold: Amount; + // Number indicating the max debit allowed for the requesting user. + debit_threshold: Amount; - contact_data?: ChallengeContactData; + contact_data?: ChallengeContactData; - // 'payto' address pointing the bank account - // where to send cashouts. This field is optional - // because not all the accounts are required to participate - // in the merchants' circuit. One example is the exchange: - // that never cashouts. Registering these accounts can - // be done via the access API. - cashout_payto_uri?: string; - } + // 'payto' address pointing the bank account + // where to send cashouts. This field is optional + // because not all the accounts are required to participate + // in the merchants' circuit. One example is the exchange: + // that never cashouts. Registering these accounts can + // be done via the access API. + cashout_payto_uri?: string; + } Transactions ------------ .. http:get:: ${BANK_API_BASE_URL}/accounts/${account_name}/transactions - Retrieve a subset of transactions related to $account_name. Without - query parameters, it returns the last 5 transactions. - - The list of returned transactions is determined by a row ID *starting point* - and a signed non-zero integer *delta*: + Retrieve a subset of transactions related to $account_name. Without + query parameters, it returns the last 5 transactions. - * If *delta* is positive, return a list of up to *delta* transactions (all matching - the filter criteria) strictly **after** the starting point. The transactions are sorted - in **ascending** order of the row ID. - * If *delta* is negative, return a list of up to *-delta* transactions (all matching - the filter criteria) strictly **before** the starting point. The transactions are sorted - in **descending** order of the row ID. + The list of returned transactions is determined by a row ID *starting point* + and a signed non-zero integer *delta*: - If *starting point* is not explicitly given, it defaults to: + * If *delta* is positive, return a list of up to *delta* transactions (all matching + the filter criteria) strictly **after** the starting point. The transactions are sorted + in **ascending** order of the row ID. + * If *delta* is negative, return a list of up to *-delta* transactions (all matching + the filter criteria) strictly **before** the starting point. The transactions are sorted + in **descending** order of the row ID. - * A value that is **smaller** than all other row IDs if *delta* is **positive**. - * A value that is **larger** than all other row IDs if *delta* is **negative**. + If *starting point* is not explicitly given, it defaults to: - **Request** - - :query long_poll_ms: Optional number to express how many milliseconds the server - should wait for at least one result to be shown. If not given, the server - responds immediately, regardless of the result. - :query start: *Optional.* - Row identifier to explicitly set the *starting point* of the query. - :query delta: *Optional.* - The *delta* value that determines the range of the query. + * A value that is **smaller** than all other row IDs if *delta* is **positive**. + * A value that is **larger** than all other row IDs if *delta* is **negative**. - **Response** + **Request:** - .. ts:def:: BankAccountTransactionsResponse + :query long_poll_ms: Optional number to express how many milliseconds the server + should wait for at least one result to be shown. If not given, the server + responds immediately, regardless of the result. + :query start: *Optional.* + Row identifier to explicitly set the *starting point* of the query. + :query delta: *Optional.* + The *delta* value that determines the range of the query. - interface BankAccountTransactionsResponse { - transactions: BankAccountTransactionInfo[]; - } + **Response:** :http:statuscode:`200 OK`: The bank responds with an `BankAccountTransactionsResponse` object. @@ -493,29 +489,19 @@ Transactions :http:statuscode:`404 Not found`: Username not found -.. http:get:: ${BANK_API_BASE_URL}/accounts/${account_name}/transactions/${transaction_id} - - **Response** - - Retrieve the transaction whose identifier is ``transaction_id``, - in the following format: + **Details:** - .. ts:def:: BankAccountTransactionInfo + .. ts:def:: BankAccountTransactionsResponse - interface BankAccountTransactionInfo { - creditor_payto_uri: string; - debtor_payto_uri: string; + interface BankAccountTransactionsResponse { + transactions: BankAccountTransactionInfo[]; + } - amount: Amount; - direction: "debit" | "credit"; +.. http:get:: ${BANK_API_BASE_URL}/accounts/${account_name}/transactions/${transaction_id} - subject: string; + Retrieve the transaction whose identifier is ``transaction_id``. - // Transaction unique ID. Matches - // $transaction_id from the URI. - row_id: number; - date: Timestamp; - } + **Response:** :http:statuscode:`200 OK`: The bank responds with an `BankAccountTransactionInfo` object. @@ -524,29 +510,47 @@ Transactions :http:statuscode:`401 Unauthorized`: Invalid credentials. + **Details:** + + .. ts:def:: BankAccountTransactionInfo + + interface BankAccountTransactionInfo { + creditor_payto_uri: string; + debtor_payto_uri: string; + + amount: Amount; + direction: "debit" | "credit"; + + subject: string; + + // Transaction unique ID. Matches + // $transaction_id from the URI. + row_id: number; + date: Timestamp; + } .. http:post:: ${BANK_API_BASE_URL}/accounts/${account_name}/transactions - Create a new transaction where the bank account with the label ``account_name`` is **debited**. + Create a new transaction where the bank account with the label ``account_name`` is **debited**. - **Request** + **Request:** - .. ts:def:: BankAccountTransactionCreate + .. ts:def:: BankAccountTransactionCreate - interface CreateBankAccountTransactionCreate { + interface CreateBankAccountTransactionCreate { - // Address in the Payto format of the wire transfer receiver. - // It needs at least the 'message' query string parameter. - payto_uri: string; + // Address in the Payto format of the wire transfer receiver. + // It needs at least the 'message' query string parameter. + payto_uri: string; - // Transaction amount (in the $currency:x.y format), optional. - // However, when not given, its value must occupy the 'amount' - // query string parameter of the 'payto' field. In case it - // is given in both places, the payto_uri's takes the precedence. - amount: string; - } + // Transaction amount (in the $currency:x.y format), optional. + // However, when not given, its value must occupy the 'amount' + // query string parameter of the 'payto' field. In case it + // is given in both places, the payto_uri's takes the precedence. + amount: string; + } - **Response** + **Response:** :http:statuscode:`204 No content`: the transaction has been created. @@ -563,7 +567,7 @@ Taler Withdrawals Create a withdrawal operation, resulting in a ``taler://withdraw`` URI. - **Request** + **Request:** .. ts:def:: BankAccountCreateWithdrawalRequest @@ -572,7 +576,14 @@ Taler Withdrawals amount: Amount; } - **Response** + **Response:** + + :http:statuscode:`200 Ok`: + The bank responds with an `BankAccountCreateWithdrawalResponse` object. + :http:statuscode:`403 Forbidden`: + The operation was rejected due to insufficient funds. + + **Details:** .. ts:def:: BankAccountCreateWithdrawalResponse @@ -584,21 +595,21 @@ Taler Withdrawals // URI that can be passed to the wallet to initiate the withdrawal. taler_withdraw_uri: string; - } - - :http:statuscode:`200 Ok`: - The bank responds with an `BankAccountCreateWithdrawalResponse` object. - :http:statuscode:`403 Forbidden`: - The operation was rejected due to insufficient funds. + } .. http:get:: ${BANK_API_BASE_URL}/withdrawals/${withdrawal_id} Query the status of a withdrawal operation. Does not require further authentication as knowledge of the withdrawal ID serves as an authenticator. - **Response** + **Response:** + + :http:statuscode:`200 Ok`: + The bank responds with an `BankAccountGetWithdrawalResponse` object. + :http:statuscode:`404 Not found`: + The operation was not found. - **Details** + **Details:** .. ts:def:: BankAccountGetWithdrawalResponse @@ -627,10 +638,7 @@ Taler Withdrawals selected_exchange_account: string | null; } - :http:statuscode:`200 Ok`: - The bank responds with an `BankAccountGetWithdrawalResponse` object. - :http:statuscode:`404 Not found`: - The operation was not found. + .. http:post:: ${BANK_API_BASE_URL}/withdrawals/${withdrawal_id}/abort @@ -638,9 +646,12 @@ Taler Withdrawals withdrawal operation. Does not require further authentication as knowledge of the withdrawal ID serves as an authenticator. - :http:statuscode:`204 No content`: The withdrawal operation has been aborted. The response is an empty JSON object. - :http:statuscode:`409 Conflict`: The reserve operation has been confirmed previously and can't be aborted. + **Response:** + :http:statuscode:`204 No content`: + The withdrawal operation has been aborted. + :http:statuscode:`409 Conflict`: + The reserve operation has been confirmed previously and can't be aborted. .. http:post:: ${BANK_API_BASE_URL}/withdrawals/${withdrawal_id}/confirm @@ -649,10 +660,10 @@ Taler Withdrawals exchange. Does not require further authentication as knowledge of the withdrawal ID serves as an authenticator. - **Response** + **Response:** :http:statuscode:`204 No content`: - The withdrawal operation has been confirmed. The response is an empty JSON object. + The withdrawal operation has been confirmed. :http:statuscode:`409 Conflict`: The withdrawal has been aborted previously and can't be confirmed. :http:statuscode:`422 Unprocessable Entity` (New): @@ -687,7 +698,7 @@ Cashouts To test this operation without relying on any SMS/E-mail provider, Libeufin offers two methods: defining an environment variable called ``LIBEUFIN_CASHOUT_TEST_TAN`` or specifying the value ``file`` to - the ``tan_channel`` field of the `request object <cashout-request_>`_. + the ``tan_channel`` field of the `CashoutRequest`. Assuming ``LIBEUFIN_CASHOUT_TEST_TAN`` is set to *T*, every */confirm* operation can use *T* as the TAN. Setting instead the ``tan_channel`` field to ``file`` will cause the server to (over)write every TAN to @@ -702,8 +713,6 @@ Cashouts :query delta: *Optional.* The *delta* value that determines the range of the query. - `CashoutRequest <cashout-request_>`_ - .. ts:def:: TanChannel enum TanChannel { @@ -712,8 +721,6 @@ Cashouts FILE = "file" } - .. _cashout-request: - .. ts:def:: CashoutRequest interface CashoutRequest { @@ -850,18 +857,6 @@ Cashouts **Response:** - .. ts:def:: CashoutConversionResponse - - interface CashoutConversionResponse { - // Amount that the user will get deducted from their regional - // bank account, according to the 'amount_credit' value. - amount_debit: Amount; - // Amount that the user will receive in their fiat - // bank account, according to 'amount_debit'. - amount_credit: Amount; - } - - :http:statuscode:`200 OK`: Response is a `CashoutConversionResponse`. :http:statuscode:`400 Bad request`: @@ -873,6 +868,18 @@ Cashouts :http:statuscode:`503 Service unavailable`: This server does not support cashout, client should check config response. + **Details:** + + .. ts:def:: CashoutConversionResponse + + interface CashoutConversionResponse { + // Amount that the user will get deducted from their regional + // bank account, according to the 'amount_credit' value. + amount_debit: Amount; + // Amount that the user will receive in their fiat + // bank account, according to 'amount_debit'. + amount_credit: Amount; + } .. _circuit-cashouts: @@ -883,6 +890,17 @@ Cashouts **Response:** + :http:statuscode:`200 OK`: + Response is a `Cashouts`. + :http:statuscode:`204 No Content`: + No cash-out operations were found at the bank + :http:statuscode:`404 Not found`: + Username not fuond. + :http:statuscode:`503 Service unavailable`: + This server does not support cashout, client should check config response. + + **Details:** + .. ts:def:: Cashouts interface Cashouts { @@ -897,15 +915,6 @@ Cashouts status: "pending" | "confirmed"; } - :http:statuscode:`200 OK`: - Response is a `Cashouts`. - :http:statuscode:`204 No Content`: - No cash-out operations were found at the bank - :http:statuscode:`404 Not found`: - Username not fuond. - :http:statuscode:`503 Service unavailable`: - This server does not support cashout, client should check config response. - .. http:get:: /cashouts Returns the list of all the (pending and confirmed) cash-out operations @@ -920,11 +929,19 @@ Cashouts **Response:** + :http:statuscode:`200 OK`: + Response is a `GlobalCashouts`. + :http:statuscode:`204 No Content`: + No cash-out operations were found at the bank + :http:statuscode:`503 Service unavailable`: + This server does not support cashout, client should check config response. + + **Details:** + .. ts:def:: GlobalCashouts interface GlobalCashouts { - // Every string represents a cash-out operation ID. - cashouts: { cashout_id: string, username: string}[]; + cashouts: GlobalCashoutInfo[]; } .. ts:def:: GlobalCashoutInfo @@ -935,13 +952,6 @@ Cashouts status: "pending" | "confirmed"; } - :http:statuscode:`200 OK`: - Response is a `GlobalCashouts`. - :http:statuscode:`204 No Content`: - No cash-out operations were found at the bank - :http:statuscode:`503 Service unavailable`: - This server does not support cashout, client should check config response. - .. _circuit-cashout-details: .. http:get:: /accounts/$USERNAME/cashouts/$CASHOUT_ID @@ -951,11 +961,17 @@ Cashouts **Response:** - `CashoutStatusResponse <cashout-status_>`_ + :http:statuscode:`200 OK`: + Response is a `CashoutStatusResponse`. + :http:statuscode:`404 Not found`: + The cashout operation was not found. + Aborted cashout operations will also not be found. + :http:statuscode:`503 Service unavailable`: + This server does not support cashout, client should check config response. - .. _cashout-status: + **Details:** - .. ts:def:: CashoutStatus + .. ts:def:: CashoutStatusResponse interface CashoutStatusResponse { status: "pending" | "confirmed"; @@ -982,17 +998,6 @@ Cashouts confirmation_time?: Timestamp; } - **Response:** - - :http:statuscode:`200 OK`: - Response is a `CashoutStatusResponse`. - :http:statuscode:`404 Not found`: - The cashout operation was not found. - Aborted cashout operations will also not be found. - :http:statuscode:`503 Service unavailable`: - This server does not support cashout, client should check config response. - - Monitor ------- @@ -1037,6 +1042,8 @@ Monitor :http:statuscode:`503 Service unavailable`: The bank doesn't have the conversion service. + **Details:** + .. note:: API consumers may combine the values in the response with other |