Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add default nil value for optional parameters #240

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 18 additions & 18 deletions Sources/StripeKit/Billing/Quotes/QuoteRoutes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 9 additions & 9 deletions Sources/StripeKit/Products/Prices/PriceRoutes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down