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

import NitroModules

/**
 * Represents an instance of `PurchaseProduct`, backed by a C++ struct.
 */
public typealias PurchaseProduct = margelo.nitro.one.PurchaseProduct

public extension PurchaseProduct {
  private typealias bridge = margelo.nitro.one.bridge.swift

  /**
   * Create a new instance of `PurchaseProduct`.
   */
  init(id: String, type: PurchaseProductType, displayName: String, description: String, displayPrice: String, currencyCode: String?) {
    self.init(std.string(id), type, std.string(displayName), std.string(description), std.string(displayPrice), { () -> bridge.std__optional_std__string_ in
      if let __unwrappedValue = currencyCode {
        return bridge.create_std__optional_std__string_(std.string(__unwrappedValue))
      } else {
        return .init()
      }
    }())
  }

  @inline(__always)
  var id: String {
    return String(self.__id)
  }

  @inline(__always)
  var type: PurchaseProductType {
    return self.__type
  }

  @inline(__always)
  var displayName: String {
    return String(self.__displayName)
  }

  @inline(__always)
  var description: String {
    return String(self.__description)
  }

  @inline(__always)
  var displayPrice: String {
    return String(self.__displayPrice)
  }

  @inline(__always)
  var currencyCode: String? {
    return { () -> String? in
      if bridge.has_value_std__optional_std__string_(self.__currencyCode) {
        let __unwrapped = bridge.get_std__optional_std__string_(self.__currencyCode)
        return String(__unwrapped)
      } else {
        return nil
      }
    }()
  }
}
