Skip to content

Commit

Permalink
feat: fix curl examples with code and detokenization expressions (#33)
Browse files Browse the repository at this point in the history
  • Loading branch information
bsterne authored Jan 12, 2023
1 parent 3e560c2 commit 1aca0e5
Show file tree
Hide file tree
Showing 8 changed files with 216 additions and 204 deletions.
84 changes: 33 additions & 51 deletions docs/api/proxies/proxies.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,15 @@ Creates a new Proxy for the Tenant.
<TabItem value="shell" label="cURL">

```shell showLineNumbers
transform='module.exports = async function (req) {
// Do something with req.configuration.SERVICE_API_KEY
return {
headers: req.args.headers,
body: req.args.body
};
};'

curl "https://api.basistheory.com/proxies" \
-H "BT-API-KEY: key_N88mVGsp3sCXkykyN2EFED" \
-H "Content-Type: application/json" \
Expand All @@ -44,28 +53,10 @@ curl "https://api.basistheory.com/proxies" \
"name": "My Proxy",
"destination_url": "https://example.com/api",
"request_transform": {
"code": "
module.exports = async function (req) {
// Do something with `req.configuration.SERVICE_API_KEY`
return {
headers: req.args.headers,
body: req.args.body
};
};
"
"code": '"$(echo $transform | jq -Rsa .)"',
},
"response_transform": {
"code": "
module.exports = async function (req) {
// Do something with `req.configuration.SERVICE_API_KEY`
return {
headers: req.args.headers,
body: req.args.body
};
};
"
"code": '"$(echo $transform | jq -Rsa .)"',
},
"configuration": {
"SERVICE_API_KEY": "key_abcd1234"
Expand All @@ -91,7 +82,7 @@ const proxy = await bt.proxies.create({
requestTransform: {
code: '
module.exports = async function (req) {
// Do something with `req.configuration.SERVICE_API_KEY`
// Do something with req.configuration.SERVICE_API_KEY
return {
headers: req.args.headers,
Expand All @@ -103,7 +94,7 @@ const proxy = await bt.proxies.create({
responseTransform: {
code: '
module.exports = async function (req) {
// Do something with `req.configuration.SERVICE_API_KEY`
// Do something with req.configuration.SERVICE_API_KEY
return {
headers: req.args.headers,
Expand Down Expand Up @@ -136,7 +127,7 @@ var proxy = await client.CreateAsync(new ProxyCreateRequest {
RequestTransform = new RequestTransform {
Code = @"
module.exports = async function (req) {
// Do something with `req.configuration.SERVICE_API_KEY`
// Do something with req.configuration.SERVICE_API_KEY
return {
headers: req.args.headers,
Expand All @@ -148,7 +139,7 @@ var proxy = await client.CreateAsync(new ProxyCreateRequest {
ResponseTransform = new RequestTransform {
Code = @"
module.exports = async function (req) {
// Do something with `req.configuration.SERVICE_API_KEY`
// Do something with req.configuration.SERVICE_API_KEY
return {
headers: req.args.headers,
Expand Down Expand Up @@ -184,7 +175,7 @@ with basistheory.ApiClient(configuration=basistheory.Configuration(api_key="key_
requeset_transform=ProxyTransform(
code=" \
module.exports = async function (req) { \
// Do something with `req.configuration.SERVICE_API_KEY` \
// Do something with req.configuration.SERVICE_API_KEY \
return { \
headers: req.args.headers, \
Expand Down Expand Up @@ -628,6 +619,15 @@ Update a Proxy by ID in the Tenant.
<TabItem value="shell" label="cURL">

```shell showLineNumbers
transform='module.exports = async function (req) {
// Do something with req.configuration.SERVICE_API_KEY
return {
headers: req.args.headers,
body: req.args.body
};
};'

curl "https://api.basistheory.com/proxies/433013a6-a614-4e1e-b2aa-5fba67aa85e6" \
-H "BT-API-KEY: key_N88mVGsp3sCXkykyN2EFED" \
-H "Content-Type: application/json" \
Expand All @@ -636,28 +636,10 @@ curl "https://api.basistheory.com/proxies/433013a6-a614-4e1e-b2aa-5fba67aa85e6"
"name": "My Proxy",
"destination_url": "https://example.com/api",
"request_transform": {
"code": "
module.exports = async function (req) {
// Do something with `req.configuration.SERVICE_API_KEY`
return {
headers: req.args.headers,
body: req.args.body
};
};
"
"code": '"$(echo $transform | jq -Rsa .)"',
},
"response_transform": {
"code": "
module.exports = async function (req) {
// Do something with `req.configuration.SERVICE_API_KEY`
return {
headers: req.args.headers,
body: req.args.body
};
};
"
"code": '"$(echo $transform | jq -Rsa .)"',
},
"configuration": {
"SERVICE_API_KEY": "key_abcd1234"
Expand All @@ -683,7 +665,7 @@ const proxy = await bt.proxies.update('433013a6-a614-4e1e-b2aa-5fba67aa85e6', {
requestTransform: {
code: '
module.exports = async function (req) {
// Do something with `req.configuration.SERVICE_API_KEY`
// Do something with req.configuration.SERVICE_API_KEY
return {
headers: req.args.headers,
Expand All @@ -695,7 +677,7 @@ const proxy = await bt.proxies.update('433013a6-a614-4e1e-b2aa-5fba67aa85e6', {
responseTransform: {
code: '
module.exports = async function (req) {
// Do something with `req.configuration.SERVICE_API_KEY`
// Do something with req.configuration.SERVICE_API_KEY
return {
headers: req.args.headers,
Expand Down Expand Up @@ -729,7 +711,7 @@ var proxy = await client.UpdateAsync("433013a6-a614-4e1e-b2aa-5fba67aa85e6",
RequestTransform = new RequestTransform {
Code = @"
module.exports = async function (req) {
// Do something with `req.configuration.SERVICE_API_KEY`
// Do something with req.configuration.SERVICE_API_KEY
return {
headers: req.args.headers,
Expand All @@ -741,7 +723,7 @@ var proxy = await client.UpdateAsync("433013a6-a614-4e1e-b2aa-5fba67aa85e6",
ResponseTransform = new RequestTransform {
Code = @"
module.exports = async function (req) {
// Do something with `req.configuration.SERVICE_API_KEY`
// Do something with req.configuration.SERVICE_API_KEY
return {
headers: req.args.headers,
Expand Down Expand Up @@ -778,7 +760,7 @@ with basistheory.ApiClient(configuration=basistheory.Configuration(api_key="key_
requeset_transform=ProxyTransform(
code=" \
module.exports = async function (req) { \
// Do something with `req.configuration.SERVICE_API_KEY` \
// Do something with req.configuration.SERVICE_API_KEY \
return { \
headers: req.args.headers, \
Expand All @@ -789,7 +771,7 @@ with basistheory.ApiClient(configuration=basistheory.Configuration(api_key="key_
response_transform=ProxyTransform(
code=" \
module.exports = async function (req) { \
// Do something with `req.configuration.SERVICE_API_KEY` \
// Do something with req.configuration.SERVICE_API_KEY \
return { \
headers: req.args.headers, \
Expand Down
70 changes: 35 additions & 35 deletions docs/api/reactors/reactor-formulas.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,16 @@ Create a new Reactor Formula for the Tenant.
<TabItem value="shell" label="cURL">

```shell showLineNumbers
javascript='module.exports = async function (req) {
// Do something with req.configuration.SERVICE_API_KEY
return {
raw: {
foo: "bar"
}
};
};'

curl "https://api.basistheory.com/reactor-formulas" \
-H "BT-API-KEY: key_N88mVGsp3sCXkykyN2EFED" \
-H "Content-Type: application/json" \
Expand All @@ -43,17 +53,7 @@ curl "https://api.basistheory.com/reactor-formulas" \
"description": "Securely react a token for another token",
"type": "private",
"icon": "data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==",
"code": "
module.exports = async function (req) {
// Do something with `req.configuration.SERVICE_API_KEY`
return {
raw: {
foo: 'bar'
}
};
};
",
"code": '"$(echo $javascript | jq -Rsa .)"',
"configuration": [
{
"name": "SERVICE_API_KEY",
Expand Down Expand Up @@ -92,11 +92,11 @@ const reactorFormula = await bt.reactorFormulas.create({
icon: 'data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==',
code: '
module.exports = async function (req) {
// Do something with `req.configuration.SERVICE_API_KEY`
// Do something with req.configuration.SERVICE_API_KEY
return {
raw: {
foo: 'bar'
foo: "bar"
}
};
};
Expand Down Expand Up @@ -139,7 +139,7 @@ var reactorFormula = await client.CreateAsync(new ReactorFormula {
Icon = "data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==",
Code = @"
module.exports = async function (req) {
// Do something with `req.configuration.SERVICE_API_KEY`
// Do something with req.configuration.SERVICE_API_KEY
return {
raw: {
Expand Down Expand Up @@ -192,7 +192,7 @@ with basistheory.ApiClient(configuration=basistheory.Configuration(api_key="key_
icon="data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==",
code=" \
module.exports = async function (req) { \
// Do something with `req.configuration.SERVICE_API_KEY`" \
// Do something with req.configuration.SERVICE_API_KEY \
return { \
raw: { \
Expand Down Expand Up @@ -302,7 +302,7 @@ Returns a [Reactor Formula](#reactor-formula-object) if the Reactor Formula was
"icon": "data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==",
"code": "
module.exports = async function (req) {
// Do something with `req.configuration.SERVICE_API_KEY`
// Do something with req.configuration.SERVICE_API_KEY

return {
raw: {
Expand Down Expand Up @@ -442,7 +442,7 @@ Returns a [paginated object](/docs/api/pagination) with the `data` property cont
"icon": "data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==",
"code": "
module.exports = async function (req) {
// Do something with `req.configuration.SERVICE_API_KEY`
// Do something with req.configuration.SERVICE_API_KEY

return {
raw: {
Expand Down Expand Up @@ -587,7 +587,7 @@ Returns a [Reactor Formula](#reactor-formula-object) with the `id` provided. Ret
"icon": "data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==",
"code": "
module.exports = async function (req) {
// Do something with `req.configuration.SERVICE_API_KEY`
// Do something with req.configuration.SERVICE_API_KEY

return {
raw: {
Expand Down Expand Up @@ -642,6 +642,16 @@ Update a Reactor Formula by ID in the Tenant.
<TabItem value="shell" label="cURL">

```shell showLineNumbers
javascript='module.exports = async function (req) {
// Do something with req.configuration.SERVICE_API_KEY
return {
raw: {
foo: "bar"
}
};
};'

curl "https://api.basistheory.com/reator-formula/17069df1-80f4-439e-86a7-4121863e4678" \
-H "BT-API-KEY: key_N88mVGsp3sCXkykyN2EFED" \
-H "Content-Type: application/json" \
Expand All @@ -651,17 +661,7 @@ curl "https://api.basistheory.com/reator-formula/17069df1-80f4-439e-86a7-4121863
"description": "Securely exchange token for another token",
"type": "private",
"icon": "data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==",
"code": "
module.exports = async function (req) {
// Do something with `req.configuration.SERVICE_API_KEY`
return {
raw: {
foo: 'bar'
}
};
};
",
"code": '"$(echo $javascript | jq -Rsa .)"',
"configuration": [
{
"name": "SERVICE_API_KEY",
Expand Down Expand Up @@ -700,11 +700,11 @@ const reactorFormula = await bt.reactorFormulas.update('17069df1-80f4-439e-86a7-
icon: 'data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==',
code: '
module.exports = async function (req) {
// Do something with `req.configuration.SERVICE_API_KEY`
// Do something with req.configuration.SERVICE_API_KEY
return {
raw: {
foo: 'bar',
foo: "bar",
}
};
};
Expand Down Expand Up @@ -748,7 +748,7 @@ var reactorFormula = await client.UpdateAsync("17069df1-80f4-439e-86a7-4121863e4
Icon = "data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==",
Code = @"
module.exports = async function (req) {
// Do something with `req.configuration.SERVICE_API_KEY`
// Do something with req.configuration.SERVICE_API_KEY
return {
raw: {
Expand Down Expand Up @@ -802,7 +802,7 @@ with basistheory.ApiClient(configuration=basistheory.Configuration(api_key="key_
icon="data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==",
code=" \
module.exports = async function (req) { \
// Do something with `req.configuration.SERVICE_API_KEY`" \
// Do something with req.configuration.SERVICE_API_KEY \
return { \
raw: { \
Expand Down Expand Up @@ -920,7 +920,7 @@ Returns a [Reactor Formula](#reactor-formula-object) if the Reactor Formula was
"icon": "data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==",
"code": "
module.exports = async function (req) {
// Do something with `req.configuration.SERVICE_API_KEY`
// Do something with req.configuration.SERVICE_API_KEY

return {
raw: {
Expand Down Expand Up @@ -1148,4 +1148,4 @@ For more information about writing your own code for a Reactor Formula, check ou
| Type | Description |
| ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `verified` | The formula has been verified and is generally available |
| `coming_soon` | The formula has limited availability. Request to <a href="https://support.basistheory.com/hc/requests/new?tf_subject=Join%20Private%20Beta%20for%20Reactor%20Formula&amp;tf_description=Let%20us%20know%20which%20reactor%20formula%20you'd%20like%20to%20use&amp;tf_priority=normal" target="_blank">join the Private Beta</a> for access. |
| `coming_soon` | The formula has limited availability. Request to <a href="https://support.basistheory.com/hc/requests/new?tf_subject=Join%20Private%20Beta%20for%20Reactor%20Formula&amp;tf_description=Let%20us%20know%20which%20reactor%20formula%20you'd%20like%20to%20use&amp;tf_priority=normal" target="_blank">join the Private Beta</a> for access. |
Loading

1 comment on commit 1aca0e5

@vercel
Copy link

@vercel vercel bot commented on 1aca0e5 Jan 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.