Skip to content

Commit

Permalink
chore: add JS tab to code snippets (#475)
Browse files Browse the repository at this point in the history
* chore: add JS tab to code snippets

* fix: add missing tabs
  • Loading branch information
sabineschaller committed May 29, 2024
1 parent 39ae12e commit 35ce0cf
Show file tree
Hide file tree
Showing 18 changed files with 730 additions and 6 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
136 changes: 134 additions & 2 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 Expand Up @@ -113,6 +157,49 @@ Run `tsx path/to/directory/index.ts`.
<LinkOut href='https://github.com/interledger/open-payments-snippets/blob/main/grant/grant-quote.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-quote.ts'
chunk='1'
/>

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

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

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

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

<ChunkedSnippet
source='https://raw.githubusercontent.com/interledger/open-payments-snippets/main/grant/grant-quote.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-quote.js'>View full source</LinkOut>
</p>

</TabItem>
</Tabs>

Expand Down Expand Up @@ -156,14 +243,59 @@ In Open Payments, an outgoing payment grant must be interactive. An interactive
chunk='6'
/>

</TabItem>
</Tabs>
Run `tsx path/to/directory/index.ts`.

{/* prettier-ignore */}
<p>
<LinkOut href='https://github.com/interledger/open-payments-snippets/blob/main/grant/grant-outgoing-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-outgoing-payment.ts'
chunk='1'
/>

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

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

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

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

<ChunkedSnippet
source='https://raw.githubusercontent.com/interledger/open-payments-snippets/main/grant/grant-outgoing-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-outgoing-payment.js'>View full source</LinkOut>
</p>

</TabItem>
</Tabs>

## References

- [API specification](/apis/auth-server/operations/post-request)
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)
Loading

0 comments on commit 35ce0cf

Please sign in to comment.