Skip to content

Commit 2192ce6

Browse files
author
Sam Ritchie
committed
Merge pull request #10 from racehub/feature/upgrade_cljc
upgrade to cljc
2 parents 6ed5a24 + 45a1448 commit 2192ce6

File tree

5 files changed

+48
-54
lines changed

5 files changed

+48
-54
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 0.3.0 (7/12/2015)
2+
3+
- Upgrade to Clojure 1.7.0 and cljc.
4+
15
## 0.2.1 (7/4/2015)
26

37
- Upgraded to latest API schema.

project.clj

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,18 @@
1-
(defproject racehub/stripe-clj "0.2.2-SNAPSHOT"
1+
(defproject racehub/stripe-clj "0.3.0-SNAPSHOT"
22
:description "Schemafied Stripe bindings for Clojure."
33
:url "https://github.com/racehub/stripe-clj"
44
:license {:name "Eclipse Public License"
55
:url "http://www.eclipse.org/legal/epl-v10.html"}
6-
:dependencies [[cheshire "5.3.1"]
6+
:dependencies [[cheshire "5.5.0"]
77
[environ "0.5.0"]
88
[http-kit "2.1.19"]
9-
[org.clojure/clojure "1.6.0"]
9+
[org.clojure/clojure "1.7.0"]
1010
[org.clojure/core.async "0.1.346.0-17112a-alpha"]
11-
[prismatic/schema "0.3.0" :exclude [org.clojure/clojurescript]]]
12-
:hooks [cljx.hooks]
11+
[racehub/schema "0.4.4"]]
1312
:jar-exclusions [#"\.cljx|\.swp|\.swo|\.DS_Store"]
14-
:source-paths ["src/clj" "target/generated/clj"]
15-
:resource-paths ["target/generated/cljs" "src/cljs" "resources"]
16-
:profiles {:1.7 {:dependencies [[org.clojure/clojure "1.7.0-alpha2"]]}
17-
:dev {:injections [(require 'schema.core)
13+
:source-paths ["src/clj"]
14+
:resource-paths ["src/cljs" "resources"]
15+
:profiles {:dev {:injections [(require 'schema.core)
1816
(schema.core/set-fn-validation! true)]
19-
:test-paths ["test/clj" "target/test/clj"]
20-
:plugins [[com.keminglabs/cljx "0.4.0"]
21-
[paddleguru/lein-gitflow "0.1.2"]]}}
22-
:cljx {:builds [{:source-paths ["src/cljx"]
23-
:output-path "target/generated/clj"
24-
:rules :clj}
25-
{:source-paths ["src/cljx"]
26-
:output-path "target/generated/cljs"
27-
:rules :cljs}]})
17+
:test-paths ["test/clj"]
18+
:plugins [[paddleguru/lein-gitflow "0.1.2"]]}})

src/cljx/stripe/schema.cljx renamed to src/clj/stripe/schema.cljc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
(ns stripe.schema
22
(:require [schema.core :as s :include-macros true]
3-
[#+clj clojure.core.async #+cljs cljs.core.async])
4-
#+clj (:import [clojure.core.async.impl.protocols ReadPort]))
3+
#?(:clj clojure.core.async :cljs cljs.core.async))
4+
#?(:clj
5+
(:import [clojure.core.async.impl.protocols ReadPort])))
56

67
;; ## Shared Schema
78

@@ -25,9 +26,8 @@
2526
schema is ignored, and just for documentation purposes."
2627
([] (Channel s/Any))
2728
([inner]
28-
(s/named #+cljs s/Any
29-
#+clj ReadPort
30-
"core.async channel.")))
29+
(s/named #?(:cljs s/Any :clj ReadPort)
30+
"core.async channel.")))
3131

3232
(def StripeError
3333
"Stripe API error."

src/cljx/stripe/token.cljx renamed to src/clj/stripe/token.cljc

Lines changed: 24 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
(ns stripe.token
22
(:require [schema.core :as s]
3-
#+clj [stripe.http :as h]
3+
#?(:clj [stripe.http :as h])
44
[stripe.schema :as ss]
55
[stripe.util :as u]))
66

@@ -55,31 +55,30 @@
5555

5656
;; ## Bank and Card Tokens
5757

58-
#+clj
5958
(do
60-
;; TODO: Add return schemas to the tokens.
61-
62-
(s/defn create-card-token :- (ss/Async)
63-
"Returns a card token if successful, errors otherwise. This endpoint
64-
also supports a customer token, but this is only good for Stripe
65-
Connect, so I'm leaving it out for now."
66-
[card :- CardMap]
67-
(h/post-req "tokens" {:stripe-params
68-
{:card card}}))
69-
70-
(s/defn create-bank-token :- (ss/Async)
71-
"Returns a bank token if successful, errors otherwise. The returned
72-
token is good for a one-time use - you have to attach it to a
73-
`recipient` object, or its worthless.
59+
#?@(:clj
60+
[ ;; TODO: Add return schemas to the tokens.
61+
(s/defn create-card-token :- (ss/Async)
62+
"Returns a card token if successful, errors otherwise. This
63+
endpoint also supports a customer token, but this is only good for
64+
Stripe Connect, so I'm leaving it out for now."
65+
[card :- CardMap]
66+
(h/post-req "tokens" {:stripe-params
67+
{:card card}}))
68+
69+
(s/defn create-bank-token :- (ss/Async)
70+
"Returns a bank token if successful, errors otherwise. The
71+
returned token is good for a one-time use - you have to attach it to
72+
a `recipient` object, or its worthless.
7473
7574
We hardcode Country here because the US is all that's currently
7675
supported by Stripe."
77-
[account :- BankMap]
78-
(h/post-req "tokens" {:stripe-params
79-
{:bank_account (assoc account
80-
:country "US")}}))
81-
82-
(s/defn get-token :- (ss/Async)
83-
"Returns a card or bank object if successful, errors otherwise."
84-
[token :- (s/either CardToken BankToken)]
85-
(h/get-req (str "tokens/" token))))
76+
[account :- BankMap]
77+
(h/post-req "tokens" {:stripe-params
78+
{:bank_account (assoc account
79+
:country "US")}}))
80+
81+
(s/defn get-token :- (ss/Async)
82+
"Returns a card or bank object if successful, errors otherwise."
83+
[token :- (s/either CardToken BankToken)]
84+
(h/get-req (str "tokens/" token)))]))

src/cljx/stripe/util.cljx renamed to src/clj/stripe/util.cljc

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@
1111
(< x high))))
1212

1313
(defn collectify [x]
14-
#+cljs
15-
(if (sequential? x) x [x])
16-
#+clj
17-
(cond (nil? x) []
18-
(or (sequential? x) (instance? java.util.List x) (set? x)) x
19-
:else [x]))
14+
#?(:cljs
15+
(if (sequential? x) x [x])
16+
:clj
17+
(cond (nil? x) []
18+
(or (sequential? x) (instance? java.util.List x) (set? x)) x
19+
:else [x])))
2020

2121
(s/defn toggle-optional :- {s/Any s/Any}
2222
"Takes in a Schema, and a keyword to toggle."

0 commit comments

Comments
 (0)