-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 93824a0
Showing
42 changed files
with
21,641 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
.github/workflows @tremendous-rewards/platform |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
version: 2 | ||
updates: | ||
- package-ecosystem: "github-actions" | ||
directory: "/" | ||
schedule: | ||
interval: "weekly" | ||
|
||
- package-ecosystem: "npm" | ||
directory: "/" | ||
schedule: | ||
interval: "weekly" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
name: Publish package to NPM | ||
on: | ||
release: | ||
types: [published] | ||
jobs: | ||
publish: | ||
if: github.repository == 'tremendous/tremendous-node' | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: '20.x' | ||
registry-url: 'https://registry.npmjs.org' | ||
- run: npm ci | ||
# TODO: Remove `--dry-run` when it's ready | ||
- run: npm publish --dry-run | ||
env: | ||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
name: Run tests | ||
|
||
on: [push, pull_request] | ||
|
||
jobs: | ||
test: | ||
if: github.repository == 'tremendous/tremendous-node' | ||
runs-on: ubuntu-latest | ||
|
||
strategy: | ||
matrix: | ||
node-version: ['18.x', '20.x', '21.x'] | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Use Node.js ${{ matrix.node-version }} | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
cache: 'npm' | ||
- run: npm ci | ||
- run: npm run build | ||
- run: npm run test | ||
env: | ||
SANDBOX_API_TOKEN: ${{ secrets.SANDBOX_API_TOKEN }} | ||
TEST_CAMPAIGN_ID: ${{ secrets.TEST_CAMPAIGN_ID }} | ||
TEST_PRODUCT_ID: ${{ secrets.TEST_PRODUCT_ID }} | ||
TEST_RECIPIENT_EMAIL: ${{ secrets.TEST_RECIPIENT_EMAIL }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
/node_modules/ | ||
/npm-debug.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
/test/ | ||
/.gitignore | ||
/RELEASING.md | ||
/.github | ||
/tsconfig.json | ||
/tmp | ||
/templates | ||
.openapi-generator* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# OpenAPI Generator Ignore | ||
# Generated by openapi-generator https://github.com/openapitools/openapi-generator | ||
|
||
# Use this file to prevent files from being overwritten by the generator. | ||
# The patterns follow closely to .gitignore or .dockerignore. | ||
|
||
# As an example, the C# client generator defines ApiClient.cs. | ||
# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line: | ||
#ApiClient.cs | ||
|
||
# You can match any string of characters against a directory, file or extension with a single asterisk (*): | ||
#foo/*/qux | ||
# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux | ||
|
||
# You can recursively match patterns against a directory, file or extension with a double asterisk (**): | ||
#foo/**/qux | ||
# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux | ||
|
||
# You can also negate patterns with an exclamation (!). | ||
# For example, you can ignore all files in a docs folder with the file extension .md: | ||
#docs/*.md | ||
# Then explicitly reverse the ignore rule for a single file: | ||
#!docs/README.md | ||
bin | ||
.gitignore | ||
.npmignore | ||
README.md | ||
package.json | ||
package-lock.json | ||
tsconfig.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
api.ts | ||
base.ts | ||
common.ts | ||
configuration.ts | ||
git_push.sh | ||
index.ts | ||
tsconfig.esm.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
7.3.0-SNAPSHOT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# Contributing | ||
|
||
|
||
This library cannot directly accept PRs from the public as it is generated from the OpenAPI specification | ||
for the Tremendous API. | ||
|
||
If you find an issue, please investigate whether it is a type problem with [our API reference][1] or a problem with the [typescript-axios][2] generator. Then open an issue and we will investigate further. | ||
|
||
## Running Tests | ||
|
||
This library tests uses our [Sandbox environment][3], and depend on an API token and IDs for some seed | ||
resources. They are executed via GitHub actions and don't need to be executed locally by contributors. | ||
|
||
[1]: https://developers.tremendous.com/reference | ||
[2]: https://github.com/OpenAPITools/openapi-generator/blob/master/docs/generators/typescript-axios.md | ||
[3]: https://developers.tremendous.com/docs/sandbox-environment |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
The MIT License | ||
|
||
Copyright (c) 2019 Tremendous, Inc. <[email protected]> | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
A node.js client library for the [Tremendous API][1]. | ||
|
||
## Installation | ||
|
||
```console | ||
$ npm install tremendous | ||
``` | ||
|
||
## Getting started | ||
|
||
All API requests require an access token. A sandbox access token is assigned upon signup through the [Tremendous Sandbox Environment][2]. Once you are ready to move to production, you will be assigned a production access token. | ||
|
||
### Authentication | ||
## Getting started | ||
|
||
All endpoints require a valid `access_token` for authentication. Attach them via the configuration. | ||
|
||
```typescript | ||
import { Configuration, Environments } from "tremendous"; | ||
|
||
const configuration = new Configuration({ | ||
basePath: Environments.testflight, | ||
accessToken: "YOUR-TESTFLIGHT-TOKEN", | ||
}); | ||
``` | ||
|
||
## Examples | ||
|
||
Submitting an order: | ||
|
||
```typescript | ||
import { OrdersApi, CreateOrderRequest } from "tremendous"; | ||
|
||
const orders = new OrdersApi(configuration); | ||
const params: CreateOrderRequest = { | ||
payment: { | ||
funding_source_id: "[FUNDING SOURCE ID HERE]", | ||
}, | ||
reward: | ||
{ | ||
delivery: { | ||
method: "EMAIL" | ||
}, | ||
recipient: { | ||
name: "Recipient Name", | ||
email: "recipient@domain" | ||
}, | ||
value: { | ||
denomination: 5.0, | ||
currency_code: "USD", | ||
}, | ||
campaign_id: "[CAMPAIGN_ID]", | ||
} | ||
}; | ||
|
||
const response = await orders.createOrder(params); | ||
console.log(`Order created! ID: ${response.order.id}`); | ||
``` | ||
|
||
Listing products: | ||
|
||
```typescript | ||
import { ProductsApi } from "tremendous"; | ||
|
||
const client = new ProductsApi(configuration); | ||
|
||
const response = await client.listProducts(); | ||
|
||
response.data.products.forEach(product => { /* */ }); | ||
``` | ||
|
||
[1]: https://tremendous.com/docs | ||
[2]: https://testflight.tremendous.com/rewards | ||
[3]: https://tremendous.com/docs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
## Step 1 - How to re-generate the SDK | ||
|
||
The source code from this repo is generated using [OpenAPI generator][1] and the Open API specification for the Tremendous API, available to Tremendous engineers. | ||
|
||
```console | ||
# generate a fresh Open API spec file | ||
cd core && bin/openapi-bundle | ||
|
||
# generate new `.ts` files and compile them into `./dist` | ||
cd tremendous-node-spike && bin/generate [PATH TO YML] && npm run build | ||
``` | ||
|
||
## Step 2 - Update the version on `package.json` | ||
|
||
Bump the version on `package.json` manually following [Semantic Versioning][2] practices - most changes here should be backwards compatible and deserve a MINOR version update | ||
|
||
## Step 3 - Publish a new release on GitHub | ||
|
||
The [publish.yml](.github/workflows/publish.yml) workflow is responsible for publishing the package to NPM when a new release is published on GitHub. | ||
|
||
|
||
[1]: https://openapi-generator.tech | ||
[2]: https://semver.org |
Oops, something went wrong.