-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
API updates and support for quotes and verification APIs.
- Loading branch information
1 parent
9ab8c28
commit be61a70
Showing
37 changed files
with
2,282 additions
and
109 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
Sources/StripeKit/Billing/Quote Line Items/QuoteLineItem.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
// | ||
// QuoteLineItem.swift | ||
// StripeKit | ||
// | ||
// Created by Andrew Edwards on 7/25/21. | ||
// | ||
|
||
import Foundation | ||
|
||
public struct StripeQuoteLineItem: StripeModel { | ||
/// Unique identifier for the object. | ||
public var id: String | ||
/// String representing the object’s type. Objects of the same type share the same value. | ||
public var object: String | ||
/// Total before any discounts or taxes are applied. | ||
public var amountSubtotal: Int? | ||
/// Total after discounts and taxes. | ||
public var amountTotal: Int? | ||
/// Three-letter ISO currency code, in lowercase. Must be a supported currency. | ||
public var currency: StripeCurrency? | ||
/// An arbitrary string attached to the object. Often useful for displaying to users. Defaults to product name. | ||
public var description: String? | ||
/// This field is not included by default. To include it in the response, expand the `discounts` field. | ||
public var discounts: [StripeQuoteLineItemDiscount]? | ||
/// The price used to generate the line item. | ||
public var price: StripePrice? | ||
/// The quantity of products being purchased. | ||
public var quantity: Int? | ||
/// The taxes applied to the line item. | ||
/// | ||
/// This field is not included by default. To include it in the response, expand the `taxes` field. | ||
public var taxes: [StripeQuoteLineItemTax]? | ||
} | ||
|
||
public struct StripeQuoteLineItemDiscount: StripeModel { | ||
/// The amount discounted. | ||
public var amount: Int? | ||
/// The discount applied. | ||
public var discount: StripeDiscount? | ||
} | ||
|
||
public struct StripeQuoteLineItemTax: StripeModel { | ||
/// Amount of tax applied for this rate. | ||
public var amount: Int? | ||
/// The tax rate applied. | ||
public var rate: StripeTaxRate? | ||
} | ||
|
||
public struct StripeQuoteLineItemList: StripeModel { | ||
public var object: String | ||
public var hasMore: Bool? | ||
public var url: String? | ||
public var data: [StripeQuoteLineItem]? | ||
} |
65 changes: 65 additions & 0 deletions
65
Sources/StripeKit/Billing/Quote Line Items/QuoteLineItemRoutes.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
// | ||
// QuoteLineItemRoutes.swift | ||
// StripeKit | ||
// | ||
// Created by Andrew Edwards on 7/25/21. | ||
// | ||
|
||
import NIO | ||
import NIOHTTP1 | ||
|
||
public protocol QuoteLineItemRoutes { | ||
/// When retrieving a quote, there is an includable `line_items` property containing the first handful of those items. There is also a URL where you can retrieve the full (paginated) list of line items. | ||
/// - Parameter quote: The ID of the quote | ||
/// - Parameter filter: A dictionary that will be used for the query parameters. | ||
/// - Returns: A `StripeQuoteLineItemList`. | ||
func retrieve(quote: String, filter: [String: Any]?) -> EventLoopFuture<StripeQuoteLineItemList> | ||
|
||
/// When retrieving a quote, there is an includable `upfront.line_items` property containing the first handful of those items. There is also a URL where you can retrieve the full (paginated) list of upfront line items. | ||
/// - Parameter quote: The ID of the quote | ||
/// - Parameter filter: A dictionary that will be used for the query parameters. | ||
/// - Returns: A `StripeQuoteLineItemList`. | ||
func retrieveUpfront(quote: String, filter: [String: Any]?) -> EventLoopFuture<StripeQuoteLineItemList> | ||
|
||
/// Headers to send with the request. | ||
var headers: HTTPHeaders { get set } | ||
} | ||
|
||
extension QuoteLineItemRoutes { | ||
public func retrieve(quote: String, filter: [String: Any]? = nil) -> EventLoopFuture<StripeQuoteLineItemList> { | ||
retrieve(quote: quote, filter: filter) | ||
} | ||
|
||
public func retrieveUpfront(quote: String, filter: [String: Any]? = nil) -> EventLoopFuture<StripeQuoteLineItemList> { | ||
retrieveUpfront(quote: quote, filter: filter) | ||
} | ||
} | ||
|
||
public struct StripeQuoteLineItemRoutes: QuoteLineItemRoutes { | ||
public var headers: HTTPHeaders = [:] | ||
|
||
private let apiHandler: StripeAPIHandler | ||
private let quotelineitems = APIBase + APIVersion + "quotes" | ||
|
||
init(apiHandler: StripeAPIHandler) { | ||
self.apiHandler = apiHandler | ||
} | ||
|
||
public func retrieve(quote: String, filter: [String: Any]?) -> EventLoopFuture<StripeQuoteLineItemList> { | ||
var queryParams = "" | ||
if let filter = filter { | ||
queryParams = filter.queryParameters | ||
} | ||
|
||
return apiHandler.send(method: .GET, path: "\(quotelineitems)/\(quote)/line_items", query: queryParams, headers: headers) | ||
} | ||
|
||
public func retrieveUpfront(quote: String, filter: [String: Any]?) -> EventLoopFuture<StripeQuoteLineItemList> { | ||
var queryParams = "" | ||
if let filter = filter { | ||
queryParams = filter.queryParameters | ||
} | ||
|
||
return apiHandler.send(method: .GET, path: "\(quotelineitems)/\(quote)/computed_upfront_line_items", query: queryParams, headers: headers) | ||
} | ||
} |
Oops, something went wrong.