Skip to content

Commit

Permalink
Remove any force unwraps
Browse files Browse the repository at this point in the history
  • Loading branch information
anthonycastelli committed May 19, 2017
1 parent 802eb33 commit ceb4e00
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
6 changes: 3 additions & 3 deletions Sources/Models/Balance/Transaction.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ import Helpers

public class Transfer: StripeModelProtocol {

public let currency: StripeCurrency!
public let currency: StripeCurrency
public let amount: Int
public private(set) var sourceTypes = [SourceType]()

public required init(node: Node) throws {
self.currency = try StripeCurrency(rawValue: node.get("currency"))
self.currency = try StripeCurrency(rawValue: node.get("currency"))!
self.amount = try node.get("amount")
let items: [String : Int] = try node.get("source_types")
self.sourceTypes = try items.map { try SourceType(type: $0.key, amount: $0.value) }
Expand All @@ -30,7 +30,7 @@ public class Transfer: StripeModelProtocol {
}

return try Node(node: [
"currency": self.currency,
"currency": self.currency.rawValue,
"amount": self.amount,
"source_types": types
])
Expand Down
6 changes: 4 additions & 2 deletions Sources/Models/Customer/Customer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import Helpers
*/
public final class Customer: StripeModelProtocol {

public private(set) var id: String!
public private(set) var id: String
public private(set) var object: String?
public var accountBalance: Int?
public private(set) var created: Date?
Expand All @@ -34,7 +34,9 @@ public final class Customer: StripeModelProtocol {
public private(set) var sources: SourceList?
public private(set) var subscriptions: SubscriptionList?

public init() { }
public init() {
self.id = ""
}

public init(node: Node) throws {
self.id = try node.get("id")
Expand Down

0 comments on commit ceb4e00

Please sign in to comment.