export interface IUserData {
  me: IUser;
  subscription: {
    subscriptionId: string;
  };
}

export interface IUser {
  ssn: string;
  msisdn: string;
  name: string;
  email: string;
  userProfile: IUserProfile;
  profiles: Array<IProfile>;
  invoices: Array<IInvoice>;
  subscriptions: IProfilePayload;
  departments: Array<IDepartment>;
  rateplans: Array<IRateplans>;
  transactions: ITransactionPayload;
  claims: Array<IClaim>;
  summary: ISummary;
  isCompany: boolean;
  authenticatedSsn: string;
  authenticatedName: string;
  subscriptionLevel: string;
  cards: Array<ICard>;
  opportunities: Array<IOpportunity>;
}

export interface IPostpaidPaymentMethod {
  maskedNumber?: string;
  expiry?: string;
  type: string;
}

export interface IConnection {
  id: string;
  subscriptionId: string;
  isActive: boolean;
  type: 'Mobile' | 'Internet' | 'CallForwarding' | 'BackupConnection' | 'Fiber';
}

export interface IVisitSlotInfo {
  code: number;
  message: string;
  bookDate: string;
}

export interface IUserProfile {
  streetAddress: string;
  postalCode: string;
  city: string;
  ssn: string;
  name: string;
  email: string;
  isCompany: boolean;
}

export interface IProfile {
  ssn: string;
  name: string;
  email: string;
  accountName: string;
  activeUntil: Date;
  accountSsn: string;
  subscriptionId: string;
  title: string;
  rateplan: IRateplan;
  firstName: string;
  isUser: boolean;
  isLoggedInAs: boolean;
  isPayer: boolean;
  isRouted: boolean;
  settings: Array<ISetting>;
  packs: Array<IUsagePack>;
  refills: Array<IRefills>;
  autoRefills: Array<IAutoRefill>;
  summary: ISummary;
  statusCode: string;
  isActive: boolean;
  displayTitle: string;
  findAutoRefillForPack: (packs: Array<IUsagePack>, index: number) => IAutoRefill;
  updateSelectedMonth: (date: Date) => void;
  allowedServicePacks: Array<IServicepackCategory>;
  hasOfferings: boolean;
  onlyRateplanChangeAllowed: boolean;
  isLoadingSettings: boolean;
  selectedMonth: Date;
  hasOfferingsByTypeId: (typeId: string) => boolean;
  selected: boolean;
  device: IDevice;
  simcard: ISimcard;
  report: IReport;
  connections: Array<IConnection>;
  visitSlotInfo: IVisitSlotInfo;
  subscriptionPeriods: Array<ISubscriptionPeriod>;
  subscriptionGuid: string;
  usageItems: Array<IUsageItem>;
  created: Date;
  forwardingSettings: IForwardingSettings;
  subscriptions: Array<any>;
  fiberInfo: IFiberInfo;
  allowMarketing: boolean;
  isVisibleInPhonebook: boolean;
  phoneNumber: number;
  postpaidPaymentMethod?: IPostpaidPaymentMethod;
  roofAmount?: number;
  invoiceExplanation?: string;
}

export interface IFiberInfo {
  subscriptionStatusDetails: string;
}

export interface IForwardingSettings {
  openingHours: IOpeningHours;
  recording: IRecording;
  forwardingNumbers: Array<IForwardingNumber>;
  voicemailEmail: string;
  voicemailActive: boolean;
  iterationId: number;
}

export interface IForwardingNumber {
  doormanNumber: string;
  forwardTo: Array<string>;
}

export interface IRecording {
  gender: 'female' | 'male';
  generatedValue: string;
  readOpeningHours: boolean;
  type: 'generated' | 'recording';
}

export interface IOpeningHours {
  days: Array<IDay>;
  override: 'no' | 'open' | 'closed';
}

export interface IDay {
  day: number;
  openingInfo: Array<IOpeningInfo>;
}

export interface IOpeningInfo {
  opens: string;
  closes: string;
}

export enum ProfileStatusCode {
  active,
  b1w,
  signup,
  b2w,
  cancelled,
  unknown,
}

export interface ISubscriptionPeriod {
  periodStart: Date;
  periodEnd: Date;
  status: SubscriptionPeriodStatus;
  id: string;
  orderId: string;
  amount: number;
}

export enum SubscriptionPeriodStatus {
  Paid = 'Paid',
  New = 'New',
  FailedPaymentNotificationSent = 'FailedPaymentNotificationSent',
  SubscriptionDeactivated = 'SubscriptionDeactivated',
  SubscriptionDeactivatedAndNotified = 'SubscriptionDeactivatedAndNotified',
  SubscriptionAbandoned = 'SubscriptionAbandoned',
}

export interface IProfilePayload {
  pageInfo: IProfilePageInfo;
  subscriptions: Array<IProfile>;
}

export interface IProfilePageInfo {
  totalCount: number;
}

export interface IInvoice {
  id: string;
  invoiceNumber: string;
  title: string;
  date: Date;
  amount: number;
  isOpen: boolean;
  pdfLink: string;
  documentLink: string;
}

export interface IDepartment {
  isParent: boolean;
  id: string;
  ssn: string;
  name: string;
}

export interface IRateplans {
  id: string;
  title: string;
  shortTitle: string;
}

export interface ITransactionPayload {
  pageInfo: IProfilePageInfo;
  accountTransaction: Array<IAccountTransaction>;
}

export interface IAccountTransaction {
  amount: number;
  balance: number;
  date: Date;
  description: string;
  dueDate: Date;
  remainder: number;
  transactionId: number;
  voucherNumber: string;
  voucherType: string;
  pdfUrl: string;
}

export interface IContact {
  name: string;
  msisdn: string;
  type?: string;
}

export interface IClaim {
  claimNumber: string;
  dueDate: Date;
  finalDueDate: Date;
  updated: Date;
  amount: number;
  initialAmount: number;
  penalty: number;
  defaultCharges: number;
  otherCharges: number;
  motusCharge: number;
  totalCharge: number;
  invoices: Array<IInvoice>;
}

export interface IRateplan {
  id: string;
  title: string;
  shortTitle: string;
  typeId: string;
  price: number;
  description: string;
  isPrepaid: boolean;
  receiptText: string;
  isVip: boolean;
  includedDataAmountInMb: number;
  availableRefills: Array<IRefillCategory>;
  availableServicepacks: Array<IServicepackCategory>;
  availableRateplans: Array<IRateplanCategory>;
  mobileCount: number;
  internetCount: number;
  numberForwardCount: number;
  backupCount: number;
}

export interface IRateplanCategory {
  name: string;
  description: string;
  rateplans: Array<IRateplan>;
  rateplanType: string;
  canModify: boolean;
}

export interface IServicepackCategory {
  name: string;
  description: string;
  servicepackType: string;
  servicepacks: Array<IServicepack>;
  canModify: boolean;
}

export interface IServicepack {
  id: string;
  typeId: string;
  price: number;
  offerPrice: number;
  title: string;
  shortTitle: string;
  description: string;
  dataInEurope: string;
  forSale: boolean;
  dataAmountInMb: number;
}

export interface IRefillCategory {
  id: number;
  name: string;
  description: string;
  refillType: ERefillType;
  refills: Array<IRefill>;
}

export enum ERefillType {
  PhoneData,
  Phone,
  Special,
  Foreign,
  Data,
  SpecialData,
}

export interface IRefill {
  id: string;
  typeId: ERefillType;
  price: number;
  includedDataInGb: number;
  dataInEurope: string;
  monthly: boolean;
  daily: boolean;
  title: string;
  shortTitle: string;
  offerTitle: string;
  isOnlyAutorefill: boolean;
  canBuyMultiple: boolean;
  autoRefillOptions: Array<string>;
  promotionText: string;
}

export interface IRefills {
  transactions: ITransaction[];
}

export interface IReport {
  htmlString: string;
}

// Summary

export interface ISummary {
  totalSum: number;
  totalForeignSum: number;
  usage: Array<ISummaryItem>;
  month: string;
}

export interface ISummaryItem {
  actualUnit?: number;
  amount?: number;
  billedUnit?: number;
  displayText: string;
  displayUnits?: boolean;
  hideIfFree?: boolean;
  measureUnit?: string;
  order?: number;
  showChildren?: boolean;
  children?: Array<ISummaryItem>;
}

export interface ISetting {
  settingId: string;
  settingType: string;
  title: string;
  statusText: string;
  descriptionDetailed?: string;
  order: number;
  on: boolean;
  needsConfirmation: boolean;
  changeable: boolean;
  optionalUrl?: string;
  pendingUpdate: boolean;
  updateError: boolean;
}

export interface ISettingPayload {
  subscriptionId: string;
  settingId: string;
  on: boolean;
}

export interface ITransaction {
  date: Date;
  amount: number;
  authorizationCode?: string;
  authorized?: boolean;
  subscriptionPrice?: number;
  registeredForSubscription?: boolean;
  success: boolean;
  message: string;
  selected: boolean;
}

export interface IRefillHistoryItem {
  title: string;
  description: string;
  date: Date;
  amount: number;
  success: boolean;
  message: string;
}

// Usage

export interface IUsageSummary {
  totalBalance: number;
}
export interface IPrice {
  amount: number;
  displayPrice: string;
}

export interface IAlert {
  description: string;
  message: string;
}

export interface IPackInfo {
  id: string;
  title: string;
  shortTitle: string;
  description: string;
  detailedDescription: string;
  price: number;
  offerPrice: number;
  categoryId: string;
  typeId: string;
  categoryTitle: string;
  dataInEurope: string;
  canModify: boolean;
  canCancel: boolean;
  contentType: string;
  billingUnit: string;
  remainingSubtitle: string;
}

export interface IUsagePack {
  servicepackId: string;
  connectionId: string;
  title: string;
  items: Array<IUsageItem>;
  price: IPrice;
  alerts: Array<IAlert>;
  offerUpsell: boolean;
  info: IPackInfo;
  excessCount: number;
  isExcessUsage: boolean;
  primaryDisplayUsage: string;
  secondaryUsage: Array<IUsageItem>;
  isUsageInfinite: boolean;
  minimumUpgradeInMb: number;
  isUpgradeAllowed: (servicepack: IServicepack) => boolean;
  isRateplanChangeAllowed: (rateplan: IRateplan) => boolean;
  validTo: Date | undefined;
}

export interface IUsageItem {
  title: string;
  included: IAmount;
  remaining: IAmount;
  usage: IAmount;
  used: string;
  infinite: boolean;
  isPrimary: boolean;
  type: UsageType;
  remainingAmount: number;
  isPrimaryData: boolean;
}

export interface IAmount {
  usageType: string;
  unit: string;
  amount: number;
}

export enum UsageType {
  BALANCE,
  SMS,
  DATA,
  ROAM_LIKE_HOME,
  ROAMING,
  VALID_TIME,
  PHONE_OFFER,
  EXCESS_DATA,
  DISCOUNT,
  TRAVEL_PACK,
  CREDIT,
}

export interface IAutoRefill {
  id: number;
  refillId: string;
  triggerType: string;
  type: number;
  nextRefill?: Date;
  paymentMethod: IAutoRefillPayment;
  info: IRefill;
}

export interface IAutoRefillPayment {
  maskedCardNumber: string;
  expiryMonth: string;
  expiryYear: string;
  nick: string;
  type: string;
}

export interface IPayClaims {
  payClaims: IPayClaimsPayload;
}

export interface IPayClaimsPayload {
  transaction: ITransaction;
  user: IUser;
  error: IError;
}

export interface IUpdateSetting {
  updateSetting: IUpdateSettingPayload;
}

export interface IUpdateSettingPayload {
  setting: ISetting;
  error: IError;
}

export interface IUpdateAccount {
  updateAccount: IUpdateAccountPayload;
}

export interface IUpdateAccountPayload {
  user: IUser;
  error: IError;
}

export interface ISetPrimaryEmail {
  setPrimaryEmail: ISetPrimaryEmailPayload;
}

export interface ISetPrimaryEmailPayload {
  user: IUser;
  error: IError;
}

export interface IServicepackInput {
  servicepackId: string;
  activateNextMonth: boolean;
}

export interface IAutoRefillInput {
  autoRefillId: number;
  refillId: string;
  activateNextMonth: boolean;
  activateMonthly: boolean;
  subscriptionId: string;
  paymentInfo: IPaymentMethodInput;
}

export interface IConnectionInput {
  connectionId: string;
  msisdn: string;
  type: string;
  cardNumber: string;
  payExcess: boolean;
}

export interface IPaymentMethodInput {
  ssn: string;
  cardNumber: string;
  expiryMonth: string;
  expiryYear: string;
  cvc: string;
}

export interface IRateplanInput {
  rateplanId: string;
  activateNextMonth: boolean;
}

export interface IUpdateSubscription {
  updateSubscription: IUpdateSubscriptionPayload;
}

export interface IUpdateSubscriptionPayload {
  user: IUser;
  error: IError;
}

export interface IDevice {
  name: string;
  imageUrl: string;
}
export interface ISimcard {
  iccid: string;
  imsi: string;
  pin: string;
  puk: string;
  simType: string;
}

export interface IAddDepartmentPayload {
  addDepartment: {
    department: IDepartment;
    error: IError;
  };
}

export interface IChangeDepartmentPayload {
  changeDepartment: {
    res: boolean;
    error: IError;
  };
}

export interface IUpdateOpportunityInput {
  id: string;
  expectedOutcome: OpportunityExpectedOutcome;
  status: OpportunityStatus;
}

export interface IOpportunityPayload {
  updateOpportunity: {
    error: IError;
  };
}

export interface IError {
  message: string;
  code: ErrorCode;
}

export interface IKeyValue {
  key: string;
  value: string;
}

export enum ErrorCode {
  unknownError,
  paymentInfoInvalid,
  paymentDenied,
}

export interface IAccountInput {
  ssn: string;
}

export interface IHistoryItem {
  name: string;
  date: string;
  content: string;
}

export interface IMenuList {
  id: string;
  className?: string;
  title: string;
  href?: string;
  subPath?: string;
  asPath?: string;
  addService?: boolean;
  subLinks?: Array<IMenuList>;
  hoverLinks?: Array<IMenuList>;
  newTab?: boolean;
  hero?: boolean;
}

export interface IOpportunity {
  id: string;
  signatue: string;
  label: string;
  subject: string;
  importance: string;
  expectedOutcome: OpportunityExpectedOutcome;
  status: OpportunityStatus;
  category: string;
  description: string;
  ticketId: string;
  script: string;
  callToAction: string;
}

export enum OpportunityExpectedOutcome {
  Unknown,
  Success,
  Failure,
  Mixed,
}

export enum OpportunityStatus {
  Discovered,
  Viewed,
  Assigned,
  Snoozed,
  Seized,
  Succeeded,
  Failed,
  Mixed,
  Invalidated,
  Expired,
  Defaulted,
}

export interface ICard {
  id: string;
  maskedNumber: string;
  expiryMonth: string;
  expiryYear: string;
  paymentType: string;
  issuer: string;
  virtualNumber?: string;
}

export interface ISlot {
  startTime: string;
  endTime: string;
  slotId: number;
}

export interface IAnnouncement {
  acceptText: string;
  color: string;
  cookieId: string;
  link: string;
  linkText: string;
  text: string;
  display: Array<string>;
}

export interface ISubscriptionPaymentMethod {
  id: string;
  added: Date;
  active: boolean;
  subscriptionId: string;
  paymentMethod: ICard;
}
export interface ISubscriptionPaymentMethodData {
  subscriptionPaymentMethod?: ISubscriptionPaymentMethod;
}
