killbill 1.0.19 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (128) hide show
  1. data/Jarfile +4 -2
  2. data/VERSION +1 -1
  3. data/killbill.gemspec +4 -3
  4. data/lib/killbill.rb +7 -51
  5. data/lib/killbill/creator.rb +10 -18
  6. data/lib/killbill/gen/account.rb +208 -27
  7. data/lib/killbill/gen/account_api_exception.rb +66 -0
  8. data/lib/killbill/gen/account_data.rb +166 -23
  9. data/lib/killbill/gen/account_email.rb +80 -8
  10. data/lib/killbill/gen/account_service.rb +55 -0
  11. data/lib/killbill/gen/account_user_api.rb +187 -0
  12. data/lib/killbill/gen/audit_user_api.rb +196 -0
  13. data/lib/killbill/gen/beatrix_service.rb +55 -0
  14. data/lib/killbill/gen/billing_exception_base.rb +66 -0
  15. data/lib/killbill/gen/blockable.rb +91 -0
  16. data/lib/killbill/gen/blocking_api_exception.rb +66 -0
  17. data/lib/killbill/gen/blocking_state.rb +150 -16
  18. data/lib/killbill/gen/call_context.rb +107 -13
  19. data/lib/killbill/gen/catalog.rb +76 -0
  20. data/lib/killbill/gen/catalog_api_exception.rb +66 -0
  21. data/lib/killbill/gen/catalog_service.rb +69 -0
  22. data/lib/killbill/gen/catalog_user_api.rb +54 -0
  23. data/lib/killbill/gen/column_info.rb +67 -0
  24. data/lib/killbill/gen/control_tag.rb +112 -0
  25. data/lib/killbill/gen/currency_value_null.rb +66 -0
  26. data/lib/killbill/gen/custom_field.rb +93 -10
  27. data/lib/killbill/gen/custom_field_api_exception.rb +66 -0
  28. data/lib/killbill/gen/custom_field_user_api.rb +115 -0
  29. data/lib/killbill/gen/database_export_output_stream.rb +51 -0
  30. data/lib/killbill/gen/default_mutable_account_data.rb +180 -0
  31. data/lib/killbill/gen/duration.rb +62 -0
  32. data/lib/killbill/gen/entitlement_service.rb +55 -0
  33. data/lib/killbill/gen/entitlement_user_api.rb +272 -0
  34. data/lib/killbill/gen/entitlement_user_api_exception.rb +66 -0
  35. data/lib/killbill/gen/entity.rb +84 -0
  36. data/lib/killbill/gen/entity_persistence_exception.rb +66 -0
  37. data/lib/killbill/gen/export_user_api.rb +17 -0
  38. data/lib/killbill/gen/ext_bus_event.rb +68 -9
  39. data/lib/killbill/gen/external_bus.rb +51 -0
  40. data/lib/killbill/gen/illegal_plan_change.rb +66 -0
  41. data/lib/killbill/gen/international_price.rb +79 -0
  42. data/lib/killbill/gen/invalid_config_exception.rb +49 -0
  43. data/lib/killbill/gen/invoice.rb +238 -23
  44. data/lib/killbill/gen/invoice_api_exception.rb +66 -0
  45. data/lib/killbill/gen/invoice_creation_event.rb +51 -0
  46. data/lib/killbill/gen/invoice_item.rb +179 -21
  47. data/lib/killbill/gen/invoice_migration_api.rb +66 -0
  48. data/lib/killbill/gen/invoice_notifier.rb +51 -0
  49. data/lib/killbill/gen/invoice_payment.rb +135 -15
  50. data/lib/killbill/gen/invoice_payment_api.rb +208 -0
  51. data/lib/killbill/gen/invoice_service.rb +55 -0
  52. data/lib/killbill/gen/invoice_user_api.rb +461 -0
  53. data/lib/killbill/gen/junction_api.rb +60 -0
  54. data/lib/killbill/gen/limit.rb +68 -0
  55. data/lib/killbill/gen/listing.rb +63 -0
  56. data/lib/killbill/gen/migration_account_data.rb +228 -0
  57. data/lib/killbill/gen/migration_plan.rb +143 -0
  58. data/lib/killbill/gen/mutable_account_data.rb +182 -0
  59. data/lib/killbill/gen/no_op_payment_plugin_api.rb +254 -0
  60. data/lib/killbill/gen/payment.rb +183 -20
  61. data/lib/killbill/gen/payment_api.rb +433 -0
  62. data/lib/killbill/gen/payment_api_exception.rb +66 -0
  63. data/lib/killbill/gen/payment_attempt.rb +100 -10
  64. data/lib/killbill/gen/payment_info_plugin.rb +103 -12
  65. data/lib/killbill/gen/payment_method.rb +116 -0
  66. data/lib/killbill/gen/payment_method_info_plugin.rb +64 -7
  67. data/lib/killbill/gen/payment_method_kv_info.rb +56 -6
  68. data/lib/killbill/gen/payment_method_plugin.rb +142 -20
  69. data/lib/killbill/gen/payment_plugin_api.rb +232 -0
  70. data/lib/killbill/gen/payment_plugin_api_exception.rb +59 -0
  71. data/lib/killbill/gen/payment_service.rb +62 -0
  72. data/lib/killbill/gen/plan.rb +143 -0
  73. data/lib/killbill/gen/plan_change_result.rb +68 -0
  74. data/lib/killbill/gen/plan_phase.rb +104 -0
  75. data/lib/killbill/gen/plan_phase_specifier.rb +80 -0
  76. data/lib/killbill/gen/plan_specifier.rb +73 -0
  77. data/lib/killbill/gen/price.rb +67 -0
  78. data/lib/killbill/gen/price_list.rb +74 -0
  79. data/lib/killbill/gen/price_list_set.rb +56 -0
  80. data/lib/killbill/gen/product.rb +101 -0
  81. data/lib/killbill/gen/record_id_api.rb +55 -0
  82. data/lib/killbill/gen/refund.rb +126 -13
  83. data/lib/killbill/gen/refund_info_plugin.rb +96 -10
  84. data/lib/killbill/gen/require_gen.rb +97 -15
  85. data/lib/killbill/gen/static_catalog.rb +137 -0
  86. data/lib/killbill/gen/subscription.rb +258 -28
  87. data/lib/killbill/gen/subscription_bundle.rb +94 -10
  88. data/lib/killbill/gen/subscription_status_dry_run.rb +89 -0
  89. data/lib/killbill/gen/subscription_transition.rb +196 -0
  90. data/lib/killbill/gen/tag.rb +88 -9
  91. data/lib/killbill/gen/tag_api_exception.rb +66 -0
  92. data/lib/killbill/gen/tag_definition.rb +110 -10
  93. data/lib/killbill/gen/tag_definition_api_exception.rb +66 -0
  94. data/lib/killbill/gen/tag_user_api.rb +239 -0
  95. data/lib/killbill/gen/tenant.rb +102 -0
  96. data/lib/killbill/gen/tenant_api_exception.rb +66 -0
  97. data/lib/killbill/gen/tenant_context.rb +39 -4
  98. data/lib/killbill/gen/tenant_data.rb +67 -0
  99. data/lib/killbill/gen/tenant_kv.rb +96 -0
  100. data/lib/killbill/gen/tenant_service.rb +55 -0
  101. data/lib/killbill/gen/tenant_user_api.rb +127 -0
  102. data/lib/killbill/gen/unit.rb +55 -0
  103. data/lib/killbill/jnotification.rb +1 -1
  104. data/lib/killbill/jpayment.rb +10 -7
  105. data/lib/killbill/jplugin.rb +63 -61
  106. data/lib/killbill/killbill_api.rb +42 -9
  107. data/spec/killbill/jnotification_spec.rb +15 -1
  108. data/spec/killbill/jpayment_spec.rb +12 -8
  109. data/spec/killbill/killbillapi_spec.rb +23 -21
  110. data/spec/killbill/payment_plugin_spec.rb +1 -9
  111. data/spec/killbill/payment_test.rb +21 -5
  112. metadata +96 -22
  113. data/lib/killbill/gen/audit_log.rb +0 -28
  114. data/lib/killbill/gen/call_origin.rb +0 -34
  115. data/lib/killbill/gen/currency.rb +0 -34
  116. data/lib/killbill/gen/date_time_zone.rb +0 -35
  117. data/lib/killbill/gen/ext_bus_event_type.rb +0 -34
  118. data/lib/killbill/gen/invoice_payment_type.rb +0 -34
  119. data/lib/killbill/gen/object_type.rb +0 -34
  120. data/lib/killbill/gen/payment_plugin_status.rb +0 -34
  121. data/lib/killbill/gen/refund_plugin_status.rb +0 -34
  122. data/lib/killbill/gen/subscription_source_type.rb +0 -34
  123. data/lib/killbill/gen/subscription_state.rb +0 -34
  124. data/lib/killbill/gen/user_type.rb +0 -34
  125. data/lib/killbill/gen/uuid.rb +0 -22
  126. data/lib/killbill/jconverter.rb +0 -537
  127. data/lib/killbill/jkillbill_api.rb +0 -137
  128. data/spec/killbill/jconverter_spec.rb +0 -193
@@ -1,137 +0,0 @@
1
- require 'killbill/jconverter'
2
-
3
-
4
- module Killbill
5
- module Plugin
6
-
7
- class JKillbillApi
8
-
9
- attr_writer :account_user_api,
10
- :analytics_sanity_api,
11
- :analytics_user_api,
12
- :catalog_user_api,
13
- :entitlement_migration_api,
14
- :entitlement_timeline_api,
15
- :entitlement_transfer_api,
16
- :entitlement_user_api,
17
- :invoice_migration_api,
18
- :invoice_payment_api,
19
- :invoice_user_api,
20
- :meter_user_api,
21
- :overdue_user_api,
22
- :payment_api,
23
- :tenant_user_api,
24
- :usage_user_api,
25
- :audit_user_api,
26
- :custom_field_user_api,
27
- :export_user_api,
28
- :tag_user_api
29
-
30
-
31
- def initialize(plugin_name, services)
32
- @plugin_name = plugin_name
33
- @plugged_services = []
34
- services.each do |service_name, service_instance|
35
- begin
36
- self.send("#{service_name}=", service_instance)
37
- @plugged_services << service_instance
38
- rescue NoMethodError
39
- # Expected for non APIs (e.g. logger)
40
- #warn "Ignoring unsupported service: #{service_name}"
41
- end
42
- end
43
- end
44
-
45
- def proxy_api(method_name, *args)
46
- @plugged_services.each do |s|
47
- if s.class.method_defined?(method_name)
48
- puts "Found service #{s.to_s} : #{method_name}"
49
- return do_call_handle_exception(s, method_name, *args)
50
- end
51
- end
52
- raise APINotAvailableError.new("API #{method_name} is not available")
53
- end
54
-
55
- private
56
-
57
- def do_call_handle_exception(delegate_service, method_name, *args)
58
- begin
59
- # STEPH TODO hack tenant_id
60
- call_context = create_call_context(nil, nil, nil, nil)
61
- #puts "INPUT ARGS = #{args}"
62
- jargs = convert_args(method_name, args)
63
- #puts "OUTPUT JARGS = #{jargs.collect { |e| e.class}.join(", ")}"
64
- res = delegate_service.send(method_name, *jargs, call_context)
65
- if res.java_kind_of? Java::com.ning.billing.account.api.Account
66
- return JConverter.from_account(res)
67
- elsif res.java_kind_of? Java::com.ning.billing.util.tag.TagDefinition
68
- return JConverter.from_tag_definition(res)
69
- elsif res.java_kind_of? Java::com.ning.billing.util.tag.Tag
70
- return JConverter.from_tag(res)
71
- else
72
- return res
73
- end
74
-
75
- rescue Exception => e
76
- wrap_and_throw_exception(method_name, e)
77
- end
78
- end
79
-
80
- def wrap_and_throw_exception(api, e)
81
-
82
- raise e
83
-
84
- message = "#{api} failure: #{e}"
85
- unless e.backtrace.nil?
86
- message = "#{message}\n#{e.backtrace.join("\n")}"
87
- end
88
- raise ApiErrorException.new("#{api} failure : #{e.message}")
89
- end
90
-
91
- def convert_args(api, args)
92
-
93
-
94
- args.collect! do |a|
95
- if a.is_a? Killbill::Plugin::Model::Account
96
- JConverter.to_account(a)
97
- elsif a.is_a? Killbill::Plugin::Model::AccountData
98
- JConverter.to_account_data(a)
99
- elsif a.is_a? Killbill::Plugin::Model::UUID
100
- JConverter.to_uuid(a)
101
- elsif a.is_a? Killbill::Plugin::Model::ObjectType
102
- JConverter.to_object_type(a)
103
- else
104
- a
105
- end
106
- end
107
- end
108
-
109
-
110
- def create_tenant_context(tenant_id)
111
- Killbill::Plugin::Model::TenantContext.new(0)
112
- end
113
-
114
- def create_call_context(tenant_id, user_token, reason_code, comments)
115
- user_token = user_token.nil? ? java.util.UUID.randomUUID() : to_uuid(user_token)
116
- created_date = org.joda.time.DateTime.new(org.joda.time.DateTimeZone::UTC)
117
- updated_date = created_date
118
- Killbill::Plugin::Model::CallContext.new(tenant_id,
119
- user_token,
120
- @plugin_name,
121
- Java::com.ning.billing.util.callcontext.CallOrigin::EXTERNAL,
122
- Java::com.ning.billing.util.callcontext.UserType::SYSTEM,
123
- reason_code,
124
- comments,
125
- created_date,
126
- updated_date)
127
- end
128
-
129
- class ApiErrorException < Exception
130
- end
131
-
132
- class APINotAvailableError < NotImplementedError
133
- end
134
-
135
- end
136
- end
137
- end
@@ -1,193 +0,0 @@
1
- require 'spec_helper'
2
- require 'date'
3
- require 'killbill/jconverter'
4
-
5
- describe Killbill::Plugin::JConverter do
6
-
7
- it "should_test_uuid_converter" do
8
- input = "bf5c926e-3d9c-470e-b34b-0719d7b58323"
9
- output = Killbill::Plugin::JConverter.to_uuid(input)
10
- output.should be_an_instance_of java.util.UUID
11
- output.to_s.should == input
12
- end
13
-
14
- it "should_test_joda_date_time_converter" do
15
- input_str = '2013-03-11T16:05:11-07:00'
16
- expected_output_str = '2013-03-11T23:05:11.000Z'
17
- input = org.joda.time.DateTime.parse(input_str)
18
- output = Killbill::Plugin::JConverter.to_joda_date_time(input)
19
- output.should be_an_instance_of org.joda.time.DateTime
20
- output.to_s.should == expected_output_str
21
- end
22
-
23
- it "should_test_to_string_converter" do
24
- input = "great it works"
25
- output = Killbill::Plugin::JConverter.to_string(input)
26
- output.should be_an_instance_of java.lang.String
27
- output.should == input
28
- end
29
-
30
- it "should_test_to_string_converter_from_non_string" do
31
- input = 12
32
- output = Killbill::Plugin::JConverter.to_string(input)
33
- output.should be_an_instance_of java.lang.String
34
- output.should == input.to_s
35
- end
36
-
37
- it "should_test_payment_plugin_status_success_converter" do
38
- input = Killbill::Plugin::Model::PaymentPluginStatus.new(:PROCESSED)
39
- output = Killbill::Plugin::JConverter.to_payment_plugin_status(input)
40
- output.should be_an_instance_of Java::com.ning.billing.payment.plugin.api.PaymentPluginStatus
41
- output.should == Java::com.ning.billing.payment.plugin.api.PaymentPluginStatus::PROCESSED
42
- end
43
-
44
- it "should_test_payment_plugin_status_failed_converter" do
45
- input = Killbill::Plugin::Model::PaymentPluginStatus.new(:ERROR)
46
- output = Killbill::Plugin::JConverter.to_payment_plugin_status(input)
47
- output.should be_an_instance_of Java::com.ning.billing.payment.plugin.api.PaymentPluginStatus
48
- output.should == Java::com.ning.billing.payment.plugin.api.PaymentPluginStatus::ERROR
49
- end
50
-
51
- it "should_test_payment_plugin_status_undefined_converter" do
52
- input = Killbill::Plugin::Model::PaymentPluginStatus.new(:UNDEFINED)
53
- output = Killbill::Plugin::JConverter.to_payment_plugin_status(input)
54
- output.should be_an_instance_of Java::com.ning.billing.payment.plugin.api.PaymentPluginStatus
55
- output.should == Java::com.ning.billing.payment.plugin.api.PaymentPluginStatus::UNDEFINED
56
- end
57
-
58
- it "should_test_big_decimal_converter" do
59
- {
60
- nil => '0',
61
- 1 => '0.01',
62
- 0 => '0',
63
- -1 => '-0.01',
64
- 12376 => '12.376',
65
- -532 => '-5.32'
66
- }.each do |input,output|
67
- output = Killbill::Plugin::JConverter.to_big_decimal_with_cents_conversion(input)
68
- output.should be_an_instance_of java.math.BigDecimal
69
- output.to_s.should == output.to_s
70
- end
71
- end
72
-
73
- it "should_test_boolean_true_converter" do
74
- input = true
75
- output = Killbill::Plugin::JConverter.to_boolean(input)
76
- output.should be_an_instance_of java.lang.Boolean
77
- output.to_s == input.to_s
78
- end
79
-
80
- it "should_test_boolean_false_converter" do
81
- input = nil
82
- output = Killbill::Plugin::JConverter.to_boolean(input)
83
- output.should be_an_instance_of java.lang.Boolean
84
- output.to_s == "false"
85
- end
86
-
87
- it "should_test_uuid_from_converter" do
88
- input = java.util.UUID.random_uuid
89
- output = Killbill::Plugin::JConverter.from_uuid(input)
90
- output.should be_an_instance_of Killbill::Plugin::Model::UUID
91
- output.to_s.should == input.to_s
92
- end
93
-
94
-
95
- it "should_test_boolean_from_nil_converter" do
96
- input = nil
97
- output = Killbill::Plugin::JConverter.from_boolean(input)
98
- output.should be_an_instance_of FalseClass
99
- output.to_s == "false"
100
- end
101
-
102
- it "should_test_boolean_from_false_converter" do
103
- input = java.lang.Boolean.new("false")
104
- output = Killbill::Plugin::JConverter.from_boolean(input)
105
- output.should be_an_instance_of FalseClass
106
- output.to_s == "false"
107
- end
108
-
109
- it "should_test_boolean_from_false2_converter" do
110
- input = java.lang.Boolean.new("false").boolean_value
111
- output = Killbill::Plugin::JConverter.from_boolean(input)
112
- output.should be_an_instance_of FalseClass
113
- output.to_s == "false"
114
- end
115
-
116
- it "should_test_boolean_from_true_converter" do
117
- input = java.lang.Boolean.new("true")
118
- output = Killbill::Plugin::JConverter.from_boolean(input)
119
- output.should be_an_instance_of TrueClass
120
- output.to_s == "true"
121
- end
122
-
123
- it "should_test_boolean_from_true2_converter" do
124
- input = java.lang.Boolean.new("true").boolean_value
125
- output = Killbill::Plugin::JConverter.from_boolean(input)
126
- output.should be_an_instance_of TrueClass
127
- output.to_s == "true"
128
- end
129
-
130
-
131
- it "should_test_joda_time_from_converter" do
132
- input = org.joda.time.DateTime.new(org.joda.time.DateTimeZone::UTC)
133
- input = input.minus_millis(input.millis_of_second)
134
- output = Killbill::Plugin::JConverter.from_joda_date_time(input)
135
- output.should be_an_instance_of DateTime
136
-
137
- input_match = Killbill::Plugin::JConverter.to_joda_date_time(output)
138
- input_match.to_s.should == input.to_s
139
- end
140
-
141
- it "should_test_payment_status_from_converter" do
142
- input = Java::com.ning.billing.payment.plugin.api.PaymentPluginStatus::PROCESSED
143
- output = Killbill::Plugin::JConverter.from_payment_plugin_status(input)
144
- output.should == Killbill::Plugin::Model::PaymentPluginStatus.new(:PROCESSED)
145
- end
146
-
147
- it "should_test_big_decimal_from_converter" do
148
- input = java.math.BigDecimal::TEN
149
- output = Killbill::Plugin::JConverter.from_big_decimal_with_cents_conversion(input)
150
- output.should be_an_instance_of Fixnum
151
- output.to_s.should == "1000"
152
- end
153
-
154
- it "should_test_ext_bus_event__from_converter" do
155
-
156
- object_type = Java::com.ning.billing.ObjectType::INVOICE
157
- event_type = Java::com.ning.billing.beatrix.bus.api.ExtBusEventType::INVOICE_CREATION
158
- uuid = java.util.UUID.random_uuid
159
-
160
- input = Killbill::Plugin::Model::ExtBusEvent.new(event_type, object_type, uuid, uuid, uuid)
161
- output = Killbill::Plugin::JConverter.from_ext_bus_event(input)
162
-
163
- output.should be_an_instance_of Killbill::Plugin::Model::ExtBusEvent
164
-
165
- output.event_type.should == Killbill::Plugin::Model::ExtBusEventType.new(:INVOICE_CREATION)
166
-
167
- output.object_type.should == Killbill::Plugin::Model::ObjectType.new(:INVOICE)
168
-
169
- output.object_id.should be_an_instance_of Killbill::Plugin::Model::UUID
170
- output.object_id.to_s.should == Killbill::Plugin::JConverter.from_uuid(uuid).to_s
171
-
172
- output.account_id.should be_an_instance_of Killbill::Plugin::Model::UUID
173
- output.account_id.to_s.should == Killbill::Plugin::JConverter.from_uuid(uuid).to_s
174
-
175
- output.tenant_id.should be_an_instance_of Killbill::Plugin::Model::UUID
176
- output.tenant_id.to_s.should == Killbill::Plugin::JConverter.from_uuid(uuid).to_s
177
-
178
- end
179
- it "should_test_enum_object_type_from_converter" do
180
-
181
- java_object_type = Java::com.ning.billing.ObjectType::ACCOUNT
182
-
183
- ruby_object_type = Killbill::Plugin::JConverter.from_object_type(java_object_type)
184
- ruby_object_type.should be_an_instance_of Killbill::Plugin::Model::ObjectType
185
- ruby_object_type.enum.to_s.should == java_object_type.to_s
186
-
187
- java_object_type_back = Killbill::Plugin::JConverter.to_object_type(ruby_object_type)
188
- java_object_type_back.should be_an_instance_of Java::com.ning.billing.ObjectType
189
- java_object_type_back.to_s.should == java_object_type.to_s
190
- java_object_type_back.to_s.should == "ACCOUNT"
191
-
192
- end
193
- end