import { AxiosInstance } from "axios"

class SMSIR {
  /**
   * The API's base URL.
   */
  baseURL: string
  client: AxiosInstance

  constructor(apiKey: string)

  /**
   * Bulk send SMS from a line to multiple phone numbers
   * 
   * https://app.sms.ir/developer/help/bulk
   */
  async bulkSend(line: number, text: string, phones: string[], sendDate: number | undefined): Promise<SMSIRResponse<BulkSendData>>

  /**
   * Bulk send SMS from a line to multiple phone numbers but send a unique message per person
   * 
   * https://app.sms.ir/developer/help/likeToLike
   */
  async bulkSendLikeToLike(line: number, text: string[], phones: string[], sendDate: number): Promise<SMSIRResponse<BulkSendDataLikeToLike>>

  /**
   * send an SMS based on a template defined in the SMSIR panel
   * 
   * https://app.sms.ir/developer/help/verify
   */
  async sendTemplate(template: number, phone: string, params: Record<string, string>): Promise<SMSIRResponse<TemplateSendData>> 

  /**
   * Fetch your SMSIR credit balance
   * 
   * https://app.sms.ir/developer/help/credit
   */
  async fetchBalance(): Promise<SMSIRResponse<FetchBalanceData>>
  /**
   * Fetch your SMSIR lines
   * 
   * https://app.sms.ir/developer/help/line
   */
  async fetchLines(): Promise<SMSIRResponse<FetchLineData>>
}

/**
 * The structure of an SMSIR Response body base
 * 
 * https://app.sms.ir/developer/help/introduction
 */
type SMSIRResponse<DataStructure> = {
  /**
   * The status of the response
   * 
   * https://app.sms.ir/developer/help/statusCode
   */
  status: number,
  /**
   * A message in persian regarding the status of a request
   */
  message: string,
  /**
   * The data returned alongside the response. varies between requests
   */
  data?: DataStructure
}

/**
 * The structure of the data section in a bulk send request
 * 
 * https://app.sms.ir/developer/help/bulk
 */
type BulkSendData = {
  /**
   * The ID of the bulk request
   */
  packId: string,
  /**
   * A list of unique identifiers for each message
   */
  messageIds: number[]
  /**
   * The cost of sending the SMS(s) in SMSIR Units
   * 
   * Pricing info: https://app.sms.ir/add-fund
   */
  cost: number
}

/**
 * The structure of the data in bulk like to like send request
 * 
 * https://app.sms.ir/developer/help/likeToLike
 */
type BulkSendDataLikeToLike = BulkSendData // It's the same so why bother :p

/**
 * The structure of the data section in a template(verify) send request
 * 
 * https://app.sms.ir/developer/help/verify
 */
type TemplateSendData = {
  /**
   * A unique identifier for the delivered message
   */
  messageId: number,
  /**
   * The cost of sending the SMS(s) in SMSIR Units
   * 
   * Pricing info: https://app.sms.ir/add-fund
   */
  cost: number
}

/**
 * The structure of the data section in a balance fetch request
 * 
 * https://app.sms.ir/developer/help/credit
 */
type FetchBalanceData = number

/**
 * The structure of the data section in a lines fetch request
 * 
 * https://app.sms.ir/developer/help/line
 */
type FetchLineData = number[]