<commit_before>import {
  DeleteAllResponse,
  DestinyVersion,
  ExportResponse,
  ImportResponse,
  Loadout,
  LoadoutShareRequest,
  LoadoutShareResponse,
  PlatformInfoResponse,
  ProfileResponse,
  ProfileUpdate,
  ProfileUpdateRequest,
  ProfileUpdateResponse,
} from '@destinyitemmanager/dim-api-types';
import { DestinyAccount } from 'app/accounts/destiny-account';
import { authenticatedApi, unauthenticatedApi } from './dim-api-helper';

export async function getGlobalSettings() {
  const response = await unauthenticatedApi<PlatformInfoResponse>(
    {
      url: '/platform_info',
      method: 'GET',
    },
    true
  );
  return response.settings;
}

export async function getDimApiProfile(account?: DestinyAccount) {
  return authenticatedApi<ProfileResponse>({
    url: '/profile',
    method: 'GET',
    params: account
      ? {
          platformMembershipId: account.membershipId,
          destinyVersion: account.destinyVersion,
          components: 'settings,loadouts,tags,hashtags,searches,triumphs',
        }
      : {
          components: 'settings',
        },
  });
}

export async function importData(data: ExportResponse) {
  return authenticatedApi<ImportResponse>({
    url: '/import',
    method: 'POST',<commit_msg>Pass flavor to dim-api platform_info method<commit_after>import {
  DeleteAllResponse,
  DestinyVersion,
  ExportResponse,
  ImportResponse,
  Loadout,
  LoadoutShareRequest,
  LoadoutShareResponse,
  PlatformInfoResponse,
  ProfileResponse,
  ProfileUpdate,
  ProfileUpdateRequest,
  ProfileUpdateResponse,
} from '@destinyitemmanager/dim-api-types';
import { DestinyAccount } from 'app/accounts/destiny-account';
import { authenticatedApi, unauthenticatedApi } from './dim-api-helper';

export async function getGlobalSettings() {
  const response = await unauthenticatedApi<PlatformInfoResponse>(
    {
      url: `/platform_info?flavor=${$DIM_FLAVOR}`,
      method: 'GET',
    },
    true
  );
  return response.settings;
}

export async function getDimApiProfile(account?: DestinyAccount) {
  return authenticatedApi<ProfileResponse>({
    url: '/profile',
    method: 'GET',
    params: account
      ? {
          platformMembershipId: account.membershipId,
          destinyVersion: account.destinyVersion,
          components: 'settings,loadouts,tags,hashtags,searches,triumphs',
        }
      : {
          components: 'settings',
        },
  });
}

export async function importData(data: ExportResponse) {
  return authenticatedApi<ImportResponse>({
    url: '/import',
    method: 'POST',
{'fraction_non_alphanumeric': 0.10594214229867084, 'fraction_numerical': 0.0, 'mean_word_length': 3.874285714285714, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '211134', 'n_tokens_mistral': 749, 'n_tokens_neox': 736, 'n_words': 146}