///
/// HybridOnePurchasesSpec.swift
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
/// https://github.com/mrousavy/nitro
/// Copyright © Marc Rousavy @ Margelo
///

import NitroModules

/// See ``HybridOnePurchasesSpec``
public protocol HybridOnePurchasesSpec_protocol: HybridObject {
  // Properties


  // Methods
  func getProducts(productIds: [String]) throws -> Promise<[PurchaseProduct]>
  func purchase(productId: String, appAccountToken: String?) throws -> Promise<PurchaseResult>
  func getCurrentEntitlements() throws -> Promise<[PurchaseTransaction]>
  func getUnfinishedTransactions() throws -> Promise<[PurchaseTransaction]>
  func finishTransaction(transactionId: String) throws -> Promise<Void>
  func addTransactionListener(onUpdate: @escaping (_ update: PurchaseUpdate) -> Void) throws -> () -> Void
  func sync() throws -> Promise<Void>
}

public extension HybridOnePurchasesSpec_protocol {
  /// Default implementation of ``HybridObject.toString``
  func toString() -> String {
    return "[HybridObject OnePurchases]"
  }
}

/// See ``HybridOnePurchasesSpec``
open class HybridOnePurchasesSpec_base {
  private weak var cxxWrapper: HybridOnePurchasesSpec_cxx? = nil
  public init() { }
  public func getCxxWrapper() -> HybridOnePurchasesSpec_cxx {
  #if DEBUG
    guard self is any HybridOnePurchasesSpec else {
      fatalError("`self` is not a `HybridOnePurchasesSpec`! Did you accidentally inherit from `HybridOnePurchasesSpec_base` instead of `HybridOnePurchasesSpec`?")
    }
  #endif
    if let cxxWrapper = self.cxxWrapper {
      return cxxWrapper
    } else {
      let cxxWrapper = HybridOnePurchasesSpec_cxx(self as! any HybridOnePurchasesSpec)
      self.cxxWrapper = cxxWrapper
      return cxxWrapper
    }
  }
}

/**
 * A Swift base-protocol representing the OnePurchases HybridObject.
 * Implement this protocol to create Swift-based instances of OnePurchases.
 * ```swift
 * class HybridOnePurchases : HybridOnePurchasesSpec {
 *   // ...
 * }
 * ```
 */
public typealias HybridOnePurchasesSpec = HybridOnePurchasesSpec_protocol & HybridOnePurchasesSpec_base
