...
 
Commits (2)
BASE_URL='http://standup-bot-rest.lndo.site:8000/'
DEFAULT_FORMAT='hal_json'
DEFAULT_FORMAT='json'
ENGINE_API_KEY=APOLLO_ENGINE_API_KEY
DRUPAL_ADMIN_USERNAME='foobar'
DRUPAL_ADMIN_PASSWORD='barfoo'
ATLASSIAN_ACCESS_TOKEN=
TEMPO_API_URL=https://api.tempo.io/core/3
JIRA_ACCOUNT_ID=
const { RESTDataSource } = require('apollo-datasource-rest');
class JiraTempo extends RESTDataSource {
constructor() {
super();
this.baseURL = process.env.TEMPO_API_URL;
}
async create({input}) {
let body = {
"issueKey": input.issueKey,
"timeSpentSeconds": input.timeSpentSeconds,
"billableSeconds": input.timeSpentSeconds,
"startDate": input.startDate,
"startTime": input.startTime,
"description": input.description,
"authorAccountId": process.env.JIRA_ACCOUNT_ID,
};
const response = await this.post('worklogs', body, {
headers: {
"Authorization": `Bearer ${process.env.ATLASSIAN_ACCESS_TOKEN}`,
"Content-Type": "application/json",
},
});
return (response !== null && typeof response === 'object') ? JiraTempo.worklogReducer(response) : [];
}
static worklogReducer(worklog) {
return {
id: worklog.tempoWorklogId,
jiraWorklogId: worklog.jiraWorklogId,
};
}
}
module.exports = JiraTempo;
......@@ -4,6 +4,7 @@ const resolvers = require('./resolvers');
const QuestionAPI = require('./datasources/question');
const StandUpNotesAPI = require('./datasources/standUpNotes');
const JiraTempoAPI = require('./datasources/jiraTempo');
require('dotenv').config();
......@@ -13,6 +14,7 @@ const server = new ApolloServer({
dataSources: () => ({
questionAPI: new QuestionAPI(),
standUpNotesAPI: new StandUpNotesAPI(),
jiraTempoAPI: new JiraTempoAPI(),
}),
introspection: true,
playground: true,
......
......@@ -4,5 +4,6 @@ module.exports = {
},
Mutation: {
createStandUpNote: (_, {input}, {dataSources}) => dataSources.standUpNotesAPI.create({input}),
createWorklog: (_, {input}, {dataSources}) => dataSources.jiraTempoAPI.create({input}),
}
};
......@@ -7,6 +7,7 @@ const typeDefs = gql`
type Mutation {
createStandUpNote(input: StandUpNoteInput!): StandUpNotes!
createWorklog(input: NewWorklogInput!): Worklog!
}
type Question {
......@@ -22,16 +23,6 @@ const typeDefs = gql`
participants: [User!]!
}
input NewStandUp {
author_id: ID!
title: String!
frequency: String!
channelID: Int!
participant_ids: [ID!]!
standUpTime: Int!
standUpReportTime: Int!
}
type StandUpMeeting {
id: ID!
standUp: StandUp!
......@@ -54,11 +45,24 @@ const typeDefs = gql`
name: String!
}
type Worklog {
id: Int!
jiraWorklogId: Int!
}
input StandUpNoteInput {
questionId: ID!
standUpMeetingId: ID!
notes: String!
}
input NewWorklogInput {
issueKey: String!
timeSpentSeconds: Int!
startDate: String!
startTime: String!
description: String
}
`;
module.exports = typeDefs;