@unicsmcr/unics_social_api_client
Advanced tools
Comparing version 0.0.7 to 0.0.8
@@ -1,2 +0,2 @@ | ||
import { RegisterData, AuthenticateData, APIUser, ProcessedAPIEvent, EventCreationData, EventEditData, GetMessageData, ProcessedAPIMessage, APIMessage, APIDMChannel, ProfileUploadData } from './types/api'; | ||
import { RegisterData, AuthenticateData, APIUser, APIEvent, EventCreationData, EventEditData, GetMessageData, APIMessage, APIDMChannel, ProfileUploadData, APIEventChannel } from './types/api'; | ||
import { AxiosResponse } from 'axios'; | ||
@@ -26,9 +26,11 @@ import { GatewayClient } from './gateway'; | ||
editProfile(data: ProfileUploadData): Promise<APIUser>; | ||
getEvents(): Promise<ProcessedAPIEvent[]>; | ||
createEvent(data: EventCreationData): Promise<ProcessedAPIEvent>; | ||
editEvent(data: EventEditData): Promise<ProcessedAPIEvent>; | ||
getMessage(data: GetMessageData): Promise<ProcessedAPIMessage>; | ||
getMessages(channelID: string): Promise<ProcessedAPIMessage[]>; | ||
createMessage(data: Pick<APIMessage, 'content' | 'channelID'>): Promise<ProcessedAPIMessage>; | ||
getEvents(): Promise<APIEvent[]>; | ||
createEvent(data: EventCreationData): Promise<APIEvent>; | ||
editEvent(data: EventEditData): Promise<APIEvent>; | ||
getChannels(): Promise<(APIDMChannel | APIEventChannel)[]>; | ||
createDMChannel(userID: string): Promise<APIDMChannel>; | ||
getMessage(data: GetMessageData): Promise<APIMessage>; | ||
getMessages(channelID: string): Promise<APIMessage[]>; | ||
createMessage(data: Pick<APIMessage, 'content' | 'channelID'>): Promise<APIMessage>; | ||
deleteMessage(data: GetMessageData): Promise<void>; | ||
} |
@@ -164,2 +164,43 @@ "use strict"; | ||
/* | ||
Channel Routes | ||
*/ | ||
async getChannels() { | ||
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) | ||
} | ||
}; | ||
}); | ||
} | ||
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) | ||
} | ||
}; | ||
} | ||
/* | ||
Message Routes | ||
@@ -166,0 +207,0 @@ */ |
@@ -79,3 +79,3 @@ export declare enum APIAccountStatus { | ||
} | ||
export interface APIEvent { | ||
export interface RawAPIEvent { | ||
id: string; | ||
@@ -90,3 +90,3 @@ title: string; | ||
} | ||
export interface ProcessedAPIEvent { | ||
export interface APIEvent { | ||
id: string; | ||
@@ -100,3 +100,3 @@ title: string; | ||
} | ||
export interface APIMessage { | ||
export interface RawAPIMessage { | ||
id: string; | ||
@@ -108,3 +108,3 @@ channelID: string; | ||
} | ||
export interface ProcessedAPIMessage { | ||
export interface APIMessage { | ||
id: string; | ||
@@ -116,5 +116,14 @@ channelID: string; | ||
} | ||
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 { | ||
@@ -124,5 +133,29 @@ event: APIEvent; | ||
} | ||
export interface RawAPIVideoIntegration { | ||
id: string; | ||
creationTime: string; | ||
endTime: string; | ||
users?: { | ||
id: string; | ||
accessToken: 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 { | ||
users: string[]; | ||
type: 'dm'; | ||
video?: APIVideoIntegration; | ||
} |
{ | ||
"name": "@unicsmcr/unics_social_api_client", | ||
"version": "0.0.7", | ||
"version": "0.0.8", | ||
"description": "networking for CS students at the University of Manchester", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
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
30246
709