From 3878b049d9f52e8a940f6d5110e1416f5772843b Mon Sep 17 00:00:00 2001 From: Daniel Dyba Date: Sat, 14 Mar 2015 18:41:47 -0700 Subject: [PATCH] Supports contribution-type and fund-id in xml.elements --- project.clj | 2 +- .../fellowship_one/xml/elements.clj | 36 ++++++++----------- 2 files changed, 16 insertions(+), 22 deletions(-) diff --git a/project.clj b/project.clj index fc62019..15f9a11 100644 --- a/project.clj +++ b/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" diff --git a/src/com/danieldyba/fellowship_one/xml/elements.clj b/src/com/danieldyba/fellowship_one/xml/elements.clj index 312ee5f..fedfe3d 100644 --- a/src/com/danieldyba/fellowship_one/xml/elements.clj +++ b/src/com/danieldyba/fellowship_one/xml/elements.clj @@ -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 @@ -20,8 +22,6 @@ xml/parse zip/xml-zip)))) -;; contribution receipt - (defn amount [amt] {:tag :amount :content [(str amt)]}) @@ -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]}))