// Copyright © 2022 Olo Inc. All rights reserved.
// This software is made available under the Olo Pay SDK License (See LICENSE.md file)
//
//  OPPaymentMethodProtocolExtensions.swift
//  OlopaysdkReactNative
//
//  Created by Justin Anderson on 3/31/23.
//  Copyright © 2023 Facebook. All rights reserved.
//

import Foundation
import OloPaySDK

extension OPPaymentMethodProtocol {
    public func toDictionary() -> [String: Any] {
        return [
            DataKeys.IDKey: self.id,
            DataKeys.Last4Key: self.last4 ?? "",
            DataKeys.CardTypeKey: self.cardType.description,
            DataKeys.ExpirationMonthKey: self.expirationMonth ?? "",
            DataKeys.ExpirationYearKey: self.expirationYear ?? "",
            DataKeys.PostalCodeKey: self.postalCode ?? "",
            DataKeys.CountryCodeKey: self.country ?? "",
            DataKeys.IsDigitalWalletKey: self.isApplePay,
            DataKeys.ProductionEnvironmentKey: self.environment == .production
        ]
    }
}
