added Alarms API

This commit is contained in:
Sean Macfarlane
2020-05-27 13:16:54 -04:00
parent e2c8c24642
commit 4cae83d9fb
3 changed files with 27 additions and 0 deletions

View File

@@ -163,4 +163,11 @@ export class API extends RESTDataSource {
}),
});
}
async getAllAlarms(customerId, cursor, limit) {
return this.get('portal/alarm/forCustomer', {
customerId,
paginationContext: buildPaginationContext(cursor, limit),
});
}
}

View File

@@ -57,6 +57,10 @@ const resolvers = {
getAllProfiles: async (_, { customerId }, { dataSources }) => {
return dataSources.api.getAllProfiles(customerId);
},
getAllAlarms: async (_, { customerId, cursor, limit }, { dataSources }) => {
return dataSources.api.getAllAlarms(customerId);
},
},
Mutation: {
authenticateUser: async (_, { email, password }, { dataSources }) => {

View File

@@ -32,6 +32,8 @@ const typeDefs = gql`
getProfile(id: Int!): Profile
deleteProfile(id: Int!): Profile
getAllProfiles(customerId: Int!): ProfilePagination
getAllAlarms(customerId: Int!, cursor: String, limit: Int): AlarmPagination
}
type PaginationContext {
@@ -112,6 +114,20 @@ const typeDefs = gql`
context: PaginationContext
}
type Alarm {
customerId: Int!
equipmentId: Int!
alarmCode: String!
severity: String!
lastModifiedTimestamp: String
details: JSONObject
}
type AlarmPagination {
items: [Alarm]
context: PaginationContext
}
type Mutation {
authenticateUser(email: String!, password: String!): Token
updateToken(refreshToken: String!): Token