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

TC API - Get Round Term API #382

Merged
merged 1 commit into from
Oct 26, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 66 additions & 0 deletions actions/srmRoundComponentsAndTerms.js
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,47 @@ var setRoundTerms = function (api, connection, dbConnectionMap, next) {
});
};

/**
* Gets round terms.
*
* @param api the api instance.
* @param connection the connection instance
* @param dbConnectionMap the database connection map
* @param next the callback method
*/
var getRoundTerms = function (api, connection, dbConnectionMap, next) {
var helper = api.helper,
sqlParams = {},
roundId = Number(connection.params.roundId),
roundTermsContent = '';

async.waterfall([
function (cb) {
cb(helper.checkAdmin(connection, 'Authorized information needed.', 'Admin access only.'));
}, function (cb) {
cb(helper.checkIdParameter(roundId, "roundId"));
}, function (cb) {
sqlParams.round_id = roundId;
api.dataAccess.executeQuery("get_round_terms", sqlParams, dbConnectionMap, cb);
}, function (results, cb) {
if (!results || results.length === 0) {
var error = new IllegalArgumentError("The round terms can't be found with such roundId = " + roundId);
cb(error);
} else {
roundTermsContent = results[0].terms_content;
cb();
}
}
], function (err) {
if (err) {
helper.handleError(api, connection, err);
} else {
connection.response = {"roundTermsContent": roundTermsContent};
}
next(connection, true);
});
};

/**
* The API for Set Round Components.
*/
Expand Down Expand Up @@ -349,3 +390,28 @@ exports.setRoundTerms = {
}
}
};

/**
* The API for Get Round Terms.
*/
exports.getRoundTerms = {
name: "getRoundTerms",
description: "Get Round Terms",
inputs: {
required: ['roundId'],
optional: []
},
blockedConnectionTypes: [],
outputExample: {},
version: 'v2',
transaction: 'read',
databases: ["informixoltp"],
run: function (api, connection, next) {
if (connection.dbConnectionMap) {
api.log("Execute getRoundTerms#run", 'debug');
getRoundTerms(api, connection, connection.dbConnectionMap, next);
} else {
api.helper.handleNoConnection(api, connection, next);
}
}
};
51 changes: 51 additions & 0 deletions apiary.apib
Original file line number Diff line number Diff line change
Expand Up @@ -9107,6 +9107,57 @@ Request
"description":"Servers are up but overloaded. Try again later."
}

## Get round terms of use [/data/srm/rounds/:roundId/terms]
### Get round terms of use by round id [GET]

- Only when jwt passed can we get the round terms of use.

+ Parameters
+ roundId (required, number, `13672`) ... The id of round

+ Request

+ Headers

Authorization : Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJhZHwxMzI0NTYiLCJleHAiOjEzOTM3MDM1NzEsImF1ZCI6InRvcGNvZGVyIiwiaWF0IjoxMzkzNjQzNTcxfQ.F2iohKp2nwjQeGqrBD1wn42GJUD0r28aGjhDle7KujA

+ Response 200 (application/json)

{
"roundTermsContent": "The round terms content..."
}
+ Response 401 (application/json)

{
"name":"Unauthorized",
"value":"401",
"description":"Authentication credentials were missing or incorrect."
}

+ Response 404 (application/json)

{
"name":"Not Found",
"value":"404",
"description":"This message will explain why the URI requested is invalid or the resource does not exist."
}

+ Response 500 (application/json)

{
"name":"Internal Server Error",
"value":"500",
"description":"Unknown server error. Please contact support."
}

+ Response 503 (application/json)

{
"name":"Service Unavailable",
"value":"503",
"description":"Servers are up but overloaded. Try again later."
}

## Agree terms of use [/terms/{termsOfUseId}/agree]
### Agree terms of use by id [POST]

Expand Down
Loading