// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. import { APIResource } from '../../../core/resource'; import * as OptionsAPI from './options'; import { OptionRetrieveParams, OptionRetrieveResponse, Options } from './options'; import * as PreferenceAPI from './preference'; import { PersonalizationOptionItem, Preference, PreferenceRetrieveParams, PreferenceUpdateParams, UserPersonalizationPreferenceResponse, } from './preference'; import { APIPromise } from '../../../core/api-promise'; import { buildHeaders } from '../../../internal/headers'; import { RequestOptions } from '../../../internal/request-options'; export class Personalization extends APIResource { preference: PreferenceAPI.Preference = new PreferenceAPI.Preference(this._client); options: OptionsAPI.Options = new OptionsAPI.Options(this._client); /** * Update user personalization preference toggle status. */ enable( params: PersonalizationEnableParams, options?: RequestOptions, ): APIPromise { const { 'Accept-Language': acceptLanguage, 'X-Error-Format': xErrorFormat, ...body } = params; return this._client.put('/users/personalization-preference', { body, ...options, headers: buildHeaders([ { ...(acceptLanguage != null ? { 'Accept-Language': acceptLanguage } : undefined), ...(xErrorFormat != null ? { 'X-Error-Format': xErrorFormat } : undefined), }, options?.headers, ]), }); } /** * Get user personalization preference toggle status. */ isEnabled( params: PersonalizationIsEnabledParams | null | undefined = {}, options?: RequestOptions, ): APIPromise { const { 'Accept-Language': acceptLanguage, 'X-Error-Format': xErrorFormat } = params ?? {}; return this._client.get('/users/personalization-preference', { ...options, headers: buildHeaders([ { ...(acceptLanguage != null ? { 'Accept-Language': acceptLanguage } : undefined), ...(xErrorFormat != null ? { 'X-Error-Format': xErrorFormat } : undefined), }, options?.headers, ]), }); } } /** * Response model for personalization preference toggle. * * Attributes: use_personalization (bool): Whether personalization is enabled for * the user. */ export interface UserPersonalizationPreferenceToggleResponse { /** * Whether personalization is enabled for the user */ use_personalization: boolean; } export interface PersonalizationEnableParams { /** * Body param: Whether to enable personalization for the user */ use_personalization: boolean; /** * Header param */ 'Accept-Language'?: string; /** * Header param: Set to `structured` to receive errors in the structured envelope. * Omit it to keep the legacy error body. */ 'X-Error-Format'?: string; } export interface PersonalizationIsEnabledParams { 'Accept-Language'?: string; /** * Set to `structured` to receive errors in the structured envelope. Omit it to * keep the legacy error body. */ 'X-Error-Format'?: string; } Personalization.Preference = Preference; Personalization.Options = Options; export declare namespace Personalization { export { type UserPersonalizationPreferenceToggleResponse as UserPersonalizationPreferenceToggleResponse, type PersonalizationEnableParams as PersonalizationEnableParams, type PersonalizationIsEnabledParams as PersonalizationIsEnabledParams, }; export { Preference as Preference, type PersonalizationOptionItem as PersonalizationOptionItem, type UserPersonalizationPreferenceResponse as UserPersonalizationPreferenceResponse, type PreferenceRetrieveParams as PreferenceRetrieveParams, type PreferenceUpdateParams as PreferenceUpdateParams, }; export { Options as Options, type OptionRetrieveResponse as OptionRetrieveResponse, type OptionRetrieveParams as OptionRetrieveParams, }; }