Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sync with direct project service #8

Closed
3 tasks
parthshah opened this issue Jul 18, 2016 · 4 comments
Closed
3 tasks

Sync with direct project service #8

parthshah opened this issue Jul 18, 2016 · 4 comments

Comments

@parthshah
Copy link
Contributor

  • Create direct project when a new project is successfully created
  • Add co-pilot when a co-pilot is added to a project
  • Sync billing account id with direct
@parthshah
Copy link
Contributor Author

I think this can be done as part of NodeJS event handling

@parthshah
Copy link
Contributor Author

@ajefts can you please provide api endpoints and sample request for each of these calls please

@ajefts
Copy link
Member

ajefts commented Aug 3, 2016

Here is the generated code from postman. The service is returning a 502 in dev. Do you remember how you had it setup?

Create Project:

var http = require("https");

var options = {
"method": "POST",
"hostname": "api.topcoder-dev.com",
"port": null,
"path": "/v3/direct/projects/",
"headers": {
"authorization": "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJyb2xlcyI6WyJhZG1pbmlzdHJhdG9yIiwiVG9wY29kZXIgVXNlciIsIkNvbm5lY3QgU3VwcG9ydCJdLCJpc3MiOiJodHRwczovL2FwaS50b3Bjb2Rlci1kZXYuY29tIiwiaGFuZGxlIjoiVG9ueUoiLCJleHAiOjE0NzAyNjA2NDAsInVzZXJJZCI6Ijg1NDc4OTkiLCJpYXQiOjE0NzAyNjAwNDAsImVtYWlsIjoidGplZnRzK2RldkB0b3Bjb2Rlci5jb20iLCJqdGkiOiJiOTdiYjVhZS1hMmVmLTQzMWUtYjM2OC0yZjZiYzAzZTFkMDIifQ.4pPi9u3UZN2jlqRKnzzqy9IMwotgqwEiTkzWdTAAh0M",
"cache-control": "no-cache",
"postman-token": "cf9afe9c-dee8-b6bd-ccfb-de528e06b262"
}
};

var req = http.request(options, function (res) {
var chunks = [];

res.on("data", function (chunk) {
chunks.push(chunk);
});

res.on("end", function () {
var body = Buffer.concat(chunks);
console.log(body.toString());
});
});

req.write("{\n "projectName": "Tony Test 1",\n "projectDescription": "test 1 description"\n}");
req.end();

Get Project:

var http = require("https");

var options = {
"method": "GET",
"hostname": "api.topcoder-dev.com",
"port": null,
"path": "/v3/direct/projects/7377",
"headers": {
"authorization": "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJyb2xlcyI6WyJhZG1pbmlzdHJhdG9yIiwiVG9wY29kZXIgVXNlciIsIkNvbm5lY3QgU3VwcG9ydCJdLCJpc3MiOiJodHRwczovL2FwaS50b3Bjb2Rlci1kZXYuY29tIiwiaGFuZGxlIjoiVG9ueUoiLCJleHAiOjE0NzAyNjA2NDAsInVzZXJJZCI6Ijg1NDc4OTkiLCJpYXQiOjE0NzAyNjAwNDAsImVtYWlsIjoidGplZnRzK2RldkB0b3Bjb2Rlci5jb20iLCJqdGkiOiJiOTdiYjVhZS1hMmVmLTQzMWUtYjM2OC0yZjZiYzAzZTFkMDIifQ.4pPi9u3UZN2jlqRKnzzqy9IMwotgqwEiTkzWdTAAh0M",
"cache-control": "no-cache",
"postman-token": "d71fc521-b22f-c0db-ef44-b65391b59f8c"
}
};

var req = http.request(options, function (res) {
var chunks = [];

res.on("data", function (chunk) {
chunks.push(chunk);
});

res.on("end", function () {
var body = Buffer.concat(chunks);
console.log(body.toString());
});
});

req.write("{\n "projectName": "Tony Test 1",\n "projectDescription": "test 1 description"\n}");
req.end();

Add Billing account to project:

var http = require("https");

var options = {
"method": "POST",
"hostname": "api.topcoder-dev.com",
"port": null,
"path": "/v3/direct/projects/1234/billingaccount",
"headers": {
"authorization": "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJyb2xlcyI6WyJhZG1pbmlzdHJhdG9yIiwiVG9wY29kZXIgVXNlciIsIkNvbm5lY3QgU3VwcG9ydCJdLCJpc3MiOiJodHRwczovL2FwaS50b3Bjb2Rlci1kZXYuY29tIiwiaGFuZGxlIjoiVG9ueUoiLCJleHAiOjE0NzAyNjA2NDAsInVzZXJJZCI6Ijg1NDc4OTkiLCJpYXQiOjE0NzAyNjAwNDAsImVtYWlsIjoidGplZnRzK2RldkB0b3Bjb2Rlci5jb20iLCJqdGkiOiJiOTdiYjVhZS1hMmVmLTQzMWUtYjM2OC0yZjZiYzAzZTFkMDIifQ.4pPi9u3UZN2jlqRKnzzqy9IMwotgqwEiTkzWdTAAh0M",
"cache-control": "no-cache",
"postman-token": "b5df9917-3d7c-7a04-8f92-0bced93182b1"
}
};

var req = http.request(options, function (res) {
var chunks = [];

res.on("data", function (chunk) {
chunks.push(chunk);
});

res.on("end", function () {
var body = Buffer.concat(chunks);
console.log(body.toString());
});
});

req.write("{\n "billingAccountID": 123456789\n}");
req.end();

Add Copilot to Project:

var http = require("https");

var options = {
"method": "POST",
"hostname": "api.topcoder-dev.com",
"port": null,
"path": "/v3/direct/projects/1234/copilot",
"headers": {
"authorization": "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJyb2xlcyI6WyJhZG1pbmlzdHJhdG9yIiwiVG9wY29kZXIgVXNlciIsIkNvbm5lY3QgU3VwcG9ydCJdLCJpc3MiOiJodHRwczovL2FwaS50b3Bjb2Rlci1kZXYuY29tIiwiaGFuZGxlIjoiVG9ueUoiLCJleHAiOjE0NzAyNjA2NDAsInVzZXJJZCI6Ijg1NDc4OTkiLCJpYXQiOjE0NzAyNjAwNDAsImVtYWlsIjoidGplZnRzK2RldkB0b3Bjb2Rlci5jb20iLCJqdGkiOiJiOTdiYjVhZS1hMmVmLTQzMWUtYjM2OC0yZjZiYzAzZTFkMDIifQ.4pPi9u3UZN2jlqRKnzzqy9IMwotgqwEiTkzWdTAAh0M",
"cache-control": "no-cache",
"postman-token": "82324a51-cab5-72be-6cea-f52bf167ed6e"
}
};

var req = http.request(options, function (res) {
var chunks = [];

res.on("data", function (chunk) {
chunks.push(chunk);
});

res.on("end", function () {
var body = Buffer.concat(chunks);
console.log(body.toString());
});
});

req.write("{\n "copilotUserId": 123456789\n}");
req.end();

@ajefts
Copy link
Member

ajefts commented Aug 3, 2016

@parthshah

parthshah pushed a commit that referenced this issue Aug 15, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants