Skip to content

Commit

Permalink
import new repo
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasmazza committed Mar 4, 2024
0 parents commit 44657ab
Show file tree
Hide file tree
Showing 44 changed files with 21,847 additions and 0 deletions.
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.github/workflows @tremendous-rewards/platform
11 changes: 11 additions & 0 deletions .github/dependabot.yml
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"
19 changes: 19 additions & 0 deletions .github/workflows/publish.yml
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-rewards/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 }}
28 changes: 28 additions & 0 deletions .github/workflows/test.yml
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-rewards/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 }}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/node_modules/
/npm-debug.log
8 changes: 8 additions & 0 deletions .npmignore
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*
30 changes: 30 additions & 0 deletions .openapi-generator-ignore
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
7 changes: 7 additions & 0 deletions .openapi-generator/FILES
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
1 change: 1 addition & 0 deletions .openapi-generator/VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
7.3.0-SNAPSHOT
16 changes: 16 additions & 0 deletions CONTRIBUTING.md
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
21 changes: 21 additions & 0 deletions LICENSE
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.
113 changes: 113 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
A node.js client library for the [Tremendous API][docs].

> [!NOTE]
> This branch includes the v3 version of the Tremendous Node.JS client, a new version based
> on our [API schema][ref] docs. If you are using the v2 versions, please check our
> [`UPGRADING`](UPGRADING.md) guide
## 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][docs]. Once you are ready to move to production, you will be assigned a production access token.

### Authentication
## Getting started

All endpoints require a `Configuration` object with a `basePath` and an `accessToken` for either your
Production or Sandbox account:

```typescript
import { Configuration, Environments } from "tremendous";

// when you are testing your code with the sandbox environment:
const configuration = new Configuration({
basePath: Environments.testflight,
accessToken: "YOUR-TESTFLIGHT-TOKEN",
});

// when you are ready to use the API:
const configuration = new Configuration({
basePath: Environments.production,
accessToken: "YOUR-PRODUCTION-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 { data } = await orders.createOrder(params);
console.log(`Order created! ID: ${data.order.id}`);
```

Retrieving an Order and a Reward

```typescript
import { OrdersApi, RewardsApi } from "tremendous";

const orders = new OrdersApi(configuration);
const rewards = new RewardsApi(configuration);

const { order } = await (orders.getOrder("[ORDER_ID]")).data;
const { reward } = await (rewards.getReward("[REWARD_ID]")).data;

console.log(`The order status is ${order.status}`);
console.log(`The reward was delivered to ${reward.recipient.email}`);
```

Listing products:

```typescript
import { ProductsApi } from "tremendous";

const client = new ProductsApi(configuration);

const { data } = await client.listProducts();

data.products.forEach(product => { /* */ });
```

Listing funding sources:

```typescript
import { FundingSourcesAPI } from "tremendous";

const client = new FundingSourcesAPI(configuration);

const { data } = await client.listFundingSources();

data.fundingSources.forEach(product => { /* */ });
```

[ref]: https://developers.tremendous.com/reference
[docs]: https://tremendous.com/docs
23 changes: 23 additions & 0 deletions RELEASING.md
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
Loading

0 comments on commit 44657ab

Please sign in to comment.