@unicsmcr/unics_social_api_client
Advanced tools
Comparing version 0.0.1 to 0.0.2
@@ -1,2 +0,2 @@ | ||
import { RegisterData, AuthenticateData, APIUser, ProfileData, ProcessedAPIEvent, EventCreationData, EventEditData, GetMessageData, ProcessedAPIMessage, APIMessage, APIDMChannel } from './types/api'; | ||
import { RegisterData, AuthenticateData, APIUser, ProcessedAPIEvent, EventCreationData, EventEditData, GetMessageData, ProcessedAPIMessage, APIMessage, APIDMChannel, ProfileUploadData } from './types/api'; | ||
import { AxiosResponse } from 'axios'; | ||
@@ -24,3 +24,3 @@ import { GatewayClient } from './gateway'; | ||
getMe(): Promise<APIUser>; | ||
editProfile(data: ProfileData): Promise<APIUser>; | ||
editProfile(data: ProfileUploadData): Promise<APIUser>; | ||
getEvents(): Promise<ProcessedAPIEvent[]>; | ||
@@ -27,0 +27,0 @@ createEvent(data: EventCreationData): Promise<ProcessedAPIEvent>; |
@@ -19,2 +19,3 @@ "use strict"; | ||
const gateway_1 = require("./gateway"); | ||
const form_data_1 = __importDefault(require("form-data")); | ||
__exportStar(require("./types/"), exports); | ||
@@ -68,3 +69,15 @@ class APIClient { | ||
async editProfile(data) { | ||
const response = await axios_1.default.put(`${this.apiBase}/users/@me/profile`, data, this.baseConfig); | ||
const formData = new form_data_1.default(); | ||
const props = ['avatar', 'course', 'yearOfStudy', 'instagram', 'facebook', 'twitter']; | ||
for (const key of props) { | ||
if (data.hasOwnProperty(key)) | ||
formData.append(key, data[key]); | ||
} | ||
const response = await axios_1.default.put(`${this.apiBase}/users/@me/profile`, formData, { | ||
...this.baseConfig, | ||
headers: { | ||
...this.baseConfig.headers, | ||
'Content-Type': `multipart/form-data; boundary=${formData.getBoundary()}` | ||
} | ||
}); | ||
return response.data.user; | ||
@@ -71,0 +84,0 @@ } |
@@ -20,6 +20,14 @@ export declare enum APIAccountStatus { | ||
} | ||
export interface ProfileUploadData { | ||
course?: string; | ||
yearOfStudy?: string; | ||
avatar?: File | 'false'; | ||
instagram?: string; | ||
facebook?: string; | ||
twitter?: string; | ||
} | ||
export interface ProfileData { | ||
course?: string; | ||
yearOfStudy?: string; | ||
profilePicture?: string; | ||
avatar?: string; | ||
instagram?: string; | ||
@@ -52,10 +60,3 @@ facebook?: string; | ||
accountType: APIAccountType; | ||
profile?: { | ||
course: string; | ||
yearOfStudy: number; | ||
profilePicture?: string; | ||
instagram?: string; | ||
facebook?: string; | ||
twitter?: string; | ||
}; | ||
profile?: ProfileData; | ||
} | ||
@@ -62,0 +63,0 @@ export interface APIEvent { |
{ | ||
"name": "@unicsmcr/unics_social_api_client", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"description": "networking for CS students at the University of Manchester", | ||
@@ -70,9 +70,10 @@ "main": "dist/index.js", | ||
"axios": "^0.19.2", | ||
"form-data": "^3.0.0", | ||
"ws": "^7.3.1" | ||
}, | ||
"files": [ | ||
"dist", | ||
"LICENSE", | ||
"README.md" | ||
"dist", | ||
"LICENSE", | ||
"README.md" | ||
] | ||
} |
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
22461
489
3
+ Addedform-data@^3.0.0
+ Addedasynckit@0.4.0(transitive)
+ Addedcombined-stream@1.0.8(transitive)
+ Addeddelayed-stream@1.0.0(transitive)
+ Addedform-data@3.0.2(transitive)
+ Addedmime-db@1.52.0(transitive)
+ Addedmime-types@2.1.35(transitive)