netroots-ruby-actblue 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/lib/actblue.rb CHANGED
@@ -10,6 +10,24 @@ class REXMLUtilityNode
10
10
  end
11
11
  end
12
12
 
13
+ module HTTParty
14
+ class Request
15
+ def parse_response(body)
16
+ return nil if body.nil? or body.empty? or body.strip.empty?
17
+ case format
18
+ when :xml
19
+ HTTParty::Parsers::XML.parse(body)
20
+ when :json
21
+ HTTParty::Parsers::JSON.decode(body)
22
+ when :yaml
23
+ YAML::load(body)
24
+ else
25
+ body
26
+ end
27
+ end
28
+ end
29
+ end
30
+
13
31
  module ActBlue
14
32
 
15
33
  ACTBLUE_VERSION = "2007-10-1"
@@ -4,10 +4,14 @@ module ActBlue
4
4
 
5
5
  XML_NAME = 'contribution'
6
6
  ATTRIBUTES = ['order-number', 'created-on']
7
- ELEMENTS = ['refcode', 'source', 'timestamp', 'submitter', 'recurring', 'recurringtimes', 'referrer', 'successuri', 'lineitems']
7
+ ELEMENTS = ['page', 'refcode', 'source', 'timestamp', 'submitter', 'recurring', 'recurringtimes', 'referrer', 'successuri', 'lineitems']
8
8
 
9
9
  def self.get(params)
10
10
  hash = ActiveBlue.get('/contributions', :query => params)
11
+ unless hash
12
+ return nil
13
+ end
14
+ return hash["contributions"] if ((params["view"] == "summary") || (params[:view] == "summary"))
11
15
  result = []
12
16
  if hash["contributions"]
13
17
  hash["contributions"]["contribution"].each do |h|
@@ -18,14 +22,6 @@ module ActBlue
18
22
  end
19
23
  result
20
24
  end
21
-
22
- def post
23
- super.post('/contributions', :body => to_xml)
24
- end
25
-
26
- def put
27
- super.put('/contributions', :body => to_xml)
28
- end
29
25
 
30
26
  end
31
27
 
@@ -3,8 +3,8 @@ module ActBlue
3
3
  class LineItem < ActiveBlue
4
4
 
5
5
  XML_NAME = 'lineitem'
6
- ATTRIBUTES = ['id','effective-at','visibility']
7
- ELEMENTS = ['amount', 'fee', 'entity']
6
+ ATTRIBUTES = ['id','effective-at', 'status', 'visibility']
7
+ ELEMENTS = ['amount', 'fee', 'entity', 'aq-fee', 'premium-fee', 'processing-fee', 'jurisdiction']
8
8
 
9
9
  end
10
10
 
data/lib/actblue/page.rb CHANGED
@@ -6,25 +6,17 @@ module ActBlue
6
6
  ATTRIBUTES = ['name', 'partner', 'created-on']
7
7
  ELEMENTS = ['title', 'author', 'blurb', 'visibility', 'showcandidatesummary', 'listentries']
8
8
 
9
- def self.get(params)
10
- hash = ActiveBlue.get('/pages', :query => params)
11
- result = []
12
- if hash["pages"]
13
- hash["pages"].each do |h|
14
- result << Page.new(h)
15
- end
16
- elsif hash["page"]
17
- result << Page.new(hash["page"])
18
- end
19
- result
20
- end
21
-
22
9
  def post
23
- super.post('/pages', :body => to_xml)
10
+ ActiveBlue.post('/pages', :body => to_xml)
24
11
  end
25
12
 
26
13
  def put
27
- super.put('/pages', :body => to_xml)
14
+ ActiveBlue.put("/pages/#{@variables['name']}", :body => to_xml) if @variables['name']
15
+ end
16
+
17
+ def delete
18
+ @variables['visibility'] = "archived"
19
+ ActiveBlue.put("/pages/#{@variables['name']}", :body => to_xml) if @variables['name']
28
20
  end
29
21
 
30
22
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: netroots-ruby-actblue
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kyle Shank
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-02-11 00:00:00 -08:00
12
+ date: 2009-02-17 00:00:00 -08:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency