Skip to content

Commit

Permalink
PR Feedback - syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
scannillo committed Jun 25, 2024
1 parent 4259c38 commit 8fd0f6d
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 33 deletions.
2 changes: 1 addition & 1 deletion Sources/BraintreePayPal/BTPayPalVaultRequest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ import BraintreeCore
/// - Parameters:
/// - offerCredit: Optional: Offers PayPal Credit if the customer qualifies. Defaults to `false`.
/// - recurringBillingDetails: Optional: Recurring billing product details.
/// - recurringBillingPlanType: Optional: Recurring billing plan type.
/// - recurringBillingPlanType: Optional: Recurring billing plan type, or charge pattern.
/// - userAuthenticationEmail: Optional: User email to initiate a quicker authentication flow in cases where the user has a PayPal Account with the same email.
public init(
offerCredit: Bool = false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Foundation
public struct BTPayPalBillingCycle {

// MARK: - Public Types

/// The interval at which the payment is charged or billed.
public enum BillingInterval: String {
case day = "DAY"
Expand All @@ -16,24 +16,18 @@ public struct BTPayPalBillingCycle {
// MARK: - Private Properties

private let interval: BillingInterval

private let intervalCount: Int

private let numberOfExecutions: Int

private let sequence: Int?

private let startDate: String?

private let isTrial: Bool

private let pricing: BTPayPalBillingPricing?

// MARK: - Initializer

/// Initialize a `BTPayPalBillingCycle` object.
/// - Parameters:
/// - intervalCount: The number of intervals after which a subscriber is charged or billed.
/// - interval: The number of intervals after which a subscriber is charged or billed.
/// - intervalCount: The number of times this billing cycle gets executed. For example, if the `intervalCount` is DAY with an `intervalCount` of 2, the subscription is billed once every two days. Maximum values {DAY -> 365}, {WEEK, 52}, {MONTH, 12}, {YEAR, 1}.
/// - numberOfExecutions: The number of times this billing cycle gets executed. Trial billing cycles can only be executed a finite number of times (value between 1 and 999). Regular billing cycles can be executed infinite times (value of 0) or a finite number of times (value between 1 and 999).
/// - sequence: The sequence of the billing cycle. Used to identify unique billing cycles. For example, sequence 1 could be a 3 month trial period, and sequence 2 could be a longer term full rater cycle. Max value 100. All billing cycles should have unique sequence values.
Expand Down Expand Up @@ -61,12 +55,12 @@ public struct BTPayPalBillingCycle {
// MARK: - Internal Methods

func parameters() -> [String: Any] {
var parameters: [String: Any] = [:]

parameters["billing_frequency"] = intervalCount
parameters["billing_frequency_unit"] = interval.rawValue
parameters["number_of_executions"] = numberOfExecutions
parameters["trial"] = isTrial
var parameters: [String: Any] = [
"billing_frequency": intervalCount,
"billing_frequency_unit": interval.rawValue,
"number_of_executions": numberOfExecutions,
"trial": isTrial
]

if let sequence {
parameters["sequence"] = sequence
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@ public struct BTPayPalBillingPricing {
// MARK: - Private Properties

private let pricingModel: PricingModel

private let amount: String

private let reloadThresholdAmount: String?

// MARK: - Initializer
Expand All @@ -36,10 +34,10 @@ public struct BTPayPalBillingPricing {
// MARK: - Internal Methods

func parameters() -> [String: Any] {
var parameters: [String: Any] = [:]

parameters["pricing_model"] = pricingModel.rawValue
parameters["price"] = amount
var parameters: [String: Any] = [
"pricing_model": pricingModel.rawValue,
"price": amount
]

if let reloadThresholdAmount {
parameters["reload_threshold_amount"] = reloadThresholdAmount
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,13 @@ public struct BTPayPalRecurringBillingDetails {
// MARK: - Private Properties

private let billingCycles: [BTPayPalBillingCycle]

private let currencyISOCode: String

private let productName: String?

private let productDescription: String?

private let productQuantity: Int?

private let oneTimeFeeAmount: String?

private let shippingAmount: String?

private let productAmount: String?

private let taxAmount: String?

// MARK: - Initializer
Expand Down Expand Up @@ -61,10 +53,10 @@ public struct BTPayPalRecurringBillingDetails {
// MARK: - Internal Methods

func parameters() -> [String: Any] {
var parameters: [String: Any] = [:]

parameters["currency_iso_code"] = currencyISOCode
parameters["billing_cycles"] = billingCycles.map({ $0.parameters() })
var parameters: [String: Any] = [
"currency_iso_code": currencyISOCode,
"billing_cycles": billingCycles.map { $0.parameters() }
]

if let productName {
parameters["name"] = productName
Expand Down

0 comments on commit 8fd0f6d

Please sign in to comment.