Skip to content

Commit

Permalink
Merge pull request #20 from vapor-community/testability
Browse files Browse the repository at this point in the history
Made Routes and Models open for easier testability when mocking.
  • Loading branch information
anthonycastelli authored Nov 12, 2017
2 parents 0d09696 + 6b0f33b commit b995ce2
Show file tree
Hide file tree
Showing 81 changed files with 142 additions and 184 deletions.
2 changes: 1 addition & 1 deletion Sources/Stripe/API/Routes/AccountRoutes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import Node
import HTTP

public final class AccountRoutes {
open class AccountRoutes {
let client: StripeClient

init(client: StripeClient) {
Expand Down
2 changes: 1 addition & 1 deletion Sources/Stripe/API/Routes/BalanceRoutes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import Node

public final class BalanceRoutes {
open class BalanceRoutes {

let client: StripeClient

Expand Down
2 changes: 1 addition & 1 deletion Sources/Stripe/API/Routes/ChargeRoutes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public enum ChargeType {
case customer(String)
}

public final class ChargeRoutes {
open class ChargeRoutes {

let client: StripeClient

Expand Down
2 changes: 1 addition & 1 deletion Sources/Stripe/API/Routes/CouponRoutes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import Node
import HTTP

public final class CouponRoutes {
open class CouponRoutes {
let client: StripeClient

init(client: StripeClient) {
Expand Down
2 changes: 1 addition & 1 deletion Sources/Stripe/API/Routes/CustomerRoutes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import Node
import HTTP

public final class CustomerRoutes {
open class CustomerRoutes {

let client: StripeClient

Expand Down
2 changes: 1 addition & 1 deletion Sources/Stripe/API/Routes/DisputeRoutes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import Node
import HTTP

public final class DisputeRoutes {
open class DisputeRoutes {
let client: StripeClient

init(client: StripeClient) {
Expand Down
2 changes: 1 addition & 1 deletion Sources/Stripe/API/Routes/EphemeralKeyRoutes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import HTTP
import Node

public final class EphemeralKeyRoutes {
open class EphemeralKeyRoutes {
let client: StripeClient

init(client: StripeClient) {
Expand Down
2 changes: 1 addition & 1 deletion Sources/Stripe/API/Routes/InvoiceItemRoutes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import Node
import HTTP

public final class InvoiceItemRoutes {
open class InvoiceItemRoutes {

let client: StripeClient

Expand Down
2 changes: 1 addition & 1 deletion Sources/Stripe/API/Routes/InvoiceRoutes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import Node
import HTTP

public final class InvoiceRoutes {
open class InvoiceRoutes {

let client: StripeClient

Expand Down
2 changes: 1 addition & 1 deletion Sources/Stripe/API/Routes/OrderReturnRoutes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import Node

public final class OrderReturnRoutes {
open class OrderReturnRoutes {
let client: StripeClient

init(client: StripeClient) {
Expand Down
2 changes: 1 addition & 1 deletion Sources/Stripe/API/Routes/OrderRoutes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import Node
import HTTP

public final class OrderRoutes {
open class OrderRoutes {
let client: StripeClient

init(client: StripeClient) {
Expand Down
2 changes: 1 addition & 1 deletion Sources/Stripe/API/Routes/PlanRoutes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import Node
import HTTP

public final class PlanRoutes {
open class PlanRoutes {
let client: StripeClient

init(client: StripeClient) {
Expand Down
2 changes: 1 addition & 1 deletion Sources/Stripe/API/Routes/ProductRoutes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import Node
import HTTP

public final class ProductRoutes {
open class ProductRoutes {
let client: StripeClient

init(client: StripeClient) {
Expand Down
2 changes: 1 addition & 1 deletion Sources/Stripe/API/Routes/RefundRoutes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import Node
import HTTP

public final class RefundRoutes {
open class RefundRoutes {

let client: StripeClient

Expand Down
2 changes: 1 addition & 1 deletion Sources/Stripe/API/Routes/SKURoutes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import Node
import HTTP

public final class SKURoutes {
open class SKURoutes {
let client: StripeClient

init(client: StripeClient) {
Expand Down
2 changes: 1 addition & 1 deletion Sources/Stripe/API/Routes/SourceRoutes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import Node
import HTTP

public final class SourceRoutes {
open class SourceRoutes {

let client: StripeClient

Expand Down
2 changes: 1 addition & 1 deletion Sources/Stripe/API/Routes/SubscriptionItemRoutes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import Node
import HTTP

public final class SubscriptionItemRoutes {
open class SubscriptionItemRoutes {

let client: StripeClient

Expand Down
2 changes: 1 addition & 1 deletion Sources/Stripe/API/Routes/SubscriptionRoutes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import HTTP
import Node

public final class SubscriptionRoutes {
open class SubscriptionRoutes {

let client: StripeClient

Expand Down
2 changes: 1 addition & 1 deletion Sources/Stripe/API/Routes/TokenRoutes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import Node
import HTTP

public final class TokenRoutes {
open class TokenRoutes {

let client: StripeClient

Expand Down
4 changes: 2 additions & 2 deletions Sources/Stripe/Models/Balance/Balance.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@

import Node

public final class Balance: StripeModelProtocol {
open class Balance: StripeModelProtocol {

public private(set) var object: String?
public private(set) var isLiveMode: Bool?
public private(set) var available: [BalanceTransfer]?
public private(set) var pending: [BalanceTransfer]?

public init(node: Node) throws {
public required init(node: Node) throws {
self.object = try node.get("object")
self.isLiveMode = try node.get("livemode")
self.available = try node.get("available")
Expand Down
4 changes: 2 additions & 2 deletions Sources/Stripe/Models/Balance/BalanceHistoryList.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@
import Foundation
import Vapor

public final class BalanceHistoryList: StripeModelProtocol {
open class BalanceHistoryList: StripeModelProtocol {

public private(set) var object: String?
public private(set) var url: String?
public private(set) var hasMore: Bool?
public private(set) var items: [BalanceTransactionItem]?

public init(node: Node) throws {
public required init(node: Node) throws {
self.object = try node.get("object")
self.url = try node.get("url")
self.hasMore = try node.get("has_more")
Expand Down
5 changes: 2 additions & 3 deletions Sources/Stripe/Models/Balance/BalanceTransactionItem.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
import Foundation
import Vapor


public final class BalanceTransactionItem: StripeModelProtocol {
open class BalanceTransactionItem: StripeModelProtocol {

public private(set) var id: String?
public private(set) var object: String?
Expand All @@ -25,7 +24,7 @@ public final class BalanceTransactionItem: StripeModelProtocol {
public private(set) var status: StripeStatus?
public private(set) var type: ActionType?

public init(node: Node) throws {
public required init(node: Node) throws {
self.id = try node.get("id")
self.object = try node.get("object")
self.amount = try node.get("amount")
Expand Down
4 changes: 1 addition & 3 deletions Sources/Stripe/Models/Balance/BalanceTransfer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,11 @@

import Node



/**
Balance transfer is the body object of available array.
https://stripe.com/docs/api/curl#balance_object
*/
public class BalanceTransfer: StripeModelProtocol {
open class BalanceTransfer: StripeModelProtocol {

public private(set) var currency: StripeCurrency?
public private(set) var amount: Int?
Expand Down
6 changes: 2 additions & 4 deletions Sources/Stripe/Models/Charges/Charge.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import Vapor
Charge Model
https://stripe.com/docs/api/curl#charge_object
*/
public final class Charge: StripeModelProtocol {
open class Charge: StripeModelProtocol {

public private(set) var id: String?
public private(set) var object: String?
Expand Down Expand Up @@ -60,9 +60,7 @@ public final class Charge: StripeModelProtocol {
public private(set) var shippingLabel: ShippingLabel?
public private(set) var transferGroup: String?

public init() {}

public init(node: Node) throws {
public required init(node: Node) throws {
self.id = try node.get("id")
self.object = try node.get("object")
self.amount = try node.get("amount")
Expand Down
4 changes: 2 additions & 2 deletions Sources/Stripe/Models/Charges/ChargeList.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
import Foundation
import Vapor

public final class ChargeList: StripeModelProtocol {
open class ChargeList: StripeModelProtocol {

public private(set) var object: String?
public private(set) var hasMore: Bool?
public private(set) var items: [Charge]?

public init(node: Node) throws {
public required init(node: Node) throws {
self.object = try node.get("object")
self.hasMore = try node.get("has_more")
self.items = try node.get("data")
Expand Down
4 changes: 2 additions & 2 deletions Sources/Stripe/Models/Charges/FruadDetails.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ public enum FraudReport: String {
case fraudulent = "fraudulent"
}

public final class FraudDetails: StripeModelProtocol {
open class FraudDetails: StripeModelProtocol {

public private(set) var userReport: FraudReport?
public private(set) var stripeReport: FraudReport?

public init(node: Node) throws {
public required init(node: Node) throws {
if let value: String? = try node.get("user_report") {
if let value = value {
self.userReport = FraudReport(rawValue: value)
Expand Down
4 changes: 2 additions & 2 deletions Sources/Stripe/Models/Charges/Outcome.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public enum OutcomeType: String {
case invalid = "invalid"
}

public final class Outcome: StripeModelProtocol {
open class Outcome: StripeModelProtocol {

public private(set) var networkStatus: NetworkStatus?
public private(set) var reason: String?
Expand All @@ -46,7 +46,7 @@ public final class Outcome: StripeModelProtocol {
public private(set) var sellerMessage: String?
public private(set) var type: OutcomeType?

public init(node: Node) throws {
public required init(node: Node) throws {
if let networkStatus = node["network_status"]?.string {
self.networkStatus = NetworkStatus(rawValue: networkStatus)
}
Expand Down
4 changes: 2 additions & 2 deletions Sources/Stripe/Models/Charges/Refund.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ import Vapor
https://stripe.com/docs/api/curl#charge_object-refunds
*/

public final class Refund: StripeModelProtocol {
open class Refund: StripeModelProtocol {

public private(set) var object: String?
public private(set) var hasMore: Bool
public private(set) var totalCount: Int?
public private(set) var url: String?
public private(set) var items: [RefundItem]?

public init(node: Node) throws {
public required init(node: Node) throws {
self.object = try node.get("object")
self.items = try node.get("data")
self.hasMore = try node.get("has_more")
Expand Down
5 changes: 2 additions & 3 deletions Sources/Stripe/Models/Charges/RefundItem.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
import Foundation
import Vapor


public final class RefundItem: StripeModelProtocol {
open class RefundItem: StripeModelProtocol {

public private(set) var id: String?
public private(set) var object: String?
Expand All @@ -25,7 +24,7 @@ public final class RefundItem: StripeModelProtocol {
public private(set) var receiptNumber: String?
public private(set) var status: StripeStatus?

public init(node: Node) throws {
public required init(node: Node) throws {
self.id = try node.get("id")
self.object = try node.get("object")
self.amount = try node.get("amount")
Expand Down
4 changes: 2 additions & 2 deletions Sources/Stripe/Models/Connect/Account.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import Vapor
https://stripe.com/docs/api#account_object
*/

public final class ConnectAccount: StripeModelProtocol {
open class ConnectAccount: StripeModelProtocol {

public private(set) var id: String?
public private(set) var object: String?
Expand Down Expand Up @@ -46,7 +46,7 @@ public final class ConnectAccount: StripeModelProtocol {
public private(set) var verification: Verification?
public private(set) var keys: Node?

public init(node: Node) throws {
public required init(node: Node) throws {
self.id = try node.get("id")
self.object = try node.get("object")
self.businessName = try node.get("business_name")
Expand Down
5 changes: 2 additions & 3 deletions Sources/Stripe/Models/Connect/AccountList.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,13 @@
import Foundation
import Vapor


public final class AccountList: StripeModelProtocol {
open class AccountList: StripeModelProtocol {
public private(set) var object: String?
public private(set) var url: String?
public private(set) var hasMore: Bool?
public private(set) var items: [ConnectAccount]?

public init(node: Node) throws {
public required init(node: Node) throws {
self.object = try node.get("object")
self.url = try node.get("url")
self.hasMore = try node.get("has_more")
Expand Down
5 changes: 2 additions & 3 deletions Sources/Stripe/Models/Connect/AdditionalOwner.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,15 @@
import Foundation
import Vapor


public final class AdditionalOwner: StripeModelProtocol {
open class AdditionalOwner: StripeModelProtocol {

public private(set) var firstName: String?
public private(set) var lastName: String?
public private(set) var dateOfBirth: Node?
public private(set) var address: ShippingAddress?
public private(set) var verification: Verification?

public init(node: Node) throws {
public required init(node: Node) throws {
self.firstName = try node.get("first_name")
self.lastName = try node.get("last_name")
self.dateOfBirth = try node.get("dob")
Expand Down
Loading

0 comments on commit b995ce2

Please sign in to comment.