export type AdminKuaishouIndustryAccessTokenStatus =
  | 'missing'
  | 'unknown'
  | 'expired'
  | 'expiring'
  | 'valid'

export interface AdminKuaishouIndustryShopConfig {
  enabled: boolean
  sellerId: string
  shopId: string
  shopName: string
  customShopName: string
  authState: string
  authorizationUrl: string
  accessToken: string
  accessTokenMasked: string
  hasAccessToken: boolean
  refreshToken: string
  refreshTokenMasked: string
  hasRefreshToken: boolean
  accessTokenExpiresAt: string
  refreshTokenExpiresAt: string
  accessTokenStatus: AdminKuaishouIndustryAccessTokenStatus
  accessTokenExpiresInSeconds: number | null
  openId: string
  grantedScopes: string
  lastRefreshedAt: string
  lastRefreshError: string
}

export interface AdminKuaishouIndustrySourceConfig {
  enabled: boolean
  baseUrl: string
  authBaseUrl: string
  redirectUri: string
  scopes: string
  authState: string
  authorizationUrl: string
  appKey: string
  appSecret: string
  appSecretMasked: string
  hasAppSecret: boolean
  signSecret: string
  signSecretMasked: string
  hasSignSecret: boolean
  messageSecret: string
  messageSecretMasked: string
  hasMessageSecret: boolean
  accessToken: string
  accessTokenMasked: string
  hasAccessToken: boolean
  refreshToken: string
  refreshTokenMasked: string
  hasRefreshToken: boolean
  accessTokenExpiresAt: string
  refreshTokenExpiresAt: string
  accessTokenStatus: AdminKuaishouIndustryAccessTokenStatus
  accessTokenExpiresInSeconds: number | null
  openId: string
  grantedScopes: string
  sellerId: string
  provider: string
  platform: string
  shopId: string
  shopName: string
  version: string
  shops: AdminKuaishouIndustryShopConfig[]
  lastRefreshedAt: string
  lastRefreshError: string
}

export interface AdminKuaishouIndustryConfigResponse {
  filePath: string
  source: AdminKuaishouIndustrySourceConfig
}

export interface AdminKuaishouIndustryRefreshTokenResponse extends AdminKuaishouIndustryConfigResponse {
  refreshed: boolean
  shop?: AdminKuaishouIndustryShopConfig
}

export interface AdminKuaishouIndustryAuthorizationCodePayload {
  code: string
  sellerId?: string
  shopName?: string
  customShopName?: string
}

export type AdminKuaishouIndustryExchangeCodeResponse = AdminKuaishouIndustryRefreshTokenResponse
