Skip to content

Commit

Permalink
chore: add JS tab to code snippets
Browse files Browse the repository at this point in the history
  • Loading branch information
sabineschaller committed May 23, 2024
1 parent 39ae12e commit 82ba980
Show file tree
Hide file tree
Showing 18 changed files with 640 additions and 4 deletions.
35 changes: 35 additions & 0 deletions docs/src/content/docs/snippets/grant-continue.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { Tabs, TabItem } from '@astrojs/starlight/components'
import ChunkedSnippet from '/src/components/ChunkedSnippet.astro'
import Begin from '/src/partials/before-you-begin.mdx'
import Ts from '/src/partials/ts-prerequisites.mdx'
import Js from '/src/partials/js-prerequisites.mdx'

During a grant request flow, an authorization server can require an individual (typically a client's end user) to approve the grant by interacting directly with the server. For example, by tapping an Approve button on a web page provided by the auth server.

Expand Down Expand Up @@ -53,6 +54,40 @@ Run `tsx path/to/directory/index.ts`.
<LinkOut href='https://github.com/interledger/open-payments-snippets/blob/main/grant/grant-continuation.ts'>View full source</LinkOut>
</p>

</TabItem>

<TabItem label='JavaScript'>
<Js />

#### Get started

<ChunkedSnippet
source='https://raw.githubusercontent.com/interledger/open-payments-snippets/main/grant/grant-continuation.ts'
chunk='1'
/>

<ChunkedSnippet
source='https://raw.githubusercontent.com/interledger/open-payments-snippets/main/grant/grant-continuation.ts'
chunk='2'
/>

<ChunkedSnippet
source='https://raw.githubusercontent.com/interledger/open-payments-snippets/main/grant/grant-continuation.ts'
chunk='3'
/>

<ChunkedSnippet
source='https://raw.githubusercontent.com/interledger/open-payments-snippets/main/grant/grant-continuation.ts'
chunk='4'
/>

Run `node path/to/directory/index.js`.

{/* prettier-ignore */}
<p>
<LinkOut href='https://github.com/interledger/open-payments-snippets/blob/main/grant/grant-continuation.js'>View full source</LinkOut>
</p>

</TabItem>
</Tabs>

Expand Down
44 changes: 44 additions & 0 deletions docs/src/content/docs/snippets/grant-create.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { Tabs, TabItem } from '@astrojs/starlight/components'
import ChunkedSnippet from '/src/components/ChunkedSnippet.astro'
import Begin from '/src/partials/before-you-begin.mdx'
import Ts from '/src/partials/ts-prerequisites.mdx'
import Js from '/src/partials/js-prerequisites.mdx'

Before a client can call the Open Payments API, it must request/receive a grant from the appropriate authorization server. The request must indicate the resource type the client intends to work with and the actions the client wants to take at the resource server.

Expand Down Expand Up @@ -65,6 +66,49 @@ Run `tsx path/to/directory/index.ts`.
<LinkOut href='https://github.com/interledger/open-payments-snippets/blob/main/grant/grant-incoming-payment.ts'>View full source</LinkOut>
</p>

</TabItem>
<TabItem label='JavaScript'>
<Js />

#### Get started

<ChunkedSnippet
source='https://raw.githubusercontent.com/interledger/open-payments-snippets/main/grant/grant-incoming-payment.ts'
chunk='1'
/>

<ChunkedSnippet
source='https://raw.githubusercontent.com/interledger/open-payments-snippets/main/grant/grant-incoming-payment.ts'
chunk='2'
/>

<ChunkedSnippet
source='https://raw.githubusercontent.com/interledger/open-payments-snippets/main/grant/grant-incoming-payment.ts'
chunk='3'
/>

<ChunkedSnippet
source='https://raw.githubusercontent.com/interledger/open-payments-snippets/main/grant/grant-incoming-payment.ts'
chunk='4'
/>

<ChunkedSnippet
source='https://raw.githubusercontent.com/interledger/open-payments-snippets/main/grant/grant-incoming-payment.ts'
chunk='5'
/>

<ChunkedSnippet
source='https://raw.githubusercontent.com/interledger/open-payments-snippets/main/grant/grant-incoming-payment.ts'
chunk='6'
/>

Run `node path/to/directory/index.js`.

{/* prettier-ignore */}
<p>
<LinkOut href='https://github.com/interledger/open-payments-snippets/blob/main/grant/grant-incoming-payment.js'>View full source</LinkOut>
</p>

</TabItem>
</Tabs>

Expand Down
29 changes: 29 additions & 0 deletions docs/src/content/docs/snippets/grant-revoke.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { Tabs, TabItem } from '@astrojs/starlight/components'
import ChunkedSnippet from '/src/components/ChunkedSnippet.astro'
import Begin from '/src/partials/before-you-begin.mdx'
import Ts from '/src/partials/ts-prerequisites.mdx'
import Js from '/src/partials/js-prerequisites.mdx'

If an authorized client no longer needs access to protected resources, the client can revoke the corresponding grant request.

Expand Down Expand Up @@ -46,6 +47,34 @@ Run `tsx path/to/directory/index.ts`.
<LinkOut href='https://github.com/interledger/open-payments-snippets/blob/main/grant/grant-revoke.ts'>View full source</LinkOut>
</p>

</TabItem>
<TabItem label='JavaScript'>
<Js />

#### Get started

<ChunkedSnippet
source='https://raw.githubusercontent.com/interledger/open-payments-snippets/main/grant/grant-revoke.ts'
chunk='1'
/>

<ChunkedSnippet
source='https://raw.githubusercontent.com/interledger/open-payments-snippets/main/grant/grant-revoke.ts'
chunk='2'
/>

<ChunkedSnippet
source='https://raw.githubusercontent.com/interledger/open-payments-snippets/main/grant/grant-revoke.ts'
chunk='3'
/>

Run `node path/to/directory/index.js`.

{/* prettier-ignore */}
<p>
<LinkOut href='https://github.com/interledger/open-payments-snippets/blob/main/grant/grant-revoke.js'>View full source</LinkOut>
</p>

</TabItem>
</Tabs>

Expand Down
34 changes: 34 additions & 0 deletions docs/src/content/docs/snippets/incoming-complete.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { Tabs, TabItem } from '@astrojs/starlight/components'
import ChunkedSnippet from '/src/components/ChunkedSnippet.astro'
import Begin from '/src/partials/before-you-begin.mdx'
import Ts from '/src/partials/ts-prerequisites.mdx'
import Js from '/src/partials/js-prerequisites.mdx'

An authorized client can complete an unexpired incoming payment to indicate it will not send any additional payments to the wallet address.

Expand Down Expand Up @@ -51,6 +52,39 @@ Run `tsx path/to/directory/index.ts`.
<LinkOut href='https://github.com/interledger/open-payments-snippets/blob/main/incoming-payment/incoming-payment-complete.ts'>View full source</LinkOut>
</p>

</TabItem>
<TabItem label='JavaScript'>
<Js />

#### Get started

<ChunkedSnippet
source='https://raw.githubusercontent.com/interledger/open-payments-snippets/main/incoming-payment/incoming-payment-complete.ts'
chunk='1'
/>

<ChunkedSnippet
source='https://raw.githubusercontent.com/interledger/open-payments-snippets/main/incoming-payment/incoming-payment-complete.ts'
chunk='2'
/>

<ChunkedSnippet
source='https://raw.githubusercontent.com/interledger/open-payments-snippets/main/incoming-payment/incoming-payment-complete.ts'
chunk='3'
/>

<ChunkedSnippet
source='https://raw.githubusercontent.com/interledger/open-payments-snippets/main/incoming-payment/incoming-payment-complete.ts'
chunk='4'
/>

Run `node path/to/directory/index.js`.

{/* prettier-ignore */}
<p>
<LinkOut href='https://github.com/interledger/open-payments-snippets/blob/main/incoming-payment/incoming-payment-complete.js'>View full source</LinkOut>
</p>

</TabItem>
</Tabs>

Expand Down
40 changes: 37 additions & 3 deletions docs/src/content/docs/snippets/incoming-create.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { Tabs, TabItem } from '@astrojs/starlight/components'
import ChunkedSnippet from '/src/components/ChunkedSnippet.astro'
import Begin from '/src/partials/before-you-begin.mdx'
import Ts from '/src/partials/ts-prerequisites.mdx'
import Js from '/src/partials/js-prerequisites.mdx'

Once an authorized client obtains the requisite grant from the recipient’s authentication server, the client must create an incoming payment resource before any payments can be sent to the recipient’s wallet address.

Expand Down Expand Up @@ -44,16 +45,49 @@ These code snippets create an incoming payment of $10 USD at a given wallet addr
chunk='4'
/>

</TabItem>
</Tabs>

Run `tsx path/to/directory/index.ts`.

{/* prettier-ignore */}
<p>
<LinkOut href='https://github.com/interledger/open-payments-snippets/blob/main/incoming-payment/incoming-payment-create.ts'>View full source</LinkOut>
</p>

</TabItem>
<TabItem label='JavaScript'>
<Js />

#### Get started

<ChunkedSnippet
source='https://raw.githubusercontent.com/interledger/open-payments-snippets/main/incoming-payment/incoming-payment-create.ts'
chunk='1'
/>

<ChunkedSnippet
source='https://raw.githubusercontent.com/interledger/open-payments-snippets/main/incoming-payment/incoming-payment-create.ts'
chunk='2'
/>

<ChunkedSnippet
source='https://raw.githubusercontent.com/interledger/open-payments-snippets/main/incoming-payment/incoming-payment-create.ts'
chunk='3'
/>

<ChunkedSnippet
source='https://raw.githubusercontent.com/interledger/open-payments-snippets/main/incoming-payment/incoming-payment-create.ts'
chunk='4'
/>

Run `node path/to/directory/index.js`.

{/* prettier-ignore */}
<p>
<LinkOut href='https://github.com/interledger/open-payments-snippets/blob/main/incoming-payment/incoming-payment-create.js'>View full source</LinkOut>
</p>

</TabItem>
</Tabs>

## References

- [API specification](/apis/resource-server/operations/create-incoming-payment)
34 changes: 34 additions & 0 deletions docs/src/content/docs/snippets/incoming-get.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { Tabs, TabItem } from '@astrojs/starlight/components'
import ChunkedSnippet from '/src/components/ChunkedSnippet.astro'
import Begin from '/src/partials/before-you-begin.mdx'
import Ts from '/src/partials/ts-prerequisites.mdx'
import Js from '/src/partials/js-prerequisites.mdx'

An authorized client can look up the state of an incoming payment on a wallet address. This is useful when a client must determine if an incoming payment is still active and pending payment.

Expand Down Expand Up @@ -51,6 +52,39 @@ Run `tsx path/to/directory/index.ts`.
<LinkOut href='https://github.com/interledger/open-payments-snippets/blob/main/incoming-payment/incoming-payment-get.ts'>View full source</LinkOut>
</p>

</TabItem>
<TabItem label='JavaScript'>
<Js />

#### Get started

<ChunkedSnippet
source='https://raw.githubusercontent.com/interledger/open-payments-snippets/main/incoming-payment/incoming-payment-get.ts'
chunk='1'
/>

<ChunkedSnippet
source='https://raw.githubusercontent.com/interledger/open-payments-snippets/main/incoming-payment/incoming-payment-get.ts'
chunk='2'
/>

<ChunkedSnippet
source='https://raw.githubusercontent.com/interledger/open-payments-snippets/main/incoming-payment/incoming-payment-get.ts'
chunk='3'
/>

<ChunkedSnippet
source='https://raw.githubusercontent.com/interledger/open-payments-snippets/main/incoming-payment/incoming-payment-get.ts'
chunk='4'
/>

Run `node path/to/directory/index.js`.

{/* prettier-ignore */}
<p>
<LinkOut href='https://github.com/interledger/open-payments-snippets/blob/main/incoming-payment/incoming-payment-get.js'>View full source</LinkOut>
</p>

</TabItem>
</Tabs>

Expand Down
34 changes: 34 additions & 0 deletions docs/src/content/docs/snippets/incoming-list.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { Tabs, TabItem } from '@astrojs/starlight/components'
import ChunkedSnippet from '/src/components/ChunkedSnippet.astro'
import Begin from '/src/partials/before-you-begin.mdx'
import Ts from '/src/partials/ts-prerequisites.mdx'
import Js from '/src/partials/js-prerequisites.mdx'

After one or more incoming payments have been created on a wallet address, an authorized client can look up active and pending incoming payments on that wallet address.

Expand Down Expand Up @@ -51,6 +52,39 @@ Run `tsx path/to/directory/index.ts`.
<LinkOut href='https://github.com/interledger/open-payments-snippets/blob/main/incoming-payment/incoming-payment-list.ts'>View full source</LinkOut>
</p>

</TabItem>
<TabItem label='JavaScript'>
<Js />

#### Get started

<ChunkedSnippet
source='https://raw.githubusercontent.com/interledger/open-payments-snippets/main/incoming-payment/incoming-payment-list.ts'
chunk='1'
/>

<ChunkedSnippet
source='https://raw.githubusercontent.com/interledger/open-payments-snippets/main/incoming-payment/incoming-payment-list.ts'
chunk='2'
/>

<ChunkedSnippet
source='https://raw.githubusercontent.com/interledger/open-payments-snippets/main/incoming-payment/incoming-payment-list.ts'
chunk='3'
/>

<ChunkedSnippet
source='https://raw.githubusercontent.com/interledger/open-payments-snippets/main/incoming-payment/incoming-payment-list.ts'
chunk='4'
/>

Run `node path/to/directory/index.js`.

{/* prettier-ignore */}
<p>
<LinkOut href='https://github.com/interledger/open-payments-snippets/blob/main/incoming-payment/incoming-payment-list.js'>View full source</LinkOut>
</p>

</TabItem>
</Tabs>

Expand Down
Loading

0 comments on commit 82ba980

Please sign in to comment.