|
| 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 | +``` |
0 commit comments