<commit_before>//
//  PXCheckoutPreference+Business.swift
//  MercadoPagoSDKV4
//
//  Created by <NAME> on 04/09/2018.
//

import Foundation
extension PXCheckoutPreference {
    internal func isExpired() -> Bool {
        let date = Date()
        if let expirationDateTo = expirationDateTo {
            return expirationDateTo > date
        }
        return false
    }

    internal func isActive() -> Bool {
        let date = Date()
        if let expirationDateFrom = expirationDateFrom {
            return expirationDateFrom < date
        }
        return true
    }

    internal func hasMultipleItems() -> Bool {
        return items.count > 1
    }

    internal func clearCardId() {
        self.paymentPreference.cardId = nil
    }
}

// MARK: Setters
extension PXCheckoutPreference {
    /**
     Date that indicates when this preference expires.
     If the preference is expired, then the checkout will show an error.
     - parameter expirationDate: Date expiration.
     */
    open func setExpirationDate(_ expirationDate: Date) {
        self.expirationDateTo = expirationDate
    }

    /**
     Date that indicates when this preference start.
     - parameter date: Date active.
     */
    open func setActiveFromDate(_ date: Date) {
        self.expirationDateFrom = date
    }

    /**
     Differential pricing configuration for this preference.
     This object is related with the way the installments are asked.
     - parameter differentialPricing: `PXDifferentialPricing` pricing object.
     */
    open func setDifferentialPricing(differentialPricing: PXDifferentialPricing) {
        self.differentialPricing = differentialPricing
    }

    /**
     Add exclusion payment method id. If you exclude it, it's not going appear as a payment method available on checkout.
     - parameter paymentMethodId: paymentMethodId exclusion id.
     */
    public func addExcludedPaymentMethod(_ paymentMethodId: String) {
        paymentPreference.excludedPaymentMethodIds.append(paymentMethodId)
    }

    /**
     Add exclusion list by payment method id. If you exclude it, it's not going appear as a payment method available on checkout.
     - parameter paymentMethodIds: paymentMethodId exclusion id.
     */
    public func setExcludedPaymentMethods(_ paymentMethodIds: [String]) {
        self.paymentPreference.excludedPaymentMethodIds = paymentMethodIds
    }

    /**
     Add exclusion by payment type
     If you exclude it, it's not going appear as a payment method available on checkout
     - parameter paymentTypeId: paymentTypeId exclusion type
     */
    public func addExcludedPaymentType(_ paymentTypeId: String) {
        paymentPreference.excludedPaymentMethodIds.append(paymentTypeId)
    }

    /**
     Add exclusion list by payment type
     If you exclude it, it's not going appear as a payment method available on checkout
     - parameter paymentTypeIds: paymentTypeIds exclusion list.
     */
    public func setExcludedPaymentTypes(_ paymentTypeIds: [String]) {
        self.paymentPreference.excludedPaymentTypeIds = paymentTypeIds
    }

    /**
     This value limits the amount of installments to be shown by the user.
     - parameter maxInstallments: max installments to be shown
     */
    public func setMaxInstallments(_ maxInstallments: Int) {
        self.paymentPreference.maxAcceptedInstallments = maxInstallments
    }

    /**<commit_msg>Fix set in checkout preference<commit_after>//
//  PXCheckoutPreference+Business.swift
//  MercadoPagoSDKV4
//
//  Created by <NAME> on 04/09/2018.
//

import Foundation
extension PXCheckoutPreference {
    internal func isExpired() -> Bool {
        let date = Date()
        if let expirationDateTo = expirationDateTo {
            return expirationDateTo > date
        }
        return false
    }

    internal func isActive() -> Bool {
        let date = Date()
        if let expirationDateFrom = expirationDateFrom {
            return expirationDateFrom < date
        }
        return true
    }

    internal func hasMultipleItems() -> Bool {
        return items.count > 1
    }

    internal func clearCardId() {
        self.paymentPreference.cardId = nil
    }
}

// MARK: Setters
extension PXCheckoutPreference {
    /**
     Date that indicates when this preference expires.
     If the preference is expired, then the checkout will show an error.
     - parameter expirationDate: Date expiration.
     */
    open func setExpirationDate(_ expirationDate: Date) {
        self.expirationDateTo = expirationDate
    }

    /**
     Date that indicates when this preference start.
     - parameter date: Date active.
     */
    open func setActiveFromDate(_ date: Date) {
        self.expirationDateFrom = date
    }

    /**
     Differential pricing configuration for this preference.
     This object is related with the way the installments are asked.
     - parameter differentialPricing: `PXDifferentialPricing` pricing object.
     */
    open func setDifferentialPricing(differentialPricing: PXDifferentialPricing) {
        self.differentialPricing = differentialPricing
    }

    /**
     Add exclusion payment method id. If you exclude it, it's not going appear as a payment method available on checkout.
     - parameter paymentMethodId: paymentMethodId exclusion id.
     */
    public func addExcludedPaymentMethod(_ paymentMethodId: String) {
        paymentPreference.excludedPaymentMethodIds.append(paymentMethodId)
    }

    /**
     Add exclusion list by payment method id. If you exclude it, it's not going appear as a payment method available on checkout.
     - parameter paymentMethodIds: paymentMethodId exclusion id.
     */
    public func setExcludedPaymentMethods(_ paymentMethodIds: [String]) {
        self.paymentPreference.excludedPaymentMethodIds = paymentMethodIds
    }

    /**
     Add exclusion by payment type
     If you exclude it, it's not going appear as a payment method available on checkout
     - parameter paymentTypeId: paymentTypeId exclusion type
     */
    public func addExcludedPaymentType(_ paymentTypeId: String) {
        paymentPreference.excludedPaymentTypeIds.append(paymentTypeId)
    }

    /**
     Add exclusion list by payment type
     If you exclude it, it's not going appear as a payment method available on checkout
     - parameter paymentTypeIds: paymentTypeIds exclusion list.
     */
    public func setExcludedPaymentTypes(_ paymentTypeIds: [String]) {
        self.paymentPreference.excludedPaymentTypeIds = paymentTypeIds
    }

    /**
     This value limits the amount of installments to be shown by the user.
     - parameter maxInstallments: max installments to be shown
     */
    public func setMaxInstallments(_ maxInstallments: Int) {
        self.paymentPreference.maxAcceptedInstallments = maxInstallments
    }

    /**
{'fraction_non_alphanumeric': 0.06494076349275998, 'fraction_numerical': 0.00292525961679099, 'mean_word_length': 2.771649200220629, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6441618', 'n_tokens_mistral': 1836, 'n_tokens_neox': 1716, 'n_words': 588}