import {
  CelloTokenData,
  GetCelloTokenError,
  Referral,
} from "@komi-app/auth-sdk";
import { getSDKConfig } from "config";
import { SdkConfig } from "@komi-app/sales-sdk";
import { Maybe } from "utils/types";

export default class CelloService {
  private referralService: Referral;
  constructor() {
    const authConfig: SdkConfig = getSDKConfig('auth')
    this.referralService = new Referral(authConfig);
  }

  generateCelloToken = async (): Promise<Maybe<CelloTokenData>> => {
    try {
      return await this.referralService.getCelloToken();
    } catch (err) {
      const error = err as GetCelloTokenError;
      console.error(error);
      return void 0;
    }
  };
}
