import { createMethod } from './utils'
import {
  User,
  Auras,
  Elements,
  AuthTokens,
  Apps,
  Assets,
  AssetCategories,
  DailyForecasts,
  SubscriptionStatus,
  AICompatCategories,
  AICompats,
  AIRequests,
  UserCallbacks,
  Translations,
  Zodiacs,
  AIRequestsV2,
  Assistants,
  OpenAI,
  SinglePayment,
  Products,
  Palmistry,
  Paywall,
  Payment,
  UserVideos,
  UserPDF,
  Locale,
  Session,
  Login,
  Password,
  ChatsCategories,
  ChatMessages,
  CreateChat,
  UserSubscriptions
} from './resources'

const api = {
  // auth: createMethod<AuthTokens.Payload, AuthTokens.Response>(AuthTokens.createRequest),
  getRealToken: createMethod<AuthTokens.PayloadGetRealToken, AuthTokens.ResponseGetRealToken>(AuthTokens.createGetRealTokenRequest),
  getAppConfig: createMethod<Apps.Payload, Apps.Response>(Apps.createRequest),
  // getElement: createMethod<Element.Payload, Element.Response>(Element.createRequest),
  getElements: createMethod<Elements.Payload, Elements.Response>(Elements.createRequest),
  getUser: createMethod<User.GetPayload, User.Response>(User.createGetRequest),
  getMe: createMethod<User.GetPayload, User.IMeResponse>(User.createMeRequest),
  updateUser: createMethod<User.PatchPayload, User.Response>(User.createPatchRequest),
  getAssets: createMethod<Assets.Payload, Assets.Response>(Assets.createRequest),
  getAssetCategories: createMethod<AssetCategories.Payload, AssetCategories.Response>(AssetCategories.createRequest),
  getDailyForecasts: createMethod<DailyForecasts.Payload, DailyForecasts.Response>(DailyForecasts.createRequest),
  getAuras: createMethod<Auras.Payload, Auras.Response>(Auras.createRequest),
  getAiCompatCategories: createMethod<AICompatCategories.Payload, AICompatCategories.Response>(AICompatCategories.createRequest),
  getAiCompat: createMethod<AICompats.Payload, AICompats.Response>(AICompats.createRequest),
  getAiRequest: createMethod<AIRequests.Payload, AIRequests.Response>(AIRequests.createRequest),
  createUserCallbacks: createMethod<UserCallbacks.PayloadPost, UserCallbacks.Response>(UserCallbacks.createRequestPost),
  getUserCallbacks: createMethod<UserCallbacks.PayloadGet, UserCallbacks.Response>(UserCallbacks.createRequestGet),
  getTranslations: createMethod<Translations.Payload, Translations.Response>(Translations.createRequest),
  getZodiacs: createMethod<Zodiacs.Payload, Zodiacs.Response>(Zodiacs.createRequest),
  AIRequestsV2: createMethod<AIRequestsV2.Payload, AIRequestsV2.Response>(AIRequestsV2.createRequest),
  getAIRequestsV2: createMethod<AIRequestsV2.PayloadGet, AIRequestsV2.IAiResponseGet>(AIRequestsV2.createRequestGet),
  // Advisors chats
  assistants: createMethod<Assistants.Payload, Assistants.Response>(Assistants.createRequest),
  setExternalChatIdAssistant: createMethod<Assistants.PayloadSetExternalChatId, Assistants.ResponseSetExternalChatId>(Assistants.createRequestSetExternalChatId),
  createThread: createMethod<OpenAI.PayloadCreateThread, OpenAI.ResponseCreateThread>(OpenAI.createRequest),
  createMessage: createMethod<OpenAI.PayloadCreateMessage, OpenAI.ResponseCreateMessage>(OpenAI.createRequest),
  getListMessages: createMethod<OpenAI.PayloadGetListMessages, OpenAI.ResponseGetListMessages>(OpenAI.createRequest),
  runThread: createMethod<OpenAI.PayloadRunThread, OpenAI.ResponseGetStatusRunThread>(OpenAI.createRequest),
  getStatusRunThread: createMethod<OpenAI.PayloadRunThread, OpenAI.ResponseGetStatusRunThread>(OpenAI.createRequest),
  getListRuns: createMethod<OpenAI.PayloadGetListRuns, OpenAI.ResponseGetListRuns>(OpenAI.createRequest),
  // Single payment
  getSinglePaymentProducts: createMethod<SinglePayment.PayloadGet, SinglePayment.ResponseGet[]>(SinglePayment.createRequestGet),
  createSinglePayment: createMethod<SinglePayment.PayloadPost, SinglePayment.ResponsePost>(SinglePayment.createRequestPost),
  checkProductPurchased: createMethod<Products.PayloadGet, Products.ResponseGet>(Products.createRequest),
  getPalmistryLines: createMethod<Palmistry.Payload, Palmistry.Response>(Palmistry.createRequest),
  // New Authorization
  authorization: createMethod<User.ICreateAuthorizePayload, User.ICreateAuthorizeResponse>(User.createAuthorizeRequest),
  authorizationAnonymous: createMethod<Omit<User.ICreateAuthorizePayload, "email">, User.ICreateAuthorizeResponse>(User.createAuthorizeAnonymousRequest),
  login: createMethod<Login.Payload, Login.Response>(Login.createRequest),
  resetPassword: createMethod<Password.Payload, Password.Response>(Password.resetRequest),
  // Paywall
  getPaywallByPlacementKey: createMethod<Paywall.PayloadGet, Paywall.ResponseGet>(Paywall.createRequestGet),
  // Payment
  makePayment: createMethod<Payment.PayloadPost, Payment.ResponsePost>(Payment.createRequestPost),
  makeAnonymousPayment: createMethod<Payment.PayloadPostAnonymous, Payment.ResponsePostAnonymousSuccess>(Payment.createRequestPostAnonymous),
  getPaymentConfig: createMethod<null, Payment.IPaymentConfigResponse>(Payment.getConfigRequest),
  getPaymentMethods: createMethod<Payment.Payload, Payment.IPaymentMethodsResponse>(Payment.getMethodsRequest),
  // User videos
  getUserVideos: createMethod<UserVideos.PayloadGet, UserVideos.ResponseGet>(UserVideos.createRequest),
  // User PDF
  getUserPDF: createMethod<UserPDF.PayloadGet, UserPDF.ResponseGet>(UserPDF.createRequest),
  // Locale
  getLocale: createMethod<undefined, Locale.ResponseGet>(Locale.createRequest),
  // Session
  createSession: createMethod<Session.PayloadCreate, Session.ResponseCreate>(Session.createRequest),
  updateSession: createMethod<Session.PayloadUpdate, Session.ResponseUpdate>(Session.updateRequest),
  getLocaleTranslations: createMethod<Session.PayloadGetLocale, Session.ResponseGetLocale>(Session.getLocaleRequest),
  getPixels: createMethod<Session.PayloadGetPixels, Session.ResponseGetPixels>(Session.getPixelsRequest),
  getFunnel: createMethod<Session.PayloadGetFunnel, Session.ResponseGetFunnel>(Session.getFunnelRequest),
  // Chats
  getChatsCategories: createMethod<null, ChatsCategories.ResponseGet>(ChatsCategories.getRequest),
  getChatMessages: createMethod<ChatMessages.Payload, ChatMessages.ResponseGet>(ChatMessages.getRequest),
  createChat: createMethod<CreateChat.Payload, CreateChat.ResponseGet>(CreateChat.createRequest),
  // Subscriptions
  // getSubscriptionPlans: createMethod<SubscriptionPlans.Payload, SubscriptionPlans.Response>(SubscriptionPlans.createRequest),
  // getSubscriptionCheckout: createMethod<SubscriptionCheckout.Payload, SubscriptionCheckout.Response>(SubscriptionCheckout.createRequest),
  getSubscriptionStatus: createMethod<SubscriptionStatus.Payload, SubscriptionStatus.Response>(SubscriptionStatus.createRequest),
  // new get subscription status
  getSubscriptionStatusNew: createMethod<SubscriptionStatus.Payload, SubscriptionStatus.ResponseNew>(SubscriptionStatus.createRequestNew),
  getUserSubscriptions: createMethod<UserSubscriptions.Payload, UserSubscriptions.ResponseGet>(UserSubscriptions.createRequestGet),
  userSubscriptionAction: createMethod<UserSubscriptions.PayloadAction, UserSubscriptions.ResponseAction>(UserSubscriptions.createRequestAction),
}

export type ApiContextValue = typeof api

export function createApi(): ApiContextValue {
  return api
}
