Skip to content

Commit

Permalink
Merge pull request #2 from Andrewangeta/Plans
Browse files Browse the repository at this point in the history
Plans and other fixes
  • Loading branch information
anthonycastelli authored Jun 6, 2017
2 parents 1404a85 + c50fd68 commit 480cdce
Show file tree
Hide file tree
Showing 57 changed files with 2,136 additions and 864 deletions.
13 changes: 12 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,12 @@ XCTMain([
* [x] Deleting
* [x] Fetching by Coupon ID
* [x] Listing All Coupons (With filters)
* [ ] Disputes
* [x] Plans
* [x] Creating
* [x] Updating
* [x] Deleting
* [x] Fetching by Plan ID
* [x] Listing All Plans (With filters)
* [x] Refunds
* [x] Creating a Refund
* [x] Retrieval
Expand All @@ -93,6 +98,12 @@ XCTMain([
* [x] Card Creation
* [x] Bank Creation
* [x] Token Retrieval
* [x] Sources
* [x] Creating
* [x] Updating
* [x] Fetching by Source ID
* [ ] Subscriptions
* [ ] Disputes
* [ ] Cards
* [ ] Orders
* [ ] Order Items
Expand Down
2 changes: 1 addition & 1 deletion Sources/API/Filter/StripeFilter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ public final class StripeFilter {
}

if let value = self.source {
node["source"] = value.rawType.makeNode(in: nil)
node["source"] = value.rawValue.makeNode(in: nil)
}

if let value = self.startingAfter {
Expand Down
21 changes: 20 additions & 1 deletion Sources/API/Helpers/Endpoints.swift
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,20 @@ internal enum API {
case coupons
case coupon(String)

/**
PLANS
A subscription plan contains the pricing information for different products and feature levels on your site.
*/
case plans
case plan(String)

/**
SOURCES
Source objects allow you to accept a variety of payment methods. They represent a customer's payment instrument and can be used with the Stripe API just like a card object: once chargeable, they can be charged, or attached to customers.
*/
case sources
case source(String)

var endpoint: String {
switch self {
case .balance: return APIBase + APIVersion + "balance"
Expand All @@ -106,7 +120,12 @@ internal enum API {

case .coupons: return APIBase + APIVersion + "coupons"
case .coupon(let id): return APIBase + APIVersion + "coupons/\(id)"

case .plans: return APIBase + APIVersion + "plans"
case .plan(let id): return APIBase + APIVersion + "plans/\(id)"

case .sources: return APIBase + APIVersion + "sources"
case .source(let id): return APIBase + APIVersion + "sources/\(id)"
}
}

}
7 changes: 4 additions & 3 deletions Sources/API/Routes/BalanceRoutes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,11 @@ public final class BalanceRoutes {
Retrieve a balance transaction
Retrieves the balance transaction with the given ID.

- parameter transactionId: The ID of the desired balance transaction (as found on any API object that affects the balance, e.g. a charge or transfer).

- returns: A StripeRequest<> item which you can then use to convert to the corresponding node
*/
public func retrieveBalance(forTransaction transactionId: String) throws -> StripeRequest<BalanceTransactionItem> {
public func retrieveBalanceTransaction(_ transactionId: String) throws -> StripeRequest<BalanceTransactionItem> {
return try StripeRequest(client: self.client, method: .get, route: .balanceHistoryTransaction(transactionId), query: [:], body: nil, headers: nil)
}

Expand All @@ -47,12 +49,11 @@ public final class BalanceRoutes {

- returns: A StripeRequest<> item which you can then use to convert to the corresponding node
*/
public func history(forFilter filter: StripeFilter?=nil) throws -> StripeRequest<BalanceHistoryList> {
public func history(forFilter filter: StripeFilter? = nil) throws -> StripeRequest<BalanceHistoryList> {
var query = [String : NodeRepresentable]()
if let data = try filter?.createQuery() {
query = data
}
return try StripeRequest(client: self.client, method: .get, route: .balanceHistory, query: query, body: nil, headers: nil)
}

}
Loading

0 comments on commit 480cdce

Please sign in to comment.