Skip to content

Commit 495969b

Browse files
committed
purely cosmetic whitespace cleanup (nothing else has changed)
1 parent 6d1b6df commit 495969b

File tree

1 file changed

+87
-70
lines changed

1 file changed

+87
-70
lines changed

src/twitter.clj

Lines changed: 87 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
(def *oauth-access-token-secret* nil)
1919
(def *protocol* "http")
2020

21-
;; Get JSON from clj-apache-http
21+
;; Get JSON from clj-apache-http
2222
(defmethod http/entity-as :json [entity as state]
2323
(read-json (http/entity-as entity :string state)))
2424

@@ -28,13 +28,13 @@
2828
`(binding [*oauth-consumer* ~consumer
2929
*oauth-access-token* ~access-token
3030
*oauth-access-token-secret* ~access-token-secret]
31-
(do
31+
(do
3232
~@body)))
3333

3434
(defmacro with-https
3535
[ & body]
3636
`(binding [*protocol* "https"]
37-
(do
37+
(do
3838
~@body)))
3939

4040
(defmacro def-twitter-method
@@ -51,21 +51,34 @@ take any required and optional arguments and call the associated Twitter method.
5151
rest-map# (apply hash-map rest#)
5252
provided-optional-params# (set/intersection (set ~optional-params)
5353
(set (keys rest-map#)))
54-
required-query-param-names# (map (fn [x#]
55-
(keyword (string/replace (name x#) #"-" "_" )))
56-
~required-params)
57-
optional-query-param-names-mapping# (map (fn [x#]
58-
[x# (keyword (string/replace (name x#) #"-" "_"))])
59-
provided-optional-params#)
60-
query-params# (merge (apply hash-map
61-
(vec (interleave required-query-param-names# ~required-fn-params)))
62-
(apply merge
63-
(map (fn [x#] {(second x#) ((first x#) rest-map#)}) optional-query-param-names-mapping#)))
54+
required-query-param-names#
55+
(map (fn [x#]
56+
(keyword (string/replace (name x#) #"-" "_" )))
57+
~required-params)
58+
59+
optional-query-param-names-mapping#
60+
(map (fn [x#]
61+
[x# (keyword (string/replace (name x#) #"-" "_"))])
62+
provided-optional-params#)
63+
64+
query-params#(merge (apply hash-map
65+
(vec (interleave
66+
required-query-param-names#
67+
~required-fn-params)))
68+
(apply merge
69+
(map (fn [x#] {(second x#)
70+
((first x#)
71+
rest-map#)})
72+
optional-query-param-names-mapping#)))
6473
need-to-url-encode# (if (= :get ~req-method)
65-
(into {} (map (fn [[k# v#]] [k# (oauth.signature/url-encode v#)]) query-params#))
74+
(into {}
75+
(map (fn [[k# v#]]
76+
[k#
77+
(oauth.signature/url-encode v#)])
78+
query-params#))
6679
query-params#)
67-
oauth-creds# (when (and *oauth-consumer*
68-
*oauth-access-token*)
80+
oauth-creds# (when (and *oauth-consumer*
81+
*oauth-access-token*)
6982
(oauth/credentials *oauth-consumer*
7083
*oauth-access-token*
7184
*oauth-access-token-secret*
@@ -76,7 +89,7 @@ take any required and optional arguments and call the associated Twitter method.
7689
req-uri#
7790
:query (merge query-params#
7891
oauth-creds#)
79-
:parameters (http/map->params
92+
:parameters (http/map->params
8093
{:use-expect-continue false})
8194
:as :json))))))
8295

@@ -282,7 +295,7 @@ take any required and optional arguments and call the associated Twitter method.
282295
(def-twitter-method friends-of-name
283296
:get
284297
"api.twitter.com/1/friends/ids.json"
285-
[:screen-name]
298+
[:screen-name]
286299
[]
287300
(comp #(:content %) status-handler))
288301

@@ -349,7 +362,7 @@ take any required and optional arguments and call the associated Twitter method.
349362

350363
(defn update-profile-image [^String image]
351364
(let [req-uri__9408__auto__ "http://api.twitter.com/1/account/update_profile_image.json"
352-
365+
353366
oauth-creds__9414__auto__ (when
354367
(and
355368
*oauth-consumer*
@@ -379,45 +392,47 @@ take any required and optional arguments and call the associated Twitter method.
379392
(comp #(:content %) status-handler)))
380393

381394
(defn update-profile-background-image [^String image & rest__2570__auto__]
382-
(let [req-uri__2571__auto__ "http://api.twitter.com/1/account/update_profile_background_image.json"
383-
rest-map__2572__auto__ (apply hash-map rest__2570__auto__)
384-
provided-optional-params__2573__auto__ (set/intersection
385-
(set [:title])
386-
(set
387-
(keys
388-
rest-map__2572__auto__)))
389-
query-param-names__2574__auto__ (sort
390-
(map
391-
(fn
392-
[x__2575__auto__]
393-
(keyword
394-
(string/replace
395-
(name
396-
x__2575__auto__)
397-
#"-"
398-
"_"
399-
)))
400-
provided-optional-params__2573__auto__))
401-
query-params__2576__auto__ (apply
402-
hash-map
403-
(interleave
404-
query-param-names__2574__auto__
405-
(vec
406-
(vals
407-
(sort
408-
(select-keys
409-
rest-map__2572__auto__
410-
provided-optional-params__2573__auto__))))))
411-
oauth-creds__2577__auto__ (when
412-
(and
413-
*oauth-consumer*
414-
*oauth-access-token*)
415-
(oauth/credentials
416-
*oauth-consumer*
417-
*oauth-access-token*
418-
:post
419-
req-uri__2571__auto__
420-
query-params__2576__auto__))]
395+
(let [req-uri__2571__auto__
396+
"http://api.twitter.com/1/account/update_profile_background_image.json"
397+
398+
rest-map__2572__auto__ (apply hash-map rest__2570__auto__)
399+
provided-optional-params__2573__auto__ (set/intersection
400+
(set [:title])
401+
(set
402+
(keys
403+
rest-map__2572__auto__)))
404+
query-param-names__2574__auto__ (sort
405+
(map
406+
(fn
407+
[x__2575__auto__]
408+
(keyword
409+
(string/replace
410+
(name
411+
x__2575__auto__)
412+
#"-"
413+
"_"
414+
)))
415+
provided-optional-params__2573__auto__))
416+
query-params__2576__auto__ (apply
417+
hash-map
418+
(interleave
419+
query-param-names__2574__auto__
420+
(vec
421+
(vals
422+
(sort
423+
(select-keys
424+
rest-map__2572__auto__
425+
provided-optional-params__2573__auto__))))))
426+
oauth-creds__2577__auto__ (when
427+
(and
428+
*oauth-consumer*
429+
*oauth-access-token*)
430+
(oauth/credentials
431+
*oauth-consumer*
432+
*oauth-access-token*
433+
:post
434+
req-uri__2571__auto__
435+
query-params__2576__auto__))]
421436
((comp #(:content %) status-handler)
422437
(http/post req-uri__2571__auto__
423438
:query (merge query-params__2576__auto__ oauth-creds__2577__auto__)
@@ -430,7 +445,7 @@ take any required and optional arguments and call the associated Twitter method.
430445
:post
431446
"api.twitter.com/1/account/update_profile.json"
432447
[]
433-
[:name
448+
[:name
434449
:email
435450
:url
436451
:location
@@ -605,21 +620,23 @@ take any required and optional arguments and call the associated Twitter method.
605620
"Handle the various HTTP status codes that may be returned when accessing
606621
the Twitter API."
607622
[result]
608-
(condp #(if (coll? %1)
623+
(condp #(if (coll? %1)
609624
(first (filter (fn [x] (== x %2)) %1))
610625
(== %2 %1)) (:code result)
611626
200 result
612627
304 nil
613-
[400 401 403 404 406 500 502 503] (let [body (:content result)
614-
headers (into {} (:headers result))
615-
error-msg (:error body)
616-
error-code (:code result)
617-
request-uri (:request body)]
618-
(throw (proxy [Exception] [(str "[" error-code "] " error-msg ". [" request-uri "]")]
619-
(request [] (body "request"))
620-
(remaining-requests [] (headers "X-RateLimit-Remaining"))
621-
(rate-limit-reset [] (java.util.Date.
622-
(long (headers "X-RateLimit-Reset")))))))))
628+
[400 401 403 404 406 500 502 503]
629+
(let [body (:content result)
630+
headers (into {} (:headers result))
631+
error-msg (:error body)
632+
error-code (:code result)
633+
request-uri (:request body)]
634+
(throw (proxy [Exception]
635+
[(str "[" error-code "] " error-msg ". [" request-uri "]")]
636+
(request [] (body "request"))
637+
(remaining-requests [] (headers "X-RateLimit-Remaining"))
638+
(rate-limit-reset [] (java.util.Date.
639+
(long (headers "X-RateLimit-Reset")))))))))
623640

624641
(defn make-rate-limit-handler
625642
"Creates a handler that will only be called if the API rate limit has been exceeded."

0 commit comments

Comments
 (0)