Skip to content
This repository was archived by the owner on Mar 12, 2025. It is now read-only.

Commit 90c4360

Browse files
initial commit
0 parents  commit 90c4360

14 files changed

+5285
-0
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
node_modules
2+
.env

README.md

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
# Topcoder Submission API Review Types Wrapper
2+
3+
Wrapper library for Topcoder Submission API ReviewTypes endpoint
4+
5+
## How to use this Wrapper
6+
7+
1. Include the wrapper in package.json as follows
8+
9+
```bash
10+
"tc-submission-api-review-types-wrapper": "topcoder-platform/tc-submission-api-review-types-wrapper.git"
11+
```
12+
13+
2. Create an instance of this wrapper with the configuration variables listed below
14+
15+
```bash
16+
const reviewTypesApi = require('tc-submission-api-review-types-wrapper')
17+
const reviewTypesApiClient = reviewTypesApi(_.pick(config,
18+
['AUTH0_URL', 'AUTH0_AUDIENCE', 'TOKEN_CACHE_TIME',
19+
'AUTH0_CLIENT_ID', 'AUTH0_CLIENT_SECRET', 'SUBMISSION_API_URL',
20+
'AUTH0_PROXY_SERVER_URL']))
21+
```
22+
23+
**Configuration / Environment variables:**
24+
25+
- AUTH0_URL - the auth0 url
26+
- AUTH0_AUDIENCE - the auth0 audience
27+
- TOKEN_CACHE_TIME - (optional) the token cache time
28+
- AUTH0_CLIENT_ID - the auth0 client id, used as credential
29+
- AUTH0_CLIENT_SECRET - the auth0 client secret, used as credential
30+
- AUTH0_PROXY_SERVER_URL - (optional) the auth0 proxy server url
31+
- SUBMISSION_API_URL - Topcoder V5 Submission API URL. E.g. `https://api.topcoder-dev.com/v5`
32+
33+
3. Every function in this wrapper will return a promise, Handling promises is at the caller end. Call the functions with appropriate arguments
34+
35+
E.g.
36+
37+
```bash
38+
let reviewTypeId = '8f4e8b6a-0ad2-4ff6-ab19-afeb102ff3b4'
39+
40+
reviewTypesApiClient
41+
.createReviewType({ name: 'test-for-create', isActive: true })
42+
.then(result => console.log(result.body, result.status))
43+
.catch(err => console.log(err))
44+
45+
await reviewTypesApiClient.deleteReviewType(reviewTypeId)
46+
```
47+
48+
Refer `index.js` for the list of available wrapper functions
49+
50+
## Documentation for Review Types wrapper methods
51+
52+
All URIs are relative to **SUBMISSION_API_URL** configuration variable.
53+
54+
Method | HTTP request | Description
55+
------------- | ------------- | -------------
56+
[**searchReviewTypes**](docs/ReviewTypesApi.md#searchReviewTypes) | **GET** /reviewTypes | Search review types.
57+
[**headReviewTypes**](docs/ReviewTypesApi.md#headReviewTypes) | **HEAD** /reviewTypes | Same to search review types, but only response status and headers information return.
58+
[**createReviewType**](docs/ReviewTypesApi.md#createReviewType) | **POST** /reviewTypes | Create a review type.
59+
[**getReviewType**](docs/ReviewTypesApi.md#getReviewType) | **GET** /reviewTypes/{reviewTypeId} | Get the review type.
60+
[**headReviewType**](docs/ReviewTypesApi.md#headReviewType) | **HEAD** /reviewTypes/{reviewTypeId} | Same to get review type, but only response status and headers information return.
61+
[**updateReviewType**](docs/ReviewTypesApi.md#updateReviewType) | **PUT** /reviewTypes/{reviewTypeId} | Fully update review type.
62+
[**patchReviewType**](docs/ReviewTypesApi.md#patchReviewType) | **PATCH** /reviewTypes/{reviewTypeId} | Partially update review type.
63+
[**deleteReviewType**](docs/ReviewTypesApi.md#deleteReviewType) | **DELETE** /reviewTypes/{reviewTypeId} | Delete the review type.
64+
65+
## Authorization
66+
67+
Review Types wrapper internally generates a **JWT token using Auth0 credentials** and pass it in the `Authorization` header.
68+
69+
## Running tests
70+
71+
Following environment variables need to be set up before running the tests
72+
73+
```bash
74+
- TEST_AUTH0_URL
75+
- TEST_AUTH0_AUDIENCE
76+
- TEST_AUTH0_CLIENT_ID
77+
- TEST_AUTH0_CLIENT_SECRET
78+
- TEST_SUBMISSION_API_URL
79+
```
80+
81+
Refer to Step # 2 in [this section](#how-to-use-this-wrapper) to learn more about the configuration variables.
82+
83+
To run the tests alone, execute the command
84+
85+
```bash
86+
npm run test
87+
```
88+
89+
To run tests with coverage report, execute the command
90+
91+
```bash
92+
npm run cov
93+
```

Verification.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Topcoder Submission API Review Types Wrapper
2+
3+
## Step to run tests
4+
1. run `source env.sh` to initialize process environment
5+
2. run `npm run test` to run unit tests
6+
3. run `npm run cov` to run unit tests and generate coverage report
7+
8+
## Test Coverage Report
9+
10+
45 passing (2m)
11+
12+
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s |
13+
---------------------------------------------------|----------|----------|----------|----------|-------------------|
14+
All files | 98.33 | 84.62 | 100 | 98.33 | |
15+
tc-submission-api-review-types-wrapper | 100 | 100 | 100 | 100 | |
16+
index.js | 100 | 100 | 100 | 100 | |
17+
tc-submission-api-review-types-wrapper/src | 100 | 100 | 100 | 100 | |
18+
ReviewTypesApi.js | 100 | 100 | 100 | 100 | |
19+
tc-submission-api-review-types-wrapper/src/common | 96 | 81.82 | 100 | 96 | |
20+
helper.js | 96 | 81.82 | 100 | 96 | 63 |

docs/Criteria.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Criteria
2+
3+
## Properties
4+
Name | Type | Description | Notes
5+
------------ | ------------- | ------------- | -------------
6+
**page** | **Integer** | The page number. | Default value is 1
7+
**perPage** | **Integer** | The number of items to list per page. | Default value is 20
8+
**name** | **String** | The name filter for review types. |
9+
**isActive** | **Boolean** | The active boolean flag filter for review types. |

docs/ReviewType.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# ReviewType
2+
3+
## Properties
4+
Name | Type | Description | Notes
5+
------------ | ------------- | ------------- | -------------
6+
**id** | **String** | The review type id. |
7+
**name** | **String** | The review type name. |
8+
**isActive** | **Boolean** | The active boolean flag. |

docs/ReviewTypeData.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# ReviewTypeData
2+
3+
## Properties
4+
Name | Type | Description | Notes
5+
------------ | ------------- | ------------- | -------------
6+
**name** | **String** | The review type name. |
7+
**isActive** | **Boolean** | The active boolean flag. |

0 commit comments

Comments
 (0)