-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from vapor-community/Disputes
Support for Disputes
- Loading branch information
Showing
16 changed files
with
908 additions
and
32 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
// | ||
// DisputeRoutes.swift | ||
// Stripe | ||
// | ||
// Created by Andrew Edwards on 7/12/17. | ||
// | ||
// | ||
|
||
import Foundation | ||
import Node | ||
import Models | ||
import Helpers | ||
import HTTP | ||
import Errors | ||
|
||
public final class DisputeRoutes { | ||
let client: StripeClient | ||
|
||
init(client: StripeClient) { | ||
self.client = client | ||
} | ||
|
||
public func retrieve( dispute disputeId: String) throws -> StripeRequest<Dispute> { | ||
return try StripeRequest(client: self.client, method: .get, route: .disputes(disputeId), query: [:], body: nil, headers: nil) | ||
} | ||
|
||
public func update(dispute disputeId: String, evidence: Node?, submit: Bool?, metadata: Node? = nil) throws -> StripeRequest<Dispute> { | ||
var body = Node([:]) | ||
|
||
if let evidence = evidence?.object { | ||
for (key, value) in evidence { | ||
body["evidence[\(key)]"] = value | ||
} | ||
} | ||
|
||
if let submit = submit { | ||
body["submit"] = Node(submit) | ||
} | ||
|
||
if let metadata = metadata?.object { | ||
for (key, value) in metadata { | ||
body["metadata[\(key)]"] = value | ||
} | ||
} | ||
|
||
return try StripeRequest(client: self.client, method: .post, route: .disputes(disputeId), query: [:], body: Body.data(body.formURLEncoded()), headers: nil) | ||
} | ||
|
||
public func close(dispute disputeId: String) throws -> StripeRequest<Dispute> { | ||
return try StripeRequest(client: self.client, method: .post, route: .closeDispute(disputeId), query: [:], body: nil, headers: nil) | ||
} | ||
|
||
public func listAll(filter: StripeFilter?) throws -> StripeRequest<DisputeList> { | ||
var query = [String : NodeRepresentable]() | ||
if let data = try filter?.createQuery() { | ||
query = data | ||
} | ||
return try StripeRequest(client: self.client, method: .get, route: .dispute, query: query, body: nil, headers: nil) | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// | ||
// DisputeReason.swift | ||
// Stripe | ||
// | ||
// Created by Andrew Edwards on 7/11/17. | ||
// | ||
// | ||
|
||
import Foundation | ||
|
||
public enum DisputeReason: String { | ||
case duplicate = "duplicate" | ||
case fraudulent = "fraudulent" | ||
case subscriptionCanceled = "subscription_canceled" | ||
case productUnacceptable = "product_unacceptable" | ||
case productNotReceived = "product_not_received" | ||
case unrecognized = "unrecognized" | ||
case creditNotProcessed = "credit_not_processed" | ||
case general = "general" | ||
case incorrectAccountDetails = "incorrect_account_details" | ||
case insufficientFunds = "insufficient_funds" | ||
case bankCannotProcess = "bank_cannot_process" | ||
case debitNotAuthorized = "debit_not_authorized" | ||
case customerInitiated = "customer_initiated" | ||
} | ||
|
||
public enum DisputeStatus: String { | ||
case warningNeedsResponse = "warning_needs_response" | ||
case warningUnderReview = "warning_under_review" | ||
case warningClosed = "warning_closed" | ||
case needsResponse = "needs_response" | ||
case underReview = "under_review" | ||
case chargeRefunded = "charge_refunded" | ||
case won = "won" | ||
case lost = "lost" | ||
} |
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 |
---|---|---|
|
@@ -7,7 +7,6 @@ | |
// | ||
|
||
import Foundation | ||
import Errors | ||
|
||
public enum SourceType: String | ||
{ | ||
|
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
Oops, something went wrong.