Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert Wallet API reference to markdoc #1134

Merged
merged 1 commit into from
Dec 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion astro.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export default defineConfig({
tailwind({ applyBaseStyles: false }),
expressiveCode(),
mdx(),
markdoc(),
markdoc({ ignoreIndentation: true }),
],
markdown: {
rehypePlugins: [ rehypeSectionize ],
Expand Down
35 changes: 35 additions & 0 deletions markdoc.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,26 @@ export default defineMarkdocConfig({
},
},
tags: {
badge: {
render: component('./src/components/Badge.astro'),
attributes: {
type: { type: String },
},
},
endpoint: {
render: component('./src/components/Endpoint.astro'),
attributes: {
filename: { type: String },
path: { type: String },
},
},
error: {
render: component('./src/components/Error.astro'),
attributes: {
code: { type: String },
message: { type: String },
},
},
farmlandsSolutionCard: {
render: component('./src/components/SolutionCard.astro'),
attributes: {
Expand All @@ -75,6 +95,21 @@ export default defineMarkdocConfig({
class: { type: String },
},
},
properties: {
render: component('./src/components/Properties.astro'),
attributes: {
heading: { type: String },
},
},
property: {
render: component('./src/components/Property.astro'),
attributes: {
experimental: { type: Boolean },
name: { type: String },
required: { type: Boolean },
type: { type: String },
},
},
mermaid: {
render: component('./src/components/Mermaid.astro'),
},
Expand Down
2 changes: 0 additions & 2 deletions src/components/Endpoint.astro
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
---
import Eyebrow from './Eyebrow.astro';
import Row from './Row.astro';
import Column from './Column.astro';
import CodePanel from './CodePanel.astro';
Expand All @@ -21,7 +20,6 @@ if (!endpoint) {

<Row>
<Column>
<Eyebrow method={endpoint.method} path={path}/>
<slot/>
</Column>

Expand Down
13 changes: 0 additions & 13 deletions src/components/Eyebrow.astro

This file was deleted.

161 changes: 73 additions & 88 deletions src/content/api/wallets.mdx → src/content/api/wallets.mdoc
Original file line number Diff line number Diff line change
Expand Up @@ -5,180 +5,165 @@ nav:
path: Assets
order: 6
---
import Properties from '../../components/Properties.astro';
import Property from '../../components/Property.astro';
import Badge from '../../components/Badge.astro';
import Error from '../../components/Error.astro';
import Endpoint from '../../components/Endpoint.astro';

A Wallet is an Asset that represents [Money](/api/assets#money-model). The Wallet maintains a record of all transactions it has participated in. A Wallet has a single balance and a single currency.

## Settlement Wallets <Badge type="experimental" />
## Settlement Wallets {% badge type="experimental" /%}

A Settlement Wallet is a special type of Wallet that can only receive or refund money related to a [Payment Request](/api/payment-requests). This means you cannot topup, withdraw, or send money from this Wallet.

## Wallet Model


<Properties>
<Property name="id" type="string">
{% properties %}
{% property name="id" type="string" %}
The unique identifier of the Wallet.
</Property>
{% /property %}

<Property name="accountId" type="string">
{% property name="accountId" type="string" %}
The Wallets's owning Centrapay [Account](/api/accounts/) id.
</Property>
{% /property %}

<Property name="category" type="string">
{% property name="category" type="string" %}
Asset category (`money`, `giftcard`, `token`).
</Property>
{% /property %}

<Property name="type" type="string">
{% property name="type" type="string" %}
[Asset Type](/api/asset-types) id used by payment option asset types.
</Property>
{% /property %}

<Property name="liveness" type="string">
{% property name="liveness" type="string" %}
Either `main` (live payments allowed) or `test`.
</Property>
{% /property %}

<Property name="description" type="string">
{% property name="description" type="string" %}
Displayable asset description.
</Property>
{% /property %}

<Property name="createdAt" type="timestamp">
{% property name="createdAt" type="timestamp" %}
Timestamp at which the Wallet was created.
</Property>
{% /property %}

<Property name="status" type="string">
{% property name="status" type="string" %}
`active` if the Wallet can be used for payments.
</Property>
{% /property %}

<Property name="currency" type="string">
{% property name="currency" type="string" %}
Currency code, eg "NZD".
</Property>
{% /property %}

<Property name="balance" type="BigNumber">
{% property name="balance" type="BigNumber" %}
Current balance in the currency's smallest denomination (ie. cents).
</Property>
{% /property %}

<Property name="availableBalance" type="BigNumber">
{% property name="availableBalance" type="BigNumber" %}
The balance of the asset that is available for transfers or purchases.
</Property>
{% /property %}

<Property name="settlement" type="boolean" experimental>
{% property name="settlement" type="boolean" experimental=true %}
`true` if the Wallet is a [Settlement Wallet](#settlement-wallets).
</Property>
</Properties>
{% /property %}
{% /properties %}

---

## Wallet Transaction Model


<Properties>
<Property name="activityNumber" type="BigNumber">
{% properties %}
{% property name="activityNumber" type="BigNumber" %}
Unique sequential Wallet transaction number.
</Property>
{% /property %}

<Property name="amount" type="BigNumber">
{% property name="amount" type="BigNumber" %}
Absolute transaction amount in cents.
</Property>
{% /property %}

<Property name="value" type="BigNumber">
{% property name="value" type="BigNumber" %}
Change to the Wallet's balance in cents when the transaction was applied.
</Property>
{% /property %}

<Property name="createdAt" type="timestamp">
{% property name="createdAt" type="timestamp" %}
Transaction timestamp as ISO 8601 date string.
</Property>
{% /property %}

<Property name="activityType" type="string">
{% property name="activityType" type="string" %}
Hints to the type of transaction: undefined or `returned-asset-transfer`.
</Property>
{% /property %}

<Property name="destWalletId" type="string">
{% property name="destWalletId" type="string" %}
Id of the destination Wallet if applicable.
</Property>
{% /property %}

<Property name="srcWalletId" type="string">
{% property name="srcWalletId" type="string" %}
Id of the source Wallet if applicable.
</Property>
{% /property %}

<Property name="destParty" type="string">
{% property name="destParty" type="string" %}
Display value for party receiving funds if applicable. Values may include a merchant name, user handle, masked user email, masked user phone, or bank account.
</Property>
{% /property %}

<Property name="srcParty" type="string">
{% property name="srcParty" type="string" %}
Display value for party providing funds if applicable. Values may include a merchant name, user handle, masked user email, masked user phone, or bank account.
</Property>
{% /property %}

<Property name="paymentRequestId" type="string">
{% property name="paymentRequestId" type="string" %}
Unique identifier of the related [Payment Request](/api/payment-requests) if applicable.
</Property>
{% /property %}

<Property name="topupId" type="string">
{% property name="topupId" type="string" %}
Unique identifier of the related topup [Funds Transfer](/api/funds-transfers) request if applicable.
</Property>
{% /property %}

<Property name="assetTransferId" type="string">
{% property name="assetTransferId" type="string" %}
Unique identifier of the related [Asset Transfer](/api/asset-transfers) request if applicable.
</Property>
{% /property %}

<Property name="withdrawalId" type="string">
{% property name="withdrawalId" type="string" %}
Unique identifier of the related [Withdrawal](/api/funds-transfers) request if applicable.
</Property>
</Properties>
{% /property %}
{% /properties %}

---

<Endpoint
path="/api/wallets"
filename="wallets-create"
>
{% endpoint path="/api/wallets" filename="wallets-create" %}
## Create a Wallet

This endpoint allows you to create a Wallet.

<Properties>
<Property name="accountId" type="string" required>
{% properties %}
{% property name="accountId" type="string" required=true %}
The Wallets's owning Centrapay [Account](/api/accounts/) id.
</Property>
{% /property %}

<Property name="ledgerId" type="string" required>
{% property name="ledgerId" type="string" required=true %}
[Asset Type](/api/asset-types) id used by payment option asset types.
</Property>
{% /property %}

<Property name="settlement" type="boolean" experimental>
{% property name="settlement" type="boolean" experimental=true %}
`true` if the Wallet is a [Settlement Wallet](#settlement-wallets).
</Property>
</Properties>
{% /property %}
{% /properties %}

<Properties heading="Errors">
<Error code="403" message="ACCOUNT_MAX_WALLETS_REACHED">
{% properties heading="Errors" %}
{% error code="403" message="ACCOUNT_MAX_WALLETS_REACHED" %}
The maximum number of wallets for the given ledger has been reached.
</Error>
</Properties>
{% /error %}
{% /properties %}

</Endpoint>
{% /endpoint %}

---

<Endpoint
path="/api/wallets"
filename="wallets-list"
>
{% endpoint path="/api/wallets" filename="wallets-list" %}
## List Wallets

This endpoint allows you to list authorized Wallets.
</Endpoint>
{% /endpoint %}

---

<Endpoint
path="/api/wallets/{walletId}/transactions"
filename="wallets-list-transactions"
>
{% endpoint path="/api/wallets/{walletId}/transactions" filename="wallets-list-transactions" %}
## List Wallet Transactions

This endpoint allows you to list Wallet Transactions.
</Endpoint>
{% /endpoint %}