/* tslint:disable */
/* eslint-disable */
/**
* Gravatar Public API
* Gravatar\'s public API endpoints
*
* The version of the OpenAPI document: 3.0.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
import * as runtime from '../runtime.js';
import type {
AssociatedResponse,
Profile,
UpdateProfileRequest,
} from '../models/index.js';
import {
AssociatedResponseFromJSON,
AssociatedResponseToJSON,
ProfileFromJSON,
ProfileToJSON,
UpdateProfileRequestFromJSON,
UpdateProfileRequestToJSON,
} from '../models/index.js';
export interface AssociatedEmailRequest {
emailHash: string;
}
export interface GetProfileByIdRequest {
profileIdentifier: string;
}
export interface UpdateProfileOperationRequest {
updateProfileRequest: UpdateProfileRequest;
}
/**
* ProfilesApi - interface
*
* @export
* @interface ProfilesApiInterface
*/
export interface ProfilesApiInterface {
/**
* Checks if the provided email address is associated with the authenticated user.
* @summary Check if the email is associated with the authenticated user
* @param {string} emailHash The hash of the email address to check.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @memberof ProfilesApiInterface
*/
associatedEmailRaw(requestParameters: AssociatedEmailRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<AssociatedResponse>>;
/**
* Checks if the provided email address is associated with the authenticated user.
* Check if the email is associated with the authenticated user
*/
associatedEmail(requestParameters: AssociatedEmailRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<AssociatedResponse>;
/**
* Returns the information available for the authenticated user. It\'s equivalent to the full profile information available in the `/profiles/{profileIdentifier}` endpoint.
* @summary Get profile information for the authenticated user
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @memberof ProfilesApiInterface
*/
getProfileRaw(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<Profile>>;
/**
* Returns the information available for the authenticated user. It\'s equivalent to the full profile information available in the `/profiles/{profileIdentifier}` endpoint.
* Get profile information for the authenticated user
*/
getProfile(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<Profile>;
/**
* Returns a profile by the given identifier.
* @summary Get profile by identifier
* @param {string} profileIdentifier This can either be an SHA256 hash of an email address or profile URL slug.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @memberof ProfilesApiInterface
*/
getProfileByIdRaw(requestParameters: GetProfileByIdRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<Profile>>;
/**
* Returns a profile by the given identifier.
* Get profile by identifier
*/
getProfileById(requestParameters: GetProfileByIdRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<Profile>;
/**
* Updates the profile information for the authenticated user. Only a subset of `Profile` fields are available for update. Partial updates are supported, so only the provided fields will be updated. To unset a field, set it explicitly to an empty string.
* @summary Update profile information for the authenticated user
* @param {UpdateProfileRequest} updateProfileRequest
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @memberof ProfilesApiInterface
*/
updateProfileRaw(requestParameters: UpdateProfileOperationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<Profile>>;
/**
* Updates the profile information for the authenticated user. Only a subset of `Profile` fields are available for update. Partial updates are supported, so only the provided fields will be updated. To unset a field, set it explicitly to an empty string.
* Update profile information for the authenticated user
*/
updateProfile(requestParameters: UpdateProfileOperationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<Profile>;
}
/**
*
*/
export class ProfilesApi extends runtime.BaseAPI implements ProfilesApiInterface {
/**
* Checks if the provided email address is associated with the authenticated user.
* Check if the email is associated with the authenticated user
*/
async associatedEmailRaw(requestParameters: AssociatedEmailRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<AssociatedResponse>> {
if (requestParameters['emailHash'] == null) {
throw new runtime.RequiredError(
'emailHash',
'Required parameter "emailHash" was null or undefined when calling associatedEmail().'
);
}
const queryParameters: any = {};
if (requestParameters['emailHash'] != null) {
queryParameters['email_hash'] = requestParameters['emailHash'];
}
const headerParameters: runtime.HTTPHeaders = {};
if (this.configuration && this.configuration.accessToken) {
// oauth required
headerParameters["Authorization"] = await this.configuration.accessToken("oauth", []);
}
const response = await this.request({
path: `/me/associated-email`,
method: 'GET',
headers: headerParameters,
query: queryParameters,
}, initOverrides);
return new runtime.JSONApiResponse(response, (jsonValue) => AssociatedResponseFromJSON(jsonValue));
}
/**
* Checks if the provided email address is associated with the authenticated user.
* Check if the email is associated with the authenticated user
*/
async associatedEmail(requestParameters: AssociatedEmailRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<AssociatedResponse> {
const response = await this.associatedEmailRaw(requestParameters, initOverrides);
return await response.value();
}
/**
* Returns the information available for the authenticated user. It\'s equivalent to the full profile information available in the `/profiles/{profileIdentifier}` endpoint.
* Get profile information for the authenticated user
*/
async getProfileRaw(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<Profile>> {
const queryParameters: any = {};
const headerParameters: runtime.HTTPHeaders = {};
if (this.configuration && this.configuration.accessToken) {
// oauth required
headerParameters["Authorization"] = await this.configuration.accessToken("oauth", []);
}
const response = await this.request({
path: `/me/profile`,
method: 'GET',
headers: headerParameters,
query: queryParameters,
}, initOverrides);
return new runtime.JSONApiResponse(response, (jsonValue) => ProfileFromJSON(jsonValue));
}
/**
* Returns the information available for the authenticated user. It\'s equivalent to the full profile information available in the `/profiles/{profileIdentifier}` endpoint.
* Get profile information for the authenticated user
*/
async getProfile(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<Profile> {
const response = await this.getProfileRaw(initOverrides);
return await response.value();
}
/**
* Returns a profile by the given identifier.
* Get profile by identifier
*/
async getProfileByIdRaw(requestParameters: GetProfileByIdRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<Profile>> {
if (requestParameters['profileIdentifier'] == null) {
throw new runtime.RequiredError(
'profileIdentifier',
'Required parameter "profileIdentifier" was null or undefined when calling getProfileById().'
);
}
const queryParameters: any = {};
const headerParameters: runtime.HTTPHeaders = {};
if (this.configuration && this.configuration.accessToken) {
const token = this.configuration.accessToken;
const tokenString = await token("apiKey", []);
if (tokenString) {
headerParameters["Authorization"] = `Bearer ${tokenString}`;
}
}
const response = await this.request({
path: `/profiles/{profileIdentifier}`.replace(`{${"profileIdentifier"}}`, encodeURIComponent(String(requestParameters['profileIdentifier']))),
method: 'GET',
headers: headerParameters,
query: queryParameters,
}, initOverrides);
return new runtime.JSONApiResponse(response, (jsonValue) => ProfileFromJSON(jsonValue));
}
/**
* Returns a profile by the given identifier.
* Get profile by identifier
*/
async getProfileById(requestParameters: GetProfileByIdRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<Profile> {
const response = await this.getProfileByIdRaw(requestParameters, initOverrides);
return await response.value();
}
/**
* Updates the profile information for the authenticated user. Only a subset of `Profile` fields are available for update. Partial updates are supported, so only the provided fields will be updated. To unset a field, set it explicitly to an empty string.
* Update profile information for the authenticated user
*/
async updateProfileRaw(requestParameters: UpdateProfileOperationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<Profile>> {
if (requestParameters['updateProfileRequest'] == null) {
throw new runtime.RequiredError(
'updateProfileRequest',
'Required parameter "updateProfileRequest" was null or undefined when calling updateProfile().'
);
}
const queryParameters: any = {};
const headerParameters: runtime.HTTPHeaders = {};
headerParameters['Content-Type'] = 'application/json';
if (this.configuration && this.configuration.accessToken) {
// oauth required
headerParameters["Authorization"] = await this.configuration.accessToken("oauth", []);
}
const response = await this.request({
path: `/me/profile`,
method: 'PATCH',
headers: headerParameters,
query: queryParameters,
body: UpdateProfileRequestToJSON(requestParameters['updateProfileRequest']),
}, initOverrides);
return new runtime.JSONApiResponse(response, (jsonValue) => ProfileFromJSON(jsonValue));
}
/**
* Updates the profile information for the authenticated user. Only a subset of `Profile` fields are available for update. Partial updates are supported, so only the provided fields will be updated. To unset a field, set it explicitly to an empty string.
* Update profile information for the authenticated user
*/
async updateProfile(requestParameters: UpdateProfileOperationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<Profile> {
const response = await this.updateProfileRaw(requestParameters, initOverrides);
return await response.value();
}
}