From 6eca6938002149e5319396eb72376ea83cef32bd Mon Sep 17 00:00:00 2001 From: Hadi Sharghi Date: Mon, 30 Oct 2023 15:00:36 +0330 Subject: [PATCH] add default nil value for optional parameters --- .../Billing/Quotes/QuoteRoutes.swift | 36 +++++++++---------- .../Disputes/DisputeRoutes.swift | 4 +-- .../Core Resources/Refunds/RefundRoutes.swift | 2 +- .../Products/Prices/PriceRoutes.swift | 18 +++++----- 4 files changed, 30 insertions(+), 30 deletions(-) diff --git a/Sources/StripeKit/Billing/Quotes/QuoteRoutes.swift b/Sources/StripeKit/Billing/Quotes/QuoteRoutes.swift index 5cebbc5b..8fa2dcea 100644 --- a/Sources/StripeKit/Billing/Quotes/QuoteRoutes.swift +++ b/Sources/StripeKit/Billing/Quotes/QuoteRoutes.swift @@ -272,24 +272,24 @@ public struct StripeQuoteRoutes: QuoteRoutes { } public func update(quote: String, - lineItems: [[String: Any]]?, - metadata: [String: String]?, - applicationFeeAmount: Int?, - applicationFeePercent: String?, - automaticTax: [String: Any]?, - collectionMethod: QuoteCollectionMethod?, - customer: String?, - defaultTaxRates: [String]?, - description: String?, - discounts: [[String: Any]]?, - expiresAt: Date?, - footer: String?, - header: String?, - invoiceSettings: [String: Any]?, - onBehalfOf: String?, - subscriptionData: [String: Any]?, - transferData: [String: Any]?, - expand: [String]?) async throws -> Quote { + lineItems: [[String: Any]]? = nil, + metadata: [String: String]? = nil, + applicationFeeAmount: Int? = nil, + applicationFeePercent: String? = nil, + automaticTax: [String: Any]? = nil, + collectionMethod: QuoteCollectionMethod? = nil, + customer: String? = nil, + defaultTaxRates: [String]? = nil, + description: String? = nil, + discounts: [[String: Any]]? = nil, + expiresAt: Date? = nil, + footer: String? = nil, + header: String? = nil, + invoiceSettings: [String: Any]? = nil, + onBehalfOf: String? = nil, + subscriptionData: [String: Any]? = nil, + transferData: [String: Any]? = nil, + expand: [String]? = nil) async throws -> Quote { var body: [String: Any] = [:] if let lineItems { diff --git a/Sources/StripeKit/Core Resources/Disputes/DisputeRoutes.swift b/Sources/StripeKit/Core Resources/Disputes/DisputeRoutes.swift index 6660fec7..b83e2dd3 100644 --- a/Sources/StripeKit/Core Resources/Disputes/DisputeRoutes.swift +++ b/Sources/StripeKit/Core Resources/Disputes/DisputeRoutes.swift @@ -95,7 +95,7 @@ public struct StripeDisputeRoutes: DisputeRoutes { return try await apiHandler.send(method: .POST, path: "\(disputes)/\(dispute)", body: .string(body.queryParameters), headers: headers) } - public func close(dispute: String, expand: [String]?) async throws -> Dispute { + public func close(dispute: String, expand: [String]? = nil) async throws -> Dispute { var body: [String: Any] = [:] if let expand { @@ -105,7 +105,7 @@ public struct StripeDisputeRoutes: DisputeRoutes { return try await apiHandler.send(method: .POST, path: "\(disputes)/\(dispute)/close", body: .string(body.queryParameters), headers: headers) } - public func listAll(filter: [String : Any]?) async throws -> DisputeList { + public func listAll(filter: [String : Any]? = nil) async throws -> DisputeList { var queryParams = "" if let filter { queryParams = filter.queryParameters diff --git a/Sources/StripeKit/Core Resources/Refunds/RefundRoutes.swift b/Sources/StripeKit/Core Resources/Refunds/RefundRoutes.swift index f99f311d..d0fbdcbf 100644 --- a/Sources/StripeKit/Core Resources/Refunds/RefundRoutes.swift +++ b/Sources/StripeKit/Core Resources/Refunds/RefundRoutes.swift @@ -133,7 +133,7 @@ public struct StripeRefundRoutes: RefundRoutes { return try await apiHandler.send(method: .POST, path: refunds, body: .string(body.queryParameters), headers: headers) } - public func retrieve(refund: String, expand: [String]?) async throws -> Refund { + public func retrieve(refund: String, expand: [String]? = nil) async throws -> Refund { var queryParams = "" if let expand { queryParams = ["expand": expand].queryParameters diff --git a/Sources/StripeKit/Products/Prices/PriceRoutes.swift b/Sources/StripeKit/Products/Prices/PriceRoutes.swift index bb3e0176..4535b2a9 100644 --- a/Sources/StripeKit/Products/Prices/PriceRoutes.swift +++ b/Sources/StripeKit/Products/Prices/PriceRoutes.swift @@ -208,15 +208,15 @@ public struct StripePriceRoutes: PriceRoutes { } public func update(price: String, - active: Bool?, - metadata: [String: String]?, - nickname: String?, - currencyOptions: [String: [String: Any]]?, - lookupKey: String?, - taxBehavior: PriceTaxBehavior?, - transferLookupKey: String?, - expand: [String]?) async throws -> Price { - + active: Bool? = nil, + metadata: [String: String]? = nil, + nickname: String? = nil, + currencyOptions: [String: [String: Any]]? = nil, + lookupKey: String? = nil, + taxBehavior: PriceTaxBehavior? = nil, + transferLookupKey: String? = nil, + expand: [String]? = nil) async throws -> Price { + var body: [String: Any] = [:] if let active {