/* * --------------------------------------------------------- * Copyright(C) Microsoft Corporation. All rights reserved. * --------------------------------------------------------- * * --------------------------------------------------------- * Generated file, DO NOT EDIT * --------------------------------------------------------- */ // Licensed under the MIT license. See LICENSE file in the project root for full license information. import * as restm from 'typed-rest-client/RestClient'; import * as httpm from 'typed-rest-client/HttpClient'; import vsom = require('./VsoClient'); import basem = require('./ClientApiBases'); import serm = require('./Serialization'); import VsoBaseInterfaces = require('./interfaces/common/VsoBaseInterfaces'); import ProfileInterfaces = require("./interfaces/ProfileInterfaces"); import VSSInterfaces = require("./interfaces/common/VSSInterfaces"); export interface IProfileApi extends basem.ClientApiBase { deleteProfileAttribute(id: string, descriptor: string): Promise; getProfileAttribute(id: string, descriptor: string): Promise; getProfileAttributes(id: string, partition: string, modifiedSince?: string, modifiedAfterRevision?: string, withCoreAttributes?: boolean, coreAttributes?: string): Promise; setProfileAttribute(container: any, id: string, descriptor: string): Promise; setProfileAttributes(attributesCollection: VSSInterfaces.VssJsonCollectionWrapperV[]>, id: string): Promise; getAvatar(id: string, size?: string, format?: string): Promise; getAvatarPreview(container: any, id: string, size?: string, format?: string, displayName?: string): Promise; resetAvatar(id: string): Promise; setAvatar(container: any, id: string): Promise; getGeoRegion(ipaddress: string): Promise; createProfile(createProfileContext: ProfileInterfaces.CreateProfileContext, autoCreate?: boolean): Promise; getProfile(id: string, details?: boolean, withAttributes?: boolean, partition?: string, coreAttributes?: string, forceRefresh?: boolean): Promise; updateProfile(profile: ProfileInterfaces.Profile, id: string): Promise; getRegions(): Promise; getSupportedLcids(): Promise; getUserDefaults(includeAvatar?: boolean): Promise; refreshUserDefaults(id: string): Promise; } export class ProfileApi extends basem.ClientApiBase implements IProfileApi { constructor(baseUrl: string, handlers: VsoBaseInterfaces.IRequestHandler[], options?: VsoBaseInterfaces.IRequestOptions) { super(baseUrl, handlers, 'node-Profile-api', options); } /** * @param {string} id * @param {string} descriptor */ public async deleteProfileAttribute( id: string, descriptor: string ): Promise { return new Promise(async (resolve, reject) => { let routeValues: any = { id: id }; let queryValues: any = { descriptor: descriptor, }; try { let verData: vsom.ClientVersioningData = await this.vsoClient.getVersioningData( "3.2-preview.2", "Profile", "1392b6ac-d511-492e-af5b-2263e5545a5d", routeValues, queryValues); let url: string = verData.requestUrl; let options: restm.IRequestOptions = this.createRequestOptions('application/json', verData.apiVersion); let res: restm.IRestResponse; res = await this.rest.del(url, options); let ret = this.formatResponse(res.result, null, false); resolve(ret); } catch (err) { reject(err); } }); } /** * @param {string} id * @param {string} descriptor */ public async getProfileAttribute( id: string, descriptor: string ): Promise { return new Promise(async (resolve, reject) => { let routeValues: any = { id: id }; let queryValues: any = { descriptor: descriptor, }; try { let verData: vsom.ClientVersioningData = await this.vsoClient.getVersioningData( "3.2-preview.2", "Profile", "1392b6ac-d511-492e-af5b-2263e5545a5d", routeValues, queryValues); let url: string = verData.requestUrl; let options: restm.IRequestOptions = this.createRequestOptions('application/json', verData.apiVersion); let res: restm.IRestResponse; res = await this.rest.get(url, options); let ret = this.formatResponse(res.result, ProfileInterfaces.TypeInfo.ProfileAttribute, false); resolve(ret); } catch (err) { reject(err); } }); } /** * @param {string} id * @param {string} partition * @param {string} modifiedSince * @param {string} modifiedAfterRevision * @param {boolean} withCoreAttributes * @param {string} coreAttributes */ public async getProfileAttributes( id: string, partition: string, modifiedSince?: string, modifiedAfterRevision?: string, withCoreAttributes?: boolean, coreAttributes?: string ): Promise { return new Promise(async (resolve, reject) => { let routeValues: any = { id: id }; let queryValues: any = { partition: partition, modifiedSince: modifiedSince, modifiedAfterRevision: modifiedAfterRevision, withCoreAttributes: withCoreAttributes, coreAttributes: coreAttributes, }; try { let verData: vsom.ClientVersioningData = await this.vsoClient.getVersioningData( "3.2-preview.2", "Profile", "1392b6ac-d511-492e-af5b-2263e5545a5d", routeValues, queryValues); let url: string = verData.requestUrl; let options: restm.IRequestOptions = this.createRequestOptions('application/json', verData.apiVersion); let res: restm.IRestResponse; res = await this.rest.get(url, options); let ret = this.formatResponse(res.result, ProfileInterfaces.TypeInfo.ProfileAttribute, true); resolve(ret); } catch (err) { reject(err); } }); } /** * @param {any} container * @param {string} id * @param {string} descriptor */ public async setProfileAttribute( container: any, id: string, descriptor: string ): Promise { return new Promise(async (resolve, reject) => { let routeValues: any = { id: id }; let queryValues: any = { descriptor: descriptor, }; try { let verData: vsom.ClientVersioningData = await this.vsoClient.getVersioningData( "3.2-preview.2", "Profile", "1392b6ac-d511-492e-af5b-2263e5545a5d", routeValues, queryValues); let url: string = verData.requestUrl; let options: restm.IRequestOptions = this.createRequestOptions('application/json', verData.apiVersion); let res: restm.IRestResponse; res = await this.rest.replace(url, container, options); let ret = this.formatResponse(res.result, null, false); resolve(ret); } catch (err) { reject(err); } }); } /** * @param {VSSInterfaces.VssJsonCollectionWrapperV[]>} attributesCollection * @param {string} id */ public async setProfileAttributes( attributesCollection: VSSInterfaces.VssJsonCollectionWrapperV[]>, id: string ): Promise { return new Promise(async (resolve, reject) => { let routeValues: any = { id: id }; try { let verData: vsom.ClientVersioningData = await this.vsoClient.getVersioningData( "3.2-preview.2", "Profile", "1392b6ac-d511-492e-af5b-2263e5545a5d", routeValues); let url: string = verData.requestUrl; let options: restm.IRequestOptions = this.createRequestOptions('application/json', verData.apiVersion); let res: restm.IRestResponse; res = await this.rest.update(url, attributesCollection, options); let ret = this.formatResponse(res.result, null, false); resolve(ret); } catch (err) { reject(err); } }); } /** * @param {string} id * @param {string} size * @param {string} format */ public async getAvatar( id: string, size?: string, format?: string ): Promise { return new Promise(async (resolve, reject) => { let routeValues: any = { id: id }; let queryValues: any = { size: size, format: format, }; try { let verData: vsom.ClientVersioningData = await this.vsoClient.getVersioningData( "3.2-preview.1", "Profile", "67436615-b382-462a-b659-5367a492fb3c", routeValues, queryValues); let url: string = verData.requestUrl; let options: restm.IRequestOptions = this.createRequestOptions('application/json', verData.apiVersion); let res: restm.IRestResponse; res = await this.rest.get(url, options); let ret = this.formatResponse(res.result, ProfileInterfaces.TypeInfo.Avatar, false); resolve(ret); } catch (err) { reject(err); } }); } /** * @param {any} container * @param {string} id * @param {string} size * @param {string} format * @param {string} displayName */ public async getAvatarPreview( container: any, id: string, size?: string, format?: string, displayName?: string ): Promise { return new Promise(async (resolve, reject) => { let routeValues: any = { id: id }; let queryValues: any = { size: size, format: format, displayName: displayName, }; try { let verData: vsom.ClientVersioningData = await this.vsoClient.getVersioningData( "3.2-preview.1", "Profile", "67436615-b382-462a-b659-5367a492fb3c", routeValues, queryValues); let url: string = verData.requestUrl; let options: restm.IRequestOptions = this.createRequestOptions('application/json', verData.apiVersion); let res: restm.IRestResponse; res = await this.rest.create(url, container, options); let ret = this.formatResponse(res.result, ProfileInterfaces.TypeInfo.Avatar, false); resolve(ret); } catch (err) { reject(err); } }); } /** * @param {string} id */ public async resetAvatar( id: string ): Promise { return new Promise(async (resolve, reject) => { let routeValues: any = { id: id }; try { let verData: vsom.ClientVersioningData = await this.vsoClient.getVersioningData( "3.2-preview.1", "Profile", "67436615-b382-462a-b659-5367a492fb3c", routeValues); let url: string = verData.requestUrl; let options: restm.IRequestOptions = this.createRequestOptions('application/json', verData.apiVersion); let res: restm.IRestResponse; res = await this.rest.del(url, options); let ret = this.formatResponse(res.result, null, false); resolve(ret); } catch (err) { reject(err); } }); } /** * @param {any} container * @param {string} id */ public async setAvatar( container: any, id: string ): Promise { return new Promise(async (resolve, reject) => { let routeValues: any = { id: id }; try { let verData: vsom.ClientVersioningData = await this.vsoClient.getVersioningData( "3.2-preview.1", "Profile", "67436615-b382-462a-b659-5367a492fb3c", routeValues); let url: string = verData.requestUrl; let options: restm.IRequestOptions = this.createRequestOptions('application/json', verData.apiVersion); let res: restm.IRestResponse; res = await this.rest.replace(url, container, options); let ret = this.formatResponse(res.result, null, false); resolve(ret); } catch (err) { reject(err); } }); } /** * Lookup up country/region based on provided IPv4, null if using the remote IPv4 address. * * @param {string} ipaddress - IPv4 address to be used for reverse lookup, null if using RemoteIPAddress in request context */ public async getGeoRegion( ipaddress: string ): Promise { return new Promise(async (resolve, reject) => { let routeValues: any = { }; let queryValues: any = { ipaddress: ipaddress, }; try { let verData: vsom.ClientVersioningData = await this.vsoClient.getVersioningData( "3.2-preview.1", "Profile", "3bcda9c0-3078-48a5-a1e0-83bd05931ad0", routeValues, queryValues); let url: string = verData.requestUrl; let options: restm.IRequestOptions = this.createRequestOptions('application/json', verData.apiVersion); let res: restm.IRestResponse; res = await this.rest.get(url, options); let ret = this.formatResponse(res.result, null, false); resolve(ret); } catch (err) { reject(err); } }); } /** * Create profile * * @param {ProfileInterfaces.CreateProfileContext} createProfileContext - Context for profile creation * @param {boolean} autoCreate - Create profile automatically */ public async createProfile( createProfileContext: ProfileInterfaces.CreateProfileContext, autoCreate?: boolean ): Promise { return new Promise(async (resolve, reject) => { let routeValues: any = { }; let queryValues: any = { autoCreate: autoCreate, }; try { let verData: vsom.ClientVersioningData = await this.vsoClient.getVersioningData( "3.2-preview.3", "Profile", "f83735dc-483f-4238-a291-d45f6080a9af", routeValues, queryValues); let url: string = verData.requestUrl; let options: restm.IRequestOptions = this.createRequestOptions('application/json', verData.apiVersion); let res: restm.IRestResponse; res = await this.rest.create(url, createProfileContext, options); let ret = this.formatResponse(res.result, ProfileInterfaces.TypeInfo.Profile, false); resolve(ret); } catch (err) { reject(err); } }); } /** * @param {string} id * @param {boolean} details * @param {boolean} withAttributes * @param {string} partition * @param {string} coreAttributes * @param {boolean} forceRefresh */ public async getProfile( id: string, details?: boolean, withAttributes?: boolean, partition?: string, coreAttributes?: string, forceRefresh?: boolean ): Promise { return new Promise(async (resolve, reject) => { let routeValues: any = { id: id }; let queryValues: any = { details: details, withAttributes: withAttributes, partition: partition, coreAttributes: coreAttributes, forceRefresh: forceRefresh, }; try { let verData: vsom.ClientVersioningData = await this.vsoClient.getVersioningData( "3.2-preview.3", "Profile", "f83735dc-483f-4238-a291-d45f6080a9af", routeValues, queryValues); let url: string = verData.requestUrl; let options: restm.IRequestOptions = this.createRequestOptions('application/json', verData.apiVersion); let res: restm.IRestResponse; res = await this.rest.get(url, options); let ret = this.formatResponse(res.result, ProfileInterfaces.TypeInfo.Profile, false); resolve(ret); } catch (err) { reject(err); } }); } /** * Update profile * * @param {ProfileInterfaces.Profile} profile - Update profile * @param {string} id - Profile ID */ public async updateProfile( profile: ProfileInterfaces.Profile, id: string ): Promise { return new Promise(async (resolve, reject) => { let routeValues: any = { id: id }; try { let verData: vsom.ClientVersioningData = await this.vsoClient.getVersioningData( "3.2-preview.3", "Profile", "f83735dc-483f-4238-a291-d45f6080a9af", routeValues); let url: string = verData.requestUrl; let options: restm.IRequestOptions = this.createRequestOptions('application/json', verData.apiVersion); let res: restm.IRestResponse; res = await this.rest.update(url, profile, options); let ret = this.formatResponse(res.result, null, false); resolve(ret); } catch (err) { reject(err); } }); } /** */ public async getRegions( ): Promise { return new Promise(async (resolve, reject) => { let routeValues: any = { }; try { let verData: vsom.ClientVersioningData = await this.vsoClient.getVersioningData( "3.2-preview.1", "Profile", "92d8d1c9-26b8-4774-a929-d640a73da524", routeValues); let url: string = verData.requestUrl; let options: restm.IRequestOptions = this.createRequestOptions('application/json', verData.apiVersion); let res: restm.IRestResponse; res = await this.rest.get(url, options); let ret = this.formatResponse(res.result, null, false); resolve(ret); } catch (err) { reject(err); } }); } /** */ public async getSupportedLcids( ): Promise { return new Promise(async (resolve, reject) => { let routeValues: any = { }; try { let verData: vsom.ClientVersioningData = await this.vsoClient.getVersioningData( "3.2-preview.1", "Profile", "d5bd1aa6-c269-4bcd-ad32-75fa17475584", routeValues); let url: string = verData.requestUrl; let options: restm.IRequestOptions = this.createRequestOptions('application/json', verData.apiVersion); let res: restm.IRestResponse; res = await this.rest.get(url, options); let ret = this.formatResponse(res.result, null, true); resolve(ret); } catch (err) { reject(err); } }); } /** * @param {boolean} includeAvatar */ public async getUserDefaults( includeAvatar?: boolean ): Promise { return new Promise(async (resolve, reject) => { let routeValues: any = { }; let queryValues: any = { includeAvatar: includeAvatar, }; try { let verData: vsom.ClientVersioningData = await this.vsoClient.getVersioningData( "3.2-preview.1", "Profile", "b583a356-1da7-4237-9f4c-1deb2edbc7e8", routeValues, queryValues); let url: string = verData.requestUrl; let options: restm.IRequestOptions = this.createRequestOptions('application/json', verData.apiVersion); let res: restm.IRestResponse; res = await this.rest.get(url, options); let ret = this.formatResponse(res.result, ProfileInterfaces.TypeInfo.Profile, false); resolve(ret); } catch (err) { reject(err); } }); } /** * @param {string} id */ public async refreshUserDefaults( id: string ): Promise { return new Promise(async (resolve, reject) => { let routeValues: any = { id: id }; try { let verData: vsom.ClientVersioningData = await this.vsoClient.getVersioningData( "3.2-preview.1", "Profile", "b583a356-1da7-4237-9f4c-1deb2edbc7e8", routeValues); let url: string = verData.requestUrl; let options: restm.IRequestOptions = this.createRequestOptions('application/json', verData.apiVersion); let res: restm.IRestResponse; res = await this.rest.replace(url, options); let ret = this.formatResponse(res.result, ProfileInterfaces.TypeInfo.Profile, false); resolve(ret); } catch (err) { reject(err); } }); } }