killbill-client 0.1.0

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.
Files changed (81) hide show
  1. data/.gitignore +3 -0
  2. data/Gemfile +3 -0
  3. data/README.md +18 -0
  4. data/Rakefile +26 -0
  5. data/killbill_client.gemspec +44 -0
  6. data/lib/killbill_client.rb +93 -0
  7. data/lib/killbill_client/api/api.rb +85 -0
  8. data/lib/killbill_client/api/errors.rb +175 -0
  9. data/lib/killbill_client/api/net_http_adapter.rb +131 -0
  10. data/lib/killbill_client/models/account.rb +36 -0
  11. data/lib/killbill_client/models/gen/account_attributes.rb +51 -0
  12. data/lib/killbill_client/models/gen/account_attributes_simple.rb +33 -0
  13. data/lib/killbill_client/models/gen/account_attributes_with_balance.rb +52 -0
  14. data/lib/killbill_client/models/gen/account_attributes_with_balance_and_c_b_a.rb +53 -0
  15. data/lib/killbill_client/models/gen/account_email_attributes.rb +33 -0
  16. data/lib/killbill_client/models/gen/account_timeline_attributes.rb +35 -0
  17. data/lib/killbill_client/models/gen/analytics_sanity_attributes.rb +36 -0
  18. data/lib/killbill_client/models/gen/audit_log_attributes.rb +37 -0
  19. data/lib/killbill_client/models/gen/bundle_attributes_no_subscriptions.rb +36 -0
  20. data/lib/killbill_client/models/gen/bundle_attributes_simple.rb +34 -0
  21. data/lib/killbill_client/models/gen/bundle_attributes_with_subscriptions.rb +35 -0
  22. data/lib/killbill_client/models/gen/bundle_timeline_attributes.rb +36 -0
  23. data/lib/killbill_client/models/gen/business_account_attributes.rb +41 -0
  24. data/lib/killbill_client/models/gen/business_field_attributes.rb +35 -0
  25. data/lib/killbill_client/models/gen/business_invoice_attributes.rb +43 -0
  26. data/lib/killbill_client/models/gen/business_invoice_item_attributes.rb +46 -0
  27. data/lib/killbill_client/models/gen/business_invoice_payment_attributes.rb +50 -0
  28. data/lib/killbill_client/models/gen/business_overdue_status_attributes.rb +37 -0
  29. data/lib/killbill_client/models/gen/business_snapshot_attributes.rb +38 -0
  30. data/lib/killbill_client/models/gen/business_subscription_transition_attributes.rb +64 -0
  31. data/lib/killbill_client/models/gen/business_tag_attributes.rb +34 -0
  32. data/lib/killbill_client/models/gen/catalog_attributes_simple.rb +33 -0
  33. data/lib/killbill_client/models/gen/chargeback_attributes.rb +37 -0
  34. data/lib/killbill_client/models/gen/chargeback_collection_attributes.rb +33 -0
  35. data/lib/killbill_client/models/gen/credit_attributes.rb +39 -0
  36. data/lib/killbill_client/models/gen/credit_collection_attributes.rb +33 -0
  37. data/lib/killbill_client/models/gen/custom_field_attributes.rb +33 -0
  38. data/lib/killbill_client/models/gen/invoice_attributes_simple.rb +42 -0
  39. data/lib/killbill_client/models/gen/invoice_attributes_with_bundle_keys.rb +44 -0
  40. data/lib/killbill_client/models/gen/invoice_attributes_with_items.rb +43 -0
  41. data/lib/killbill_client/models/gen/invoice_email_attributes.rb +33 -0
  42. data/lib/killbill_client/models/gen/invoice_item_attributes_simple.rb +45 -0
  43. data/lib/killbill_client/models/gen/notification_attributes.rb +35 -0
  44. data/lib/killbill_client/models/gen/overdue_state_attributes.rb +38 -0
  45. data/lib/killbill_client/models/gen/payment_attributes_simple.rb +47 -0
  46. data/lib/killbill_client/models/gen/payment_attributes_with_bundle_keys.rb +50 -0
  47. data/lib/killbill_client/models/gen/payment_method_attributes.rb +36 -0
  48. data/lib/killbill_client/models/gen/payment_method_plugin_detail_attributes.rb +46 -0
  49. data/lib/killbill_client/models/gen/payment_method_properties.rb +34 -0
  50. data/lib/killbill_client/models/gen/phase_attributes.rb +33 -0
  51. data/lib/killbill_client/models/gen/plan_attributes.rb +33 -0
  52. data/lib/killbill_client/models/gen/plan_detail_attributes.rb +36 -0
  53. data/lib/killbill_client/models/gen/product_attributes.rb +36 -0
  54. data/lib/killbill_client/models/gen/refund_attributes.rb +40 -0
  55. data/lib/killbill_client/models/gen/require_gen.rb +80 -0
  56. data/lib/killbill_client/models/gen/subscription_attributes_no_events.rb +41 -0
  57. data/lib/killbill_client/models/gen/subscription_attributes_simple.rb +33 -0
  58. data/lib/killbill_client/models/gen/subscription_attributes_with_events.rb +36 -0
  59. data/lib/killbill_client/models/gen/subscription_deleted_event_attributes.rb +40 -0
  60. data/lib/killbill_client/models/gen/subscription_new_event_attributes.rb +38 -0
  61. data/lib/killbill_client/models/gen/subscription_read_event_attributes.rb +40 -0
  62. data/lib/killbill_client/models/gen/tag_attributes.rb +34 -0
  63. data/lib/killbill_client/models/gen/tag_definition_attributes.rb +36 -0
  64. data/lib/killbill_client/models/gen/tenant_attributes.rb +35 -0
  65. data/lib/killbill_client/models/gen/tenant_key_attributes.rb +33 -0
  66. data/lib/killbill_client/models/gen/time_series_data_attributes.rb +33 -0
  67. data/lib/killbill_client/models/invoice.rb +7 -0
  68. data/lib/killbill_client/models/invoice_item.rb +17 -0
  69. data/lib/killbill_client/models/models.rb +15 -0
  70. data/lib/killbill_client/models/payment.rb +6 -0
  71. data/lib/killbill_client/models/payment_method.rb +92 -0
  72. data/lib/killbill_client/models/resource.rb +125 -0
  73. data/lib/killbill_client/models/tag_definition.rb +6 -0
  74. data/lib/killbill_client/utils.rb +30 -0
  75. data/lib/killbill_client/version.rb +18 -0
  76. data/lib/rails/generators/killbill_client/config_generator.rb +17 -0
  77. data/lib/rails/killbill_client.rb +7 -0
  78. data/spec/killbill_client/remote/api_spec.rb +10 -0
  79. data/spec/killbill_client/remote/model_spec.rb +77 -0
  80. data/spec/spec_helper.rb +31 -0
  81. metadata +165 -0
@@ -0,0 +1,6 @@
1
+ module KillBillClient
2
+ module Model
3
+ class TagDefinition < TagDefinitionAttributes
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,30 @@
1
+ module KillBillClient
2
+ module Utils
3
+ def camelize(underscored_word, first_letter = :upper)
4
+ camelized = underscored_word.to_s.gsub(/(?:^|_)(.)/) { $1.upcase }
5
+ case first_letter
6
+ when :lower then
7
+ camelized = camelized[0, 1].downcase + camelized[1..-1]
8
+ else
9
+ # camelized = camelized
10
+ end
11
+ camelized
12
+ end
13
+
14
+ def demodulize(class_name_in_module)
15
+ class_name_in_module.to_s.sub(/^.*::/, '')
16
+ end
17
+
18
+ def underscore(camel_cased_word)
19
+ word = camel_cased_word.to_s.dup
20
+ word.gsub!(/::/, '/')
21
+ word.gsub!(/([A-Z]+)([A-Z][a-z])/, '\1_\2')
22
+ word.gsub!(/([a-z\d])([A-Z])/, '\1_\2')
23
+ word.tr! '-', '_'
24
+ word.downcase!
25
+ word
26
+ end
27
+
28
+ extend self
29
+ end
30
+ end
@@ -0,0 +1,18 @@
1
+ module KillBillClient
2
+ module Version
3
+ MAJOR = 0
4
+ MINOR = 1
5
+ PATCH = 0
6
+ PRE = nil
7
+
8
+ VERSION = [MAJOR, MINOR, PATCH, PRE].compact.join('.').freeze
9
+
10
+ class << self
11
+ def inspect
12
+ VERSION.dup
13
+ end
14
+
15
+ alias to_s inspect
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,17 @@
1
+ module KillBillClient
2
+ class ConfigGenerator < Rails::Generators::Base
3
+ desc "Creates a configuration file at config/initializers/killbill_client.rb"
4
+
5
+ # Creates a configuration file at <tt>config/initializers/killbill_client.rb</tt>
6
+ # when running <tt>rails g killbill_client:config</tt>.
7
+ def create_killbill_client_file
8
+ create_file 'config/initializers/killbill_client.rb', <<EOF
9
+ KillBillClient.url = ENV['KILLBILL_URL']
10
+ KillBillClient.api_key = ENV['KILLBILL_API_KEY']
11
+ KillBillClient.api_secret = ENV['KILLBILL_API_SECRET']
12
+
13
+ # KillBillClient.default_currency = 'USD'
14
+ EOF
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,7 @@
1
+ module KillBillClient
2
+ class Railtie < Rails::Railtie
3
+ initializer :killbill_client_set_logger do
4
+ KillBillClient.logger = Rails.logger
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,10 @@
1
+ require 'spec_helper'
2
+
3
+ describe KillBillClient::API do
4
+ it 'should get all tag definitions' do
5
+ response = KillBillClient::API.get '/1.0/kb/tagDefinitions'
6
+ response.code.to_i.should == 200
7
+ tag_definitions = KillBillClient::Model::Resource.from_response KillBillClient::Model::TagDefinition, response
8
+ tag_definitions.size.should > 1
9
+ end
10
+ end
@@ -0,0 +1,77 @@
1
+ require 'spec_helper'
2
+
3
+ describe KillBillClient::Model do
4
+ it 'should manipulate accounts' do
5
+ external_key = Time.now.to_i.to_s
6
+
7
+ account = KillBillClient::Model::Account.new
8
+ account.name = 'KillBillClient'
9
+ account.external_key = external_key
10
+ account.email = 'kill@bill.com'
11
+ account.currency = 'USD'
12
+ account.time_zone = 'UTC'
13
+ account.address1 = '5, ruby road'
14
+ account.address2 = 'Apt 4'
15
+ account.postal_code = 10293
16
+ account.company = 'KillBill, Inc.'
17
+ account.city = 'SnakeCase'
18
+ account.state = 'Awesome'
19
+ account.country = 'LalaLand'
20
+ account.locale = 'FR_fr'
21
+ account.is_notified_for_invoices = false
22
+ account.account_id.should be_nil
23
+
24
+ # Create and verify the account
25
+ account = account.create('KillBill Spec test')
26
+ account.external_key.should == external_key
27
+ account.account_id.should_not be_nil
28
+
29
+ # Try to retrieve it
30
+ account = KillBillClient::Model::Account.find_by_id account.account_id
31
+ account.external_key.should == external_key
32
+ account.payment_method_id.should be_nil
33
+
34
+ # Add a payment method
35
+ pm = KillBillClient::Model::PaymentMethod.new
36
+ pm.account_id = account.account_id
37
+ pm.plugin_name = '__EXTERNAL_PAYMENT__'
38
+ pm.plugin_info = {}
39
+ pm.payment_method_id.should be_nil
40
+
41
+ pm = pm.create(true, 'KillBill Spec test')
42
+ pm.payment_method_id.should_not be_nil
43
+
44
+ # Try to retrieve it
45
+ pm = KillBillClient::Model::PaymentMethod.find_by_id pm.payment_method_id, true
46
+ pm.account_id.should == account.account_id
47
+
48
+ account = KillBillClient::Model::Account.find_by_id account.account_id
49
+ account.payment_method_id.should == pm.payment_method_id
50
+
51
+ pms = KillBillClient::Model::PaymentMethod.find_all_by_account_id account.account_id
52
+ pms.size.should == 1
53
+ pms[0].payment_method_id.should == pm.payment_method_id
54
+
55
+ # Check there is no payment associated with that account
56
+ account.payments.size.should == 0
57
+
58
+ # Add an external charge
59
+ invoice_item = KillBillClient::Model::InvoiceItem.new
60
+ invoice_item.account_id = account.account_id
61
+ invoice_item.currency = account.currency
62
+ invoice_item.amount = 123.98
63
+
64
+ invoice = invoice_item.create 'KillBill Spec test'
65
+
66
+ invoice.balance.should == 123.98
67
+
68
+ # Check the account balance
69
+ account = KillBillClient::Model::Account.find_by_id account.account_id, true
70
+ account.account_balance.should == 123.98
71
+
72
+ pm.destroy(true, 'KillBill Spec test')
73
+
74
+ account = KillBillClient::Model::Account.find_by_id account.account_id
75
+ account.payment_method_id.should be_nil
76
+ end
77
+ end
@@ -0,0 +1,31 @@
1
+ $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
2
+
3
+ require 'bundler'
4
+ require 'killbill_client'
5
+
6
+ require 'logger'
7
+
8
+ require 'rspec'
9
+
10
+ KillBillClient.url = 'http://127.0.0.1:8080'
11
+
12
+ RSpec.configure do |config|
13
+ config.color_enabled = true
14
+ config.tty = true
15
+ config.formatter = 'documentation'
16
+ end
17
+
18
+ begin
19
+ require 'securerandom'
20
+ SecureRandom.uuid
21
+ rescue LoadError, NoMethodError
22
+ # See http://jira.codehaus.org/browse/JRUBY-6176
23
+ module SecureRandom
24
+ def self.uuid
25
+ ary = self.random_bytes(16).unpack("NnnnnN")
26
+ ary[2] = (ary[2] & 0x0fff) | 0x4000
27
+ ary[3] = (ary[3] & 0x3fff) | 0x8000
28
+ "%08x-%04x-%04x-%04x-%04x%08x" % ary
29
+ end unless respond_to?(:uuid)
30
+ end
31
+ end
metadata ADDED
@@ -0,0 +1,165 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: killbill-client
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Killbill core team
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-06-05 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rake
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: 10.0.0
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: 10.0.0
30
+ - !ruby/object:Gem::Dependency
31
+ name: rspec
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ~>
36
+ - !ruby/object:Gem::Version
37
+ version: 2.12.0
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: 2.12.0
46
+ description: An API client library for Kill Bill.
47
+ email: killbilling-users@googlegroups.com
48
+ executables: []
49
+ extensions: []
50
+ extra_rdoc_files: []
51
+ files:
52
+ - .gitignore
53
+ - Gemfile
54
+ - README.md
55
+ - Rakefile
56
+ - killbill_client.gemspec
57
+ - lib/killbill_client.rb
58
+ - lib/killbill_client/api/api.rb
59
+ - lib/killbill_client/api/errors.rb
60
+ - lib/killbill_client/api/net_http_adapter.rb
61
+ - lib/killbill_client/models/account.rb
62
+ - lib/killbill_client/models/gen/account_attributes.rb
63
+ - lib/killbill_client/models/gen/account_attributes_simple.rb
64
+ - lib/killbill_client/models/gen/account_attributes_with_balance.rb
65
+ - lib/killbill_client/models/gen/account_attributes_with_balance_and_c_b_a.rb
66
+ - lib/killbill_client/models/gen/account_email_attributes.rb
67
+ - lib/killbill_client/models/gen/account_timeline_attributes.rb
68
+ - lib/killbill_client/models/gen/analytics_sanity_attributes.rb
69
+ - lib/killbill_client/models/gen/audit_log_attributes.rb
70
+ - lib/killbill_client/models/gen/bundle_attributes_no_subscriptions.rb
71
+ - lib/killbill_client/models/gen/bundle_attributes_simple.rb
72
+ - lib/killbill_client/models/gen/bundle_attributes_with_subscriptions.rb
73
+ - lib/killbill_client/models/gen/bundle_timeline_attributes.rb
74
+ - lib/killbill_client/models/gen/business_account_attributes.rb
75
+ - lib/killbill_client/models/gen/business_field_attributes.rb
76
+ - lib/killbill_client/models/gen/business_invoice_attributes.rb
77
+ - lib/killbill_client/models/gen/business_invoice_item_attributes.rb
78
+ - lib/killbill_client/models/gen/business_invoice_payment_attributes.rb
79
+ - lib/killbill_client/models/gen/business_overdue_status_attributes.rb
80
+ - lib/killbill_client/models/gen/business_snapshot_attributes.rb
81
+ - lib/killbill_client/models/gen/business_subscription_transition_attributes.rb
82
+ - lib/killbill_client/models/gen/business_tag_attributes.rb
83
+ - lib/killbill_client/models/gen/catalog_attributes_simple.rb
84
+ - lib/killbill_client/models/gen/chargeback_attributes.rb
85
+ - lib/killbill_client/models/gen/chargeback_collection_attributes.rb
86
+ - lib/killbill_client/models/gen/credit_attributes.rb
87
+ - lib/killbill_client/models/gen/credit_collection_attributes.rb
88
+ - lib/killbill_client/models/gen/custom_field_attributes.rb
89
+ - lib/killbill_client/models/gen/invoice_attributes_simple.rb
90
+ - lib/killbill_client/models/gen/invoice_attributes_with_bundle_keys.rb
91
+ - lib/killbill_client/models/gen/invoice_attributes_with_items.rb
92
+ - lib/killbill_client/models/gen/invoice_email_attributes.rb
93
+ - lib/killbill_client/models/gen/invoice_item_attributes_simple.rb
94
+ - lib/killbill_client/models/gen/notification_attributes.rb
95
+ - lib/killbill_client/models/gen/overdue_state_attributes.rb
96
+ - lib/killbill_client/models/gen/payment_attributes_simple.rb
97
+ - lib/killbill_client/models/gen/payment_attributes_with_bundle_keys.rb
98
+ - lib/killbill_client/models/gen/payment_method_attributes.rb
99
+ - lib/killbill_client/models/gen/payment_method_plugin_detail_attributes.rb
100
+ - lib/killbill_client/models/gen/payment_method_properties.rb
101
+ - lib/killbill_client/models/gen/phase_attributes.rb
102
+ - lib/killbill_client/models/gen/plan_attributes.rb
103
+ - lib/killbill_client/models/gen/plan_detail_attributes.rb
104
+ - lib/killbill_client/models/gen/product_attributes.rb
105
+ - lib/killbill_client/models/gen/refund_attributes.rb
106
+ - lib/killbill_client/models/gen/require_gen.rb
107
+ - lib/killbill_client/models/gen/subscription_attributes_no_events.rb
108
+ - lib/killbill_client/models/gen/subscription_attributes_simple.rb
109
+ - lib/killbill_client/models/gen/subscription_attributes_with_events.rb
110
+ - lib/killbill_client/models/gen/subscription_deleted_event_attributes.rb
111
+ - lib/killbill_client/models/gen/subscription_new_event_attributes.rb
112
+ - lib/killbill_client/models/gen/subscription_read_event_attributes.rb
113
+ - lib/killbill_client/models/gen/tag_attributes.rb
114
+ - lib/killbill_client/models/gen/tag_definition_attributes.rb
115
+ - lib/killbill_client/models/gen/tenant_attributes.rb
116
+ - lib/killbill_client/models/gen/tenant_key_attributes.rb
117
+ - lib/killbill_client/models/gen/time_series_data_attributes.rb
118
+ - lib/killbill_client/models/invoice.rb
119
+ - lib/killbill_client/models/invoice_item.rb
120
+ - lib/killbill_client/models/models.rb
121
+ - lib/killbill_client/models/payment.rb
122
+ - lib/killbill_client/models/payment_method.rb
123
+ - lib/killbill_client/models/resource.rb
124
+ - lib/killbill_client/models/tag_definition.rb
125
+ - lib/killbill_client/utils.rb
126
+ - lib/killbill_client/version.rb
127
+ - lib/rails/generators/killbill_client/config_generator.rb
128
+ - lib/rails/killbill_client.rb
129
+ - spec/killbill_client/remote/api_spec.rb
130
+ - spec/killbill_client/remote/model_spec.rb
131
+ - spec/spec_helper.rb
132
+ homepage: http://www.killbilling.org
133
+ licenses:
134
+ - Apache License (2.0)
135
+ post_install_message:
136
+ rdoc_options:
137
+ - --exclude
138
+ - .
139
+ require_paths:
140
+ - lib
141
+ required_ruby_version: !ruby/object:Gem::Requirement
142
+ none: false
143
+ requirements:
144
+ - - ! '>='
145
+ - !ruby/object:Gem::Version
146
+ version: 1.8.6
147
+ required_rubygems_version: !ruby/object:Gem::Requirement
148
+ none: false
149
+ requirements:
150
+ - - ! '>='
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
153
+ segments:
154
+ - 0
155
+ hash: 2738681957006525016
156
+ requirements: []
157
+ rubyforge_project:
158
+ rubygems_version: 1.8.24
159
+ signing_key:
160
+ specification_version: 3
161
+ summary: Kill Bill client library.
162
+ test_files:
163
+ - spec/killbill_client/remote/api_spec.rb
164
+ - spec/killbill_client/remote/model_spec.rb
165
+ - spec/spec_helper.rb