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

Update CardRoutes.swift #36

Merged
merged 7 commits into from
Mar 6, 2020
Merged
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
4 changes: 2 additions & 2 deletions Sources/StripeKit/Payment Methods/Cards/CardRoutes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public struct StripeCardRoutes: CardRoutes {
public var headers: HTTPHeaders = [:]

private let apiHandler: StripeAPIHandler
private let cards = APIBase + APIVersion + "customer"
private let cards = APIBase + APIVersion + "customers"

init(apiHandler: StripeAPIHandler) {
self.apiHandler = apiHandler
Expand Down Expand Up @@ -212,7 +212,7 @@ public struct StripeCardRoutes: CardRoutes {
return apiHandler.send(method: .DELETE, path: "\(cards)/\(customer)/sources/\(id)", headers: headers)
}

public func listAll(customer: String, filter: [String: Any]?) -> EventLoopFuture<StripeBankAccountList> {
public func listAll(customer: String, filter: [String: Any]?) -> EventLoopFuture<StripeCardList> {
var queryParams = "object=card"
if let filter = filter {
queryParams = "&" + filter.queryParameters
Expand Down
6 changes: 3 additions & 3 deletions Sources/StripeKit/StripeRequest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,11 @@ struct StripeDefaultAPIHandler: StripeAPIHandler {
let request = try HTTPClient.Request(url: "\(path)?\(query)", method: method, headers: _headers, body: body)

return httpClient.execute(request: request, eventLoop: .delegate(on: self.eventLoop)).flatMap { response in
guard var byteBuffer = response.body else {
guard let byteBuffer = response.body else {
fatalError("Response body from Stripe is missing! This should never happen.")
}
let responseData = byteBuffer.readData(length: byteBuffer.readableBytes)!
let responseData = Data(byteBuffer.readableBytesView)

do {
guard response.status == .ok else {
return self.eventLoop.makeFailedFuture(try self.decoder.decode(StripeError.self, from: responseData))
Expand Down