@unicsmcr/unics_social_api_client
Advanced tools
Comparing version 0.0.8 to 0.0.9
@@ -77,4 +77,5 @@ "use strict"; | ||
} | ||
getMe() { | ||
return this.getUser('@me'); | ||
async getMe() { | ||
const response = await axios_1.default.get(`${this.apiBase}/users/@me`, this.baseConfig); | ||
return response.data.user; | ||
} | ||
@@ -106,7 +107,3 @@ async editProfile(data) { | ||
const response = await axios_1.default.get(`${this.apiBase}/users/@me/profile`, this.baseConfig); | ||
return response.data.events.map(event => ({ | ||
...event, | ||
startTime: new Date(event.startTime), | ||
endTime: new Date(event.endTime) | ||
})); | ||
return response.data.events; | ||
} | ||
@@ -133,7 +130,3 @@ async createEvent(data) { | ||
}); | ||
return { | ||
...response.data.event, | ||
startTime: new Date(response.data.event.startTime), | ||
endTime: new Date(response.data.event.endTime) | ||
}; | ||
return response.data.event; | ||
} | ||
@@ -160,7 +153,3 @@ async editEvent(data) { | ||
}); | ||
return { | ||
...response.data.event, | ||
startTime: new Date(response.data.event.startTime), | ||
endTime: new Date(response.data.event.endTime) | ||
}; | ||
return response.data.event; | ||
} | ||
@@ -172,37 +161,7 @@ /* | ||
const response = await axios_1.default.get(`${this.apiBase}/channels`, this.baseConfig); | ||
return response.data.channels.map(channel => { | ||
if (channel.type === 'dm') { | ||
return { | ||
...channel, | ||
lastUpdated: new Date(channel.lastUpdated), | ||
video: channel.video && { | ||
...channel.video, | ||
creationTime: new Date(channel.video.creationTime), | ||
endTime: new Date(channel.video.endTime) | ||
} | ||
}; | ||
} | ||
return { | ||
...channel, | ||
lastUpdated: new Date(channel.lastUpdated), | ||
event: { | ||
...channel.event, | ||
startTime: new Date(channel.event.startTime), | ||
endTime: new Date(channel.event.endTime) | ||
} | ||
}; | ||
}); | ||
return response.data.channels; | ||
} | ||
async createDMChannel(userID) { | ||
const response = await axios_1.default.post(`${this.apiBase}/users/${userID}/channel`, this.baseConfig); | ||
const channel = response.data.channel; | ||
return { | ||
...channel, | ||
lastUpdated: new Date(channel.lastUpdated), | ||
video: channel.video && { | ||
...channel.video, | ||
creationTime: new Date(channel.video.creationTime), | ||
endTime: new Date(channel.video.endTime) | ||
} | ||
}; | ||
return response.data.channel; | ||
} | ||
@@ -214,20 +173,11 @@ /* | ||
const response = await axios_1.default.get(`${this.apiBase}/channels/${data.channelID}/messages/${data.messageID}`, this.baseConfig); | ||
return { | ||
...response.data.message, | ||
time: new Date(response.data.message.time) | ||
}; | ||
return response.data.message; | ||
} | ||
async getMessages(channelID) { | ||
const response = await axios_1.default.get(`${this.apiBase}/channels/${channelID}`, this.baseConfig); | ||
return response.data.messages.map(message => ({ | ||
...message, | ||
time: new Date(message.time) | ||
})); | ||
const response = await axios_1.default.get(`${this.apiBase}/channels/${channelID}/messages`, this.baseConfig); | ||
return response.data.messages; | ||
} | ||
async createMessage(data) { | ||
const response = await axios_1.default.post(`${this.apiBase}/channels/${data.channelID}/messages`, { content: data.content }, this.baseConfig); | ||
return { | ||
...response.data.message, | ||
time: new Date(response.data.message.time) | ||
}; | ||
return response.data.message; | ||
} | ||
@@ -234,0 +184,0 @@ async deleteMessage(data) { |
@@ -79,3 +79,6 @@ export declare enum APIAccountStatus { | ||
} | ||
export interface RawAPIEvent { | ||
export interface APIPrivateUser extends APIUser { | ||
email: string; | ||
} | ||
export interface APIEvent { | ||
id: string; | ||
@@ -90,14 +93,5 @@ title: string; | ||
} | ||
export interface APIEvent { | ||
export interface APIMessage { | ||
id: string; | ||
title: string; | ||
startTime: Date; | ||
endTime: Date; | ||
description: string; | ||
external: string; | ||
channelID: string; | ||
} | ||
export interface RawAPIMessage { | ||
id: string; | ||
channelID: string; | ||
authorID: string; | ||
@@ -107,21 +101,6 @@ content: string; | ||
} | ||
export interface APIMessage { | ||
export interface APIChannel { | ||
id: string; | ||
channelID: string; | ||
authorID: string; | ||
content: string; | ||
time: Date; | ||
} | ||
export interface RawAPIChannel { | ||
id: string; | ||
lastUpdated: string; | ||
} | ||
export interface APIChannel { | ||
id: string; | ||
lastUpdated: Date; | ||
} | ||
export interface RawAPIEventChannel extends RawAPIChannel { | ||
event: RawAPIEvent; | ||
type: 'event'; | ||
} | ||
export interface APIEventChannel extends APIChannel { | ||
@@ -131,3 +110,3 @@ event: APIEvent; | ||
} | ||
export interface RawAPIVideoIntegration { | ||
export interface APIVideoIntegration { | ||
id: string; | ||
@@ -141,16 +120,2 @@ creationTime: string; | ||
} | ||
export interface APIVideoIntegration { | ||
id: string; | ||
creationTime: Date; | ||
endTime: Date; | ||
users?: { | ||
id: string; | ||
accessToken: string; | ||
}[]; | ||
} | ||
export interface RawAPIDMChannel extends RawAPIChannel { | ||
users: string[]; | ||
type: 'dm'; | ||
video?: RawAPIVideoIntegration; | ||
} | ||
export interface APIDMChannel extends APIChannel { | ||
@@ -157,0 +122,0 @@ users: string[]; |
{ | ||
"name": "@unicsmcr/unics_social_api_client", | ||
"version": "0.0.8", | ||
"version": "0.0.9", | ||
"description": "networking for CS students at the University of Manchester", | ||
@@ -39,4 +39,5 @@ "main": "dist/index.js", | ||
"@unicsmcr/eslint-config": "^0.0.2", | ||
"axios-mock-adapter": "^1.18.2", | ||
"eslint": "^7.6.0", | ||
"jest": "^26.2.2", | ||
"jest": "^26.4.2", | ||
"ts-jest": "^26.1.4", | ||
@@ -66,3 +67,4 @@ "typescript": "^3.9.7" | ||
"collectCoverageFrom": [ | ||
"src/**/*.ts" | ||
"src/**/*.ts", | ||
"!src/__tests__/**/*" | ||
] | ||
@@ -72,2 +74,3 @@ }, | ||
"axios": "^0.19.2", | ||
"axios-mock-adapter": "^1.18.2", | ||
"form-data": "^3.0.0", | ||
@@ -74,0 +77,0 @@ "ws": "^7.3.1" |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
27886
4
11
624
+ Addedaxios-mock-adapter@^1.18.2
+ Addedaxios-mock-adapter@1.22.0(transitive)
+ Addedfast-deep-equal@3.1.3(transitive)
+ Addedis-buffer@2.0.5(transitive)