billingbadger_api 0.0.1

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.
File without changes
@@ -0,0 +1,4 @@
1
+ === 0.0.1 2012-06-04
2
+
3
+ * 1 major enhancement:
4
+ * Initial release
@@ -0,0 +1,20 @@
1
+ History.txt
2
+ Manifest.txt
3
+ README.rdoc
4
+ Rakefile
5
+ lib/billingbadger_api.rb
6
+ script/console
7
+ script/destroy
8
+ script/generate
9
+ test/test_billingbadger_api.rb
10
+ test/test_helper.rb
11
+ docs/billingbadger_api.yml.example
12
+ lib/billingbadger/objects/product.rb
13
+ lib/billingbadger/objects/subscription.rb
14
+ lib/billingbadger/objects/customer.rb
15
+ lib/billingbadger/objects/invoice_item.rb
16
+ lib/billingbadger/objects/invoice.rb
17
+ lib/billingbadger/objects/periodic_invoice.rb
18
+ lib/billingbadger/objects/product_group.rb
19
+ lib/billingbadger/my_active_resource.rb
20
+ rails/init.rb
@@ -0,0 +1,54 @@
1
+ = billingbadger_api
2
+
3
+ * http://github.com/cmdjohnson/billingbadger_api
4
+
5
+ == DESCRIPTION:
6
+
7
+ API gem for Billing Badger.
8
+
9
+ == FEATURES/PROBLEMS:
10
+
11
+ Gives you a bunch of classes to work with as if they were in your own database.
12
+
13
+ == SYNOPSIS:
14
+
15
+ You have various classes at your disposal such as Billingbadger::Product, Billingbadger::Subscription, Billingbadger::Customer, etc.
16
+
17
+ This gem leans heavily on ActiveResource. This means you can use all ActiveResource commands on these classes.
18
+
19
+ See http://api.rubyonrails.org/classes/ActiveResource/Base.html for more information. The example is using the class Person, just replace that with any of the Badger object names (e.g. Billingbadger::Product).
20
+
21
+ == REQUIREMENTS:
22
+
23
+ - active_resource
24
+ - yaml
25
+
26
+ == INSTALL:
27
+
28
+ - Add 'billingbadger_api' to your Gemfile
29
+ - Create a config file config/billingbadger_api.yml according to the example in the 'doc' folder
30
+
31
+ == LICENSE:
32
+
33
+ (The MIT License)
34
+
35
+ Copyright (c) 2012 Commander Johnson <commanderjohnson@gmail.com>
36
+
37
+ Permission is hereby granted, free of charge, to any person obtaining
38
+ a copy of this software and associated documentation files (the
39
+ 'Software'), to deal in the Software without restriction, including
40
+ without limitation the rights to use, copy, modify, merge, publish,
41
+ distribute, sublicense, and/or sell copies of the Software, and to
42
+ permit persons to whom the Software is furnished to do so, subject to
43
+ the following conditions:
44
+
45
+ The above copyright notice and this permission notice shall be
46
+ included in all copies or substantial portions of the Software.
47
+
48
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
49
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
50
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
51
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
52
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
53
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
54
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,24 @@
1
+ require 'rubygems'
2
+ gem 'hoe', '>= 2.1.0'
3
+ require 'hoe'
4
+ require 'fileutils'
5
+ require './lib/billingbadger_api'
6
+
7
+ Hoe.plugin :newgem
8
+ # Hoe.plugin :website
9
+ # Hoe.plugin :cucumberfeatures
10
+
11
+ # Generate all the Rake tasks
12
+ # Run 'rake -T' to see list of generated tasks (from gem root directory)
13
+ $hoe = Hoe.spec 'billingbadger_api' do
14
+ self.developer 'Commander Johnson', 'commanderjohnson@gmail.com'
15
+ self.rubyforge_name = self.name # TODO this is default value
16
+ #self.extra_deps = [['activeresource','>= 2.3.14']]
17
+ end
18
+
19
+ require 'newgem/tasks'
20
+ Dir['tasks/**/*.rake'].each { |t| load t }
21
+
22
+ # TODO - want other tests/tasks run by default? Add them to the list
23
+ # remove_task :default
24
+ # task :default => [:spec, :features]
@@ -0,0 +1,14 @@
1
+ # Example config file to access the Billing Badger API.
2
+ # 1. Create a User account at the endpoint, keep note of your username/email and password
3
+ # 2. Copy this file to a file called config/billingbadger_api.yml
4
+ # 3. Fill in the correct username and password
5
+ # 4. All set!
6
+ ---
7
+ # BEGIN EDITABLE SECTION
8
+ username: "john.doe@example.com"
9
+ password: "deadbeef123"
10
+ # END EDITABLE SECTION
11
+ # ----------------------------------------------------------------------------
12
+ # No need to edit beyound this line
13
+ # ----------------------------------------------------------------------------
14
+ endpoint: "https://api.billingbadger.com"
@@ -0,0 +1,12 @@
1
+ # To change this template, choose Tools | Templates
2
+ # and open the template in the editor.
3
+
4
+ class MyActiveResource < ActiveResource::Base
5
+ def self.config
6
+ YAML::load_file("config/billingbadger_api.yml")
7
+ end
8
+
9
+ self.site = config["endpoint"]
10
+ self.user = config["username"]
11
+ self.password = config["password"]
12
+ end
@@ -0,0 +1,7 @@
1
+ # To change this template, choose Tools | Templates
2
+ # and open the template in the editor.
3
+
4
+ module Billingbadger
5
+ class Customer < MyActiveResource
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ # To change this template, choose Tools | Templates
2
+ # and open the template in the editor.
3
+
4
+ module Billingbadger
5
+ class Invoice < MyActiveResource
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ # To change this template, choose Tools | Templates
2
+ # and open the template in the editor.
3
+
4
+ module Billingbadger
5
+ class InvoiceItem < MyActiveResource
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ # To change this template, choose Tools | Templates
2
+ # and open the template in the editor.
3
+
4
+ module Billingbadger
5
+ class PeriodicInvoice < MyActiveResource
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ # To change this template, choose Tools | Templates
2
+ # and open the template in the editor.
3
+
4
+ module Billingbadger
5
+ class Product < MyActiveResource
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ # To change this template, choose Tools | Templates
2
+ # and open the template in the editor.
3
+
4
+ module Billingbadger
5
+ class ProductGroup < MyActiveResource
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ # To change this template, choose Tools | Templates
2
+ # and open the template in the editor.
3
+
4
+ module Billingbadger
5
+ class Subscription < MyActiveResource
6
+ end
7
+ end
@@ -0,0 +1,15 @@
1
+ $:.unshift(File.dirname(__FILE__)) unless
2
+ $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
3
+
4
+ require 'rubygems'
5
+ require 'active_resource'
6
+ require 'yaml'
7
+
8
+ # Require all the Ruby files in the Billing Badger directory.
9
+ require 'billingbadger/my_active_resource'
10
+ # this doesn't work with Rails & Bundler :((
11
+ Dir.glob('lib/billingbadger/objects/*.rb') {|file| require file}
12
+
13
+ module BillingbadgerApi
14
+ VERSION = '0.0.1'
15
+ end
@@ -0,0 +1,8 @@
1
+ require 'billingbadger_api'
2
+ # have to require all the files for Rails here
3
+ files = [ 'customer', 'invoice', 'invoice_item', 'periodic_invoice', 'product', 'product_group', 'subscription' ]
4
+ # +_+ #
5
+ for file in files
6
+ # +_+ #
7
+ require "billingbadger/objects/#{file}"
8
+ end
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env ruby
2
+ # File: script/console
3
+ irb = RUBY_PLATFORM =~ /(:?mswin|mingw)/ ? 'irb.bat' : 'irb'
4
+
5
+ libs = " -r irb/completion"
6
+ # Perhaps use a console_lib to store any extra methods I may want available in the cosole
7
+ # libs << " -r #{File.dirname(__FILE__) + '/../lib/console_lib/console_logger.rb'}"
8
+ libs << " -r #{File.dirname(__FILE__) + '/../lib/billingbadger_api.rb'}"
9
+ puts "Loading billingbadger_api gem"
10
+ exec "#{irb} #{libs} --simple-prompt"
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+ APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
3
+
4
+ begin
5
+ require 'rubigen'
6
+ rescue LoadError
7
+ require 'rubygems'
8
+ require 'rubigen'
9
+ end
10
+ require 'rubigen/scripts/destroy'
11
+
12
+ ARGV.shift if ['--help', '-h'].include?(ARGV[0])
13
+ RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
14
+ RubiGen::Scripts::Destroy.new.run(ARGV)
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+ APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
3
+
4
+ begin
5
+ require 'rubigen'
6
+ rescue LoadError
7
+ require 'rubygems'
8
+ require 'rubigen'
9
+ end
10
+ require 'rubigen/scripts/generate'
11
+
12
+ ARGV.shift if ['--help', '-h'].include?(ARGV[0])
13
+ RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
14
+ RubiGen::Scripts::Generate.new.run(ARGV)
@@ -0,0 +1,34 @@
1
+ require File.dirname(__FILE__) + '/test_helper.rb'
2
+
3
+ # -=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=-
4
+ # this test file will only work if you have a config file present.
5
+ #
6
+ # 1. set up a User account at the endpoint application
7
+ # 2. create a new file config/billingbadger_api.yml
8
+ # 3. paste the example file (in the doc/ folder) into it
9
+ # 4. fill in the correct values
10
+ # 5. test it!
11
+ # -=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=-
12
+
13
+ class TestBillingbadgerApi < Test::Unit::TestCase
14
+ def setup
15
+ end
16
+
17
+ def test_products_array
18
+ # Simple test that checks if we get an array of products back from the test environment.
19
+ ret = ::Billingbadger::Product.find(:all)
20
+ # gogo
21
+ #classes = [ "Product", "Subscription", "Customer", "Invoice", "InvoiceItem", "PeriodicInvoice", "ProductGroup" ]
22
+ classes = [ "Product", "Subscription", "Customer", "ProductGroup" ]
23
+ # +_+ #
24
+ for klazz in classes
25
+ k = eval("::Billingbadger::#{klazz}")
26
+ begin
27
+ ret = k.find(:all)
28
+ rescue => e
29
+ raise "Oops: klazz = #{klazz.to_s} error = #{e}"
30
+ end
31
+ assert_equal Array, ret.class
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,3 @@
1
+ require 'stringio'
2
+ require 'test/unit'
3
+ require File.dirname(__FILE__) + '/../lib/billingbadger_api'
metadata ADDED
@@ -0,0 +1,135 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: billingbadger_api
3
+ version: !ruby/object:Gem::Version
4
+ hash: 29
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 1
10
+ version: 0.0.1
11
+ platform: ruby
12
+ authors:
13
+ - Commander Johnson
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2012-06-06 00:00:00 Z
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: rdoc
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - ~>
27
+ - !ruby/object:Gem::Version
28
+ hash: 19
29
+ segments:
30
+ - 3
31
+ - 10
32
+ version: "3.10"
33
+ type: :development
34
+ version_requirements: *id001
35
+ - !ruby/object:Gem::Dependency
36
+ name: newgem
37
+ prerelease: false
38
+ requirement: &id002 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ hash: 5
44
+ segments:
45
+ - 1
46
+ - 5
47
+ - 3
48
+ version: 1.5.3
49
+ type: :development
50
+ version_requirements: *id002
51
+ - !ruby/object:Gem::Dependency
52
+ name: hoe
53
+ prerelease: false
54
+ requirement: &id003 !ruby/object:Gem::Requirement
55
+ none: false
56
+ requirements:
57
+ - - ~>
58
+ - !ruby/object:Gem::Version
59
+ hash: 7
60
+ segments:
61
+ - 3
62
+ - 0
63
+ version: "3.0"
64
+ type: :development
65
+ version_requirements: *id003
66
+ description: API gem for Billing Badger.
67
+ email:
68
+ - commanderjohnson@gmail.com
69
+ executables: []
70
+
71
+ extensions: []
72
+
73
+ extra_rdoc_files:
74
+ - History.txt
75
+ - Manifest.txt
76
+ - README.rdoc
77
+ files:
78
+ - History.txt
79
+ - Manifest.txt
80
+ - README.rdoc
81
+ - Rakefile
82
+ - lib/billingbadger_api.rb
83
+ - script/console
84
+ - script/destroy
85
+ - script/generate
86
+ - test/test_billingbadger_api.rb
87
+ - test/test_helper.rb
88
+ - docs/billingbadger_api.yml.example
89
+ - lib/billingbadger/objects/product.rb
90
+ - lib/billingbadger/objects/subscription.rb
91
+ - lib/billingbadger/objects/customer.rb
92
+ - lib/billingbadger/objects/invoice_item.rb
93
+ - lib/billingbadger/objects/invoice.rb
94
+ - lib/billingbadger/objects/periodic_invoice.rb
95
+ - lib/billingbadger/objects/product_group.rb
96
+ - lib/billingbadger/my_active_resource.rb
97
+ - rails/init.rb
98
+ - .gemtest
99
+ homepage: http://github.com/cmdjohnson/billingbadger_api
100
+ licenses: []
101
+
102
+ post_install_message:
103
+ rdoc_options:
104
+ - --main
105
+ - README.rdoc
106
+ require_paths:
107
+ - lib
108
+ required_ruby_version: !ruby/object:Gem::Requirement
109
+ none: false
110
+ requirements:
111
+ - - ">="
112
+ - !ruby/object:Gem::Version
113
+ hash: 3
114
+ segments:
115
+ - 0
116
+ version: "0"
117
+ required_rubygems_version: !ruby/object:Gem::Requirement
118
+ none: false
119
+ requirements:
120
+ - - ">="
121
+ - !ruby/object:Gem::Version
122
+ hash: 3
123
+ segments:
124
+ - 0
125
+ version: "0"
126
+ requirements: []
127
+
128
+ rubyforge_project: billingbadger_api
129
+ rubygems_version: 1.8.21
130
+ signing_key:
131
+ specification_version: 3
132
+ summary: API gem for Billing Badger.
133
+ test_files:
134
+ - test/test_billingbadger_api.rb
135
+ - test/test_helper.rb