buxfer 0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (8) hide show
  1. data/CHANGELOG +1 -0
  2. data/LICENSE +22 -0
  3. data/Manifest +6 -0
  4. data/README +0 -0
  5. data/Rakefile +6 -0
  6. data/buxfer.gemspec +36 -0
  7. data/lib/buxfer.rb +76 -0
  8. metadata +94 -0
@@ -0,0 +1 @@
1
+ v0.1 First version of Buxfer API.
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2009 Jeremy Wells
2
+
3
+ Permission is hereby granted, free of charge, to any person
4
+ obtaining a copy of this software and associated documentation
5
+ files (the "Software"), to deal in the Software without
6
+ restriction, including without limitation the rights to use,
7
+ copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ copies of the Software, and to permit persons to whom the
9
+ Software is furnished to do so, subject to the following
10
+ conditions:
11
+
12
+ The above copyright notice and this permission notice shall be
13
+ included in all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
17
+ OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
19
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22
+ OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,6 @@
1
+ CHANGELOG
2
+ LICENSE
3
+ Manifest
4
+ README
5
+ Rakefile
6
+ lib/buxfer.rb
data/README ADDED
File without changes
@@ -0,0 +1,6 @@
1
+ require 'echoe'
2
+ Echoe.new('buxfer') do |gem|
3
+ gem.runtime_dependencies = ['activesupport >= 2.3.4', 'httparty >= 0.5.0']
4
+ gem.author = "Jeremy Wells"
5
+ gem.summary = "A library providing access to buxfer (www.buxfer.com) API based on HTTParty."
6
+ end
@@ -0,0 +1,36 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = %q{buxfer}
5
+ s.version = "0.1"
6
+
7
+ s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
+ s.authors = ["Jeremy Wells"]
9
+ s.date = %q{2009-12-28}
10
+ s.description = %q{A library providing access to buxfer (www.buxfer.com) API based on HTTParty.}
11
+ s.email = %q{}
12
+ s.extra_rdoc_files = ["CHANGELOG", "LICENSE", "README", "lib/buxfer.rb"]
13
+ s.files = ["CHANGELOG", "LICENSE", "Manifest", "README", "Rakefile", "lib/buxfer.rb", "buxfer.gemspec"]
14
+ s.homepage = %q{}
15
+ s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Buxfer", "--main", "README"]
16
+ s.require_paths = ["lib"]
17
+ s.rubyforge_project = %q{buxfer}
18
+ s.rubygems_version = %q{1.3.5}
19
+ s.summary = %q{A library providing access to buxfer (www.buxfer.com) API based on HTTParty.}
20
+
21
+ if s.respond_to? :specification_version then
22
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
23
+ s.specification_version = 3
24
+
25
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
26
+ s.add_runtime_dependency(%q<activesupport>, [">= 0", "= 2.3.4"])
27
+ s.add_runtime_dependency(%q<httparty>, [">= 0", "= 0.5.0"])
28
+ else
29
+ s.add_dependency(%q<activesupport>, [">= 0", "= 2.3.4"])
30
+ s.add_dependency(%q<httparty>, [">= 0", "= 0.5.0"])
31
+ end
32
+ else
33
+ s.add_dependency(%q<activesupport>, [">= 0", "= 2.3.4"])
34
+ s.add_dependency(%q<httparty>, [">= 0", "= 0.5.0"])
35
+ end
36
+ end
@@ -0,0 +1,76 @@
1
+ require 'httparty'
2
+ require 'active_support'
3
+
4
+ class Buxfer
5
+ include HTTParty
6
+ base_uri 'https://www.buxfer.com/api'
7
+ format :xml
8
+
9
+ def initialize(username, password)
10
+ @username = username
11
+ @password = password
12
+ end
13
+
14
+ def add_transaction(amount, description, account = nil, status = nil, tags = [])
15
+ amount = (amount < 0 ? amount.to_s : '+' + amount.to_s)
16
+ tags = tags.join(',')
17
+ attrs = {}
18
+ text = [description, amount]
19
+
20
+ {:acct => account, :status => status, :tags => tags}.each do |k, v|
21
+ text << '%s:%s' % [k, v] unless v.blank?
22
+ end
23
+
24
+ self.class.post('/add_transaction.xml', auth_query({:text => text, :format => 'sms'}, :body))
25
+ end
26
+
27
+ def upload_statement(accountId, statement, dateFormat = 'DD/MM/YYYY')
28
+ unless statement.is_a?(String)
29
+ if statement.respond_to?(:read)
30
+ statement = statement.read
31
+ else chec
32
+ statement = statement.to_s
33
+ end
34
+ end
35
+
36
+ options = {:accountId => accountId, :statement => statement, :dateFormat => dateFormat}
37
+
38
+ self.class.post('/upload_statement.xml', auth_query(options, :body))
39
+ end
40
+
41
+ def transactions(options = {})
42
+ self.class.get('/transactions.xml', auth_query(options))['response']['transactions']['transaction']
43
+ end
44
+
45
+ def reports(options = {})
46
+ self.class.get('/reports.xml', auth_query(options))
47
+ end
48
+
49
+ def accounts
50
+ self.class.get('/accounts.xml', auth_query)['response']['accounts']['account']
51
+ end
52
+
53
+ def loans
54
+ self.class.get('/loans.xml', auth_query)
55
+ end
56
+
57
+ def tags
58
+ self.class.get('/tags.xml', auth_query)['response']['tags']['tag']
59
+ end
60
+
61
+ private
62
+
63
+ def auth
64
+ @auth ||= begin
65
+ self.class.get('/login.xml', :query => {:userid => @username, :password => @password})
66
+ end
67
+ end
68
+
69
+ def token
70
+ auth['response']['token']
71
+ end
72
+
73
+ def auth_query(options = {}, container = :query)
74
+ {container => options.merge(:token => token)}
75
+ end
76
+ end
metadata ADDED
@@ -0,0 +1,94 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: buxfer
3
+ version: !ruby/object:Gem::Version
4
+ version: "0.1"
5
+ platform: ruby
6
+ authors:
7
+ - Jeremy Wells
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-12-28 00:00:00 +13:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: activesupport
17
+ type: :runtime
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: "0"
24
+ - - "="
25
+ - !ruby/object:Gem::Version
26
+ version: 2.3.4
27
+ version:
28
+ - !ruby/object:Gem::Dependency
29
+ name: httparty
30
+ type: :runtime
31
+ version_requirement:
32
+ version_requirements: !ruby/object:Gem::Requirement
33
+ requirements:
34
+ - - ">="
35
+ - !ruby/object:Gem::Version
36
+ version: "0"
37
+ - - "="
38
+ - !ruby/object:Gem::Version
39
+ version: 0.5.0
40
+ version:
41
+ description: A library providing access to buxfer (www.buxfer.com) API based on HTTParty.
42
+ email: ""
43
+ executables: []
44
+
45
+ extensions: []
46
+
47
+ extra_rdoc_files:
48
+ - CHANGELOG
49
+ - LICENSE
50
+ - README
51
+ - lib/buxfer.rb
52
+ files:
53
+ - CHANGELOG
54
+ - LICENSE
55
+ - Manifest
56
+ - README
57
+ - Rakefile
58
+ - lib/buxfer.rb
59
+ - buxfer.gemspec
60
+ has_rdoc: true
61
+ homepage: ""
62
+ licenses: []
63
+
64
+ post_install_message:
65
+ rdoc_options:
66
+ - --line-numbers
67
+ - --inline-source
68
+ - --title
69
+ - Buxfer
70
+ - --main
71
+ - README
72
+ require_paths:
73
+ - lib
74
+ required_ruby_version: !ruby/object:Gem::Requirement
75
+ requirements:
76
+ - - ">="
77
+ - !ruby/object:Gem::Version
78
+ version: "0"
79
+ version:
80
+ required_rubygems_version: !ruby/object:Gem::Requirement
81
+ requirements:
82
+ - - ">="
83
+ - !ruby/object:Gem::Version
84
+ version: "1.2"
85
+ version:
86
+ requirements: []
87
+
88
+ rubyforge_project: buxfer
89
+ rubygems_version: 1.3.5
90
+ signing_key:
91
+ specification_version: 3
92
+ summary: A library providing access to buxfer (www.buxfer.com) API based on HTTParty.
93
+ test_files: []
94
+