Navigation Menu

Skip to content

Commit

Permalink
Supports contribution-type and fund-id in xml.elements
Browse files Browse the repository at this point in the history
  • Loading branch information
dyba committed Mar 15, 2015
1 parent e9a778a commit 3878b04
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 22 deletions.
2 changes: 1 addition & 1 deletion project.clj
@@ -1,4 +1,4 @@
(defproject com.danieldyba/fellowship-one "0.0.1"
(defproject com.danieldyba/fellowship-one "0.0.2-SNAPSHOT"
:description "An API wrapper for Fellowship One"
:url "https://github.com/dyba/fellowship-one"
:license {:name "Eclipse Public License"
Expand Down
36 changes: 15 additions & 21 deletions src/com/danieldyba/fellowship_one/xml/elements.clj
Expand Up @@ -3,6 +3,8 @@
[clj-time.core :as t]
[clojure.xml :as xml]
[clojure.data.zip.xml :as zx]
[com.danieldyba.fellowship-one.contribution-types :refer [show-type]]
[com.danieldyba.fellowship-one.funds :refer [show-fund]]
[clojure.zip :as zip]))

(defn to-xml
Expand All @@ -20,8 +22,6 @@
xml/parse
zip/xml-zip))))

;; contribution receipt

(defn amount [amt]
{:tag :amount :content [(str amt)]})

Expand All @@ -32,22 +32,16 @@
{:tag :receivedDate
:content [received-date]}))

;; contribution types

(comment
(defn contribution-type
[id]
(zip/node (xml-root (show-contribution-types id)))))

;; funds

(comment
(defn fund
[id]
(let [zipper (xml-root (show-funds id))
uri (zx/attr (zx/xml1-> zipper) :uri)
id (zx/attr (zx/xml1-> zipper) :id)
content (zip/node (zx/xml1-> zipper :name))]
{:tag :fund
:attrs {:uri uri :id id}
:content [content]})))
(defn contribution-type
[id]
(zip/node (xml-root (show-type id))))

(defn fund
[id]
(let [zipper (xml-root (show-fund id))
uri (zx/attr (zx/xml1-> zipper) :uri)
id (zx/attr (zx/xml1-> zipper) :id)
content (zip/node (zx/xml1-> zipper :name))]
{:tag :fund
:attrs {:uri uri :id id}
:content [content]}))

0 comments on commit 3878b04

Please sign in to comment.