killbill 1.0.15 → 1.0.16
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/Jarfile +4 -2
- data/VERSION +1 -1
- data/lib/killbill.rb +69 -13
- data/lib/killbill/creator.rb +16 -2
- data/lib/killbill/enum.rb +72 -0
- data/lib/killbill/gen/account.rb +43 -0
- data/lib/killbill/gen/account_data.rb +39 -0
- data/lib/killbill/gen/account_email.rb +25 -0
- data/lib/killbill/gen/audit_log.rb +28 -0
- data/lib/killbill/gen/blocking_state.rb +32 -0
- data/lib/killbill/gen/call_context.rb +29 -0
- data/lib/killbill/gen/call_origin.rb +34 -0
- data/lib/killbill/gen/currency.rb +34 -0
- data/lib/killbill/gen/custom_field.rb +27 -0
- data/lib/killbill/gen/date_time_zone.rb +35 -0
- data/lib/killbill/gen/ext_bus_event.rb +25 -0
- data/lib/killbill/gen/ext_bus_event_type.rb +34 -0
- data/lib/killbill/gen/invoice.rb +39 -0
- data/lib/killbill/gen/invoice_item.rb +37 -0
- data/lib/killbill/gen/invoice_payment.rb +31 -0
- data/lib/killbill/gen/invoice_payment_type.rb +34 -0
- data/lib/killbill/gen/object_type.rb +34 -0
- data/lib/killbill/gen/payment.rb +36 -0
- data/lib/killbill/gen/payment_attempt.rb +27 -0
- data/lib/killbill/gen/payment_info_plugin.rb +28 -0
- data/lib/killbill/gen/payment_method_info_plugin.rb +24 -0
- data/lib/killbill/gen/payment_method_kv_info.rb +21 -0
- data/lib/killbill/gen/payment_method_plugin.rb +36 -0
- data/lib/killbill/gen/payment_plugin_status.rb +34 -0
- data/lib/killbill/gen/refund.rb +29 -0
- data/lib/killbill/gen/refund_info_plugin.rb +27 -0
- data/lib/killbill/gen/refund_plugin_status.rb +34 -0
- data/lib/killbill/gen/require_gen.rb +38 -0
- data/lib/killbill/gen/subscription.rb +44 -0
- data/lib/killbill/gen/subscription_bundle.rb +27 -0
- data/lib/killbill/gen/subscription_source_type.rb +34 -0
- data/lib/killbill/gen/subscription_state.rb +34 -0
- data/lib/killbill/gen/tag.rb +26 -0
- data/lib/killbill/gen/tag_definition.rb +27 -0
- data/lib/killbill/gen/tenant_context.rb +21 -0
- data/lib/killbill/gen/user_type.rb +34 -0
- data/lib/killbill/gen/uuid.rb +22 -0
- data/lib/killbill/http_servlet.rb +10 -3
- data/lib/killbill/jconverter.rb +540 -0
- data/lib/killbill/jkillbill_api.rb +137 -0
- data/lib/killbill/jnotification.rb +0 -1
- data/lib/killbill/jpayment.rb +7 -19
- data/lib/killbill/jplugin.rb +27 -16
- data/lib/killbill/killbill_api.rb +28 -0
- data/lib/killbill/killbill_logger.rb +31 -8
- data/lib/killbill/notification.rb +0 -1
- data/lib/killbill/payment.rb +0 -5
- data/lib/killbill/plugin.rb +4 -46
- data/spec/killbill/base_plugin_spec.rb +2 -1
- data/spec/killbill/{jresponse/jconverter_spec.rb → jconverter_spec.rb} +46 -90
- data/spec/killbill/jnotification_spec.rb +2 -1
- data/spec/killbill/jpayment_spec.rb +17 -16
- data/spec/killbill/killbill_integration_spec.rb +1 -1
- data/spec/killbill/killbillapi_spec.rb +49 -0
- data/spec/killbill/payment_test.rb +5 -5
- data/spec/killbill/rack_handler_spec.rb +1 -2
- data/spec/spec_helper.rb +3 -0
- data/tools/java2ruby.rb +440 -0
- metadata +48 -26
- data/lib/killbill/jresponse/jconverter.rb +0 -126
- data/lib/killbill/jresponse/jevent.rb +0 -58
- data/lib/killbill/jresponse/jpayment_method_response.rb +0 -148
- data/lib/killbill/jresponse/jpayment_method_response_internal.rb +0 -54
- data/lib/killbill/jresponse/jpayment_response.rb +0 -74
- data/lib/killbill/jresponse/jrefund_response.rb +0 -68
- data/lib/killbill/response/event.rb +0 -18
- data/lib/killbill/response/payment_method_response.rb +0 -50
- data/lib/killbill/response/payment_method_response_internal.rb +0 -20
- data/lib/killbill/response/payment_response.rb +0 -26
- data/lib/killbill/response/payment_status.rb +0 -10
- data/lib/killbill/response/refund_response.rb +0 -25
- data/spec/killbill/jresponse/jevent_spec.rb +0 -18
- data/spec/killbill/jresponse/jpayment_method_response_internal_spec.rb +0 -34
- data/spec/killbill/jresponse/jpayment_method_response_spec.rb +0 -53
- data/spec/killbill/jresponse/jpayment_response_spec.rb +0 -41
- data/spec/killbill/jresponse/jrefund_response_spec.rb +0 -41
@@ -0,0 +1,137 @@
|
|
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
|
data/lib/killbill/jpayment.rb
CHANGED
@@ -4,21 +4,10 @@ require 'singleton'
|
|
4
4
|
|
5
5
|
require 'killbill/creator'
|
6
6
|
require 'killbill/plugin'
|
7
|
-
require 'killbill/
|
8
|
-
require 'killbill/jresponse/jrefund_response'
|
9
|
-
require 'killbill/jresponse/jpayment_method_response'
|
10
|
-
require 'killbill/jresponse/jpayment_method_response_internal'
|
7
|
+
require 'killbill/jconverter'
|
11
8
|
|
12
9
|
include Java
|
13
10
|
|
14
|
-
class String
|
15
|
-
def snake_case
|
16
|
-
return downcase if match(/\A[A-Z]+\z/)
|
17
|
-
gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2').
|
18
|
-
gsub(/([a-z])([A-Z])/, '\1_\2').
|
19
|
-
downcase
|
20
|
-
end
|
21
|
-
end
|
22
11
|
|
23
12
|
module Killbill
|
24
13
|
module Plugin
|
@@ -26,7 +15,6 @@ module Killbill
|
|
26
15
|
java_package 'com.ning.billing.payment.plugin.api'
|
27
16
|
class JPayment < JPlugin
|
28
17
|
|
29
|
-
# java_implements com.ning.billing.payment.plugin.api.PaymentPluginApi
|
30
18
|
include com.ning.billing.payment.plugin.api.PaymentPluginApi
|
31
19
|
|
32
20
|
def initialize(real_class_name, services = {})
|
@@ -36,21 +24,21 @@ module Killbill
|
|
36
24
|
java_signature 'com.ning.billing.payment.plugin.api.PaymentInfoPlugin processPayment(java.util.UUID, java.util.UUID, java.util.UUID, java.lang.BigDecimal, com.ning.billing.catalog.api.Currency, com.ning.billing.util.callcontext.CallContext)'
|
37
25
|
def process_payment(*args)
|
38
26
|
do_call_handle_exception(__method__, *args) do |res|
|
39
|
-
return
|
27
|
+
return JConverter.to_payment_info_plugin(res)
|
40
28
|
end
|
41
29
|
end
|
42
30
|
|
43
31
|
java_signature 'Java::com.ning.billing.payment.plugin.api.PaymentInfoPlugin getPaymentInfo(java.util.UUID, java.util.UUID, Java::com.ning.billing.util.callcontext.TenantContext)'
|
44
32
|
def get_payment_info(*args)
|
45
33
|
do_call_handle_exception(__method__, *args) do |res|
|
46
|
-
return
|
34
|
+
return JConverter.to_payment_info_plugin(res)
|
47
35
|
end
|
48
36
|
end
|
49
37
|
|
50
38
|
java_signature 'Java::com.ning.billing.payment.plugin.api.RefundInfoPlugin processRefund(java.util.UUID, java.util.UUID, java.lang.BigDecimal, com.ning.billing.catalog.api.Currency, Java::com.ning.billing.util.callcontext.CallContext)'
|
51
39
|
def process_refund(*args)
|
52
40
|
do_call_handle_exception(__method__, *args) do |res|
|
53
|
-
return
|
41
|
+
return JConverter.to_refund_info_plugin(res)
|
54
42
|
end
|
55
43
|
end
|
56
44
|
|
@@ -59,7 +47,7 @@ module Killbill
|
|
59
47
|
do_call_handle_exception(__method__, *args) do |res|
|
60
48
|
array_res = java.util.ArrayList.new
|
61
49
|
res.each do |el|
|
62
|
-
array_res.add(
|
50
|
+
array_res.add(JConverter.to_refund_info_plugin(el))
|
63
51
|
end
|
64
52
|
return array_res
|
65
53
|
end
|
@@ -82,7 +70,7 @@ module Killbill
|
|
82
70
|
java_signature 'Java::com.ning.billing.payment.api.PaymentMethodPlugin getPaymentMethodDetail(java.util.UUID, java.util.UUID, Java::com.ning.billing.util.callcontext.TenantContext)'
|
83
71
|
def get_payment_method_detail(*args)
|
84
72
|
do_call_handle_exception(__method__, *args) do |res|
|
85
|
-
return
|
73
|
+
return JConverter.to_payment_method_response(res)
|
86
74
|
end
|
87
75
|
end
|
88
76
|
|
@@ -98,7 +86,7 @@ module Killbill
|
|
98
86
|
do_call_handle_exception(__method__, *args) do |res|
|
99
87
|
array_res = java.util.ArrayList.new
|
100
88
|
res.each do |el|
|
101
|
-
array_res.add(
|
89
|
+
array_res.add(JConverter.to_payment_method_info_plugin(el))
|
102
90
|
end
|
103
91
|
return array_res
|
104
92
|
end
|
data/lib/killbill/jplugin.rb
CHANGED
@@ -15,15 +15,20 @@ module Killbill
|
|
15
15
|
module Plugin
|
16
16
|
class JPlugin
|
17
17
|
|
18
|
-
|
18
|
+
|
19
|
+
attr_reader :delegate_plugin,
|
20
|
+
# Called by the Killbill lifecycle to register the servlet
|
21
|
+
:rack_handler
|
19
22
|
|
20
23
|
# Called by the Killbill lifecycle when initializing the plugin
|
21
24
|
def start_plugin
|
22
25
|
@delegate_plugin.start_plugin
|
26
|
+
configure_rack_handler
|
23
27
|
end
|
24
28
|
|
25
29
|
# Called by the Killbill lifecycle when stopping the plugin
|
26
30
|
def stop_plugin
|
31
|
+
unconfigure_rack_handler
|
27
32
|
@delegate_plugin.stop_plugin
|
28
33
|
end
|
29
34
|
|
@@ -36,27 +41,29 @@ module Killbill
|
|
36
41
|
@delegate_plugin = Creator.new(plugin_class_name).create(services)
|
37
42
|
end
|
38
43
|
|
39
|
-
|
40
|
-
|
44
|
+
def logger
|
45
|
+
require 'logger'
|
46
|
+
@delegate_plugin.nil? ? ::Logger.new(STDOUT) : @delegate_plugin.logger
|
47
|
+
end
|
48
|
+
|
49
|
+
protected
|
50
|
+
|
51
|
+
def configure_rack_handler
|
41
52
|
config_ru = Pathname.new("#{@delegate_plugin.root}/config.ru").expand_path
|
42
53
|
if config_ru.file?
|
43
54
|
logger.info "Found Rack configuration file at #{config_ru.to_s}"
|
44
|
-
|
45
|
-
|
46
|
-
instance
|
55
|
+
@rack_handler = Killbill::Plugin::RackHandler.instance
|
56
|
+
@rack_handler.configure(logger, config_ru.to_s) unless @rack_handler.configured?
|
47
57
|
else
|
48
58
|
logger.info "No Rack configuration file found at #{config_ru.to_s}"
|
49
59
|
nil
|
50
60
|
end
|
51
61
|
end
|
52
62
|
|
53
|
-
def
|
54
|
-
|
55
|
-
@delegate_plugin.nil? ? ::Logger.new(STDOUT) : @delegate_plugin.logger
|
63
|
+
def unconfigure_rack_handler
|
64
|
+
@rack_handler.unconfigure unless @rack_handler.nil?
|
56
65
|
end
|
57
66
|
|
58
|
-
protected
|
59
|
-
|
60
67
|
def do_call_handle_exception(method_name, *args)
|
61
68
|
begin
|
62
69
|
rargs = convert_args(method_name, args)
|
@@ -85,7 +92,8 @@ module Killbill
|
|
85
92
|
elsif a.java_kind_of? java.util.UUID
|
86
93
|
JConverter.from_uuid(a)
|
87
94
|
elsif a.java_kind_of? java.math.BigDecimal
|
88
|
-
|
95
|
+
# A bit fragile if what we recieve is not a price...
|
96
|
+
JConverter.from_big_decimal_with_cents_conversion(a)
|
89
97
|
elsif a.java_kind_of? Java::com.ning.billing.catalog.api.Currency
|
90
98
|
a.to_string
|
91
99
|
elsif a.java_kind_of? Java::com.ning.billing.payment.api.PaymentMethodPlugin
|
@@ -110,15 +118,18 @@ module Killbill
|
|
110
118
|
end
|
111
119
|
end
|
112
120
|
result
|
121
|
+
elsif a.java_kind_of? Java::com.ning.billing.util.callcontext.CallContext
|
122
|
+
JConverter.from_call_context(a)
|
123
|
+
elsif a.java_kind_of? Java::com.ning.billing.util.callcontext.TenantContext
|
124
|
+
JConverter.from_tenant_context(a)
|
113
125
|
else
|
114
126
|
# Since we don't pass the Context at this point, we can't raise any exceptions for unexpected types.
|
115
|
-
|
116
|
-
nil
|
127
|
+
raise Java::com.ning.billing.payment.plugin.api.PaymentPluginApiException.new("#{api} failure", "Unexpected parameter type #{a.class}")
|
117
128
|
end
|
118
129
|
end
|
119
130
|
# Remove last argument if this is null (it means we passed a context)
|
120
|
-
args.delete_at(-1) if args[-1].nil?
|
121
|
-
args
|
131
|
+
#args.delete_at(-1) if args[-1].nil?
|
132
|
+
#args
|
122
133
|
end
|
123
134
|
|
124
135
|
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
module Killbill
|
4
|
+
module Plugin
|
5
|
+
|
6
|
+
#
|
7
|
+
# Represents a subset of the Killbill Apis offered to the ruby plugins
|
8
|
+
#
|
9
|
+
class KillbillApi
|
10
|
+
|
11
|
+
|
12
|
+
def initialize(japi_proxy)
|
13
|
+
@japi_proxy = japi_proxy
|
14
|
+
EXPORT_KILLBILL_API.each do |api|
|
15
|
+
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def method_missing(m, *args, &block)
|
20
|
+
# m being a symbol, to_s is required for Ruby 1.8
|
21
|
+
puts "Got missing method #{m.to_s}"
|
22
|
+
return @japi_proxy.proxy_api(m.to_s, *args) if EXPORT_KILLBILL_API.include? m.to_s
|
23
|
+
raise NoMethodError.new("undefined method `#{m}' for #{self}")
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -1,4 +1,6 @@
|
|
1
1
|
# Plugin logger that will delegate to the OSGI LogService
|
2
|
+
# Used for regular logging for plugins, as well as Rack logger and Error Stream
|
3
|
+
# Methods to implement for rack are described here: http://rack.rubyforge.org/doc/SPEC.html
|
2
4
|
module Killbill
|
3
5
|
module Plugin
|
4
6
|
class KillbillLogger
|
@@ -6,20 +8,41 @@ module Killbill
|
|
6
8
|
@logger = delegate
|
7
9
|
end
|
8
10
|
|
9
|
-
def debug(
|
10
|
-
@logger.log(4,
|
11
|
+
def debug(message, &block)
|
12
|
+
@logger.log(4, build_message(message, &block))
|
11
13
|
end
|
12
14
|
|
13
|
-
def info(
|
14
|
-
@logger.log(3,
|
15
|
+
def info(message, &block)
|
16
|
+
@logger.log(3, build_message(message, &block))
|
15
17
|
end
|
16
18
|
|
17
|
-
def warn(
|
18
|
-
@logger.log(2,
|
19
|
+
def warn(message, &block)
|
20
|
+
@logger.log(2, build_message(message, &block))
|
19
21
|
end
|
20
22
|
|
21
|
-
def error(
|
22
|
-
@logger.log(1,
|
23
|
+
def error(message, &block)
|
24
|
+
@logger.log(1, build_message(message, &block))
|
25
|
+
end
|
26
|
+
|
27
|
+
# Rack Error stream
|
28
|
+
alias_method :puts, :warn
|
29
|
+
alias_method :write, :warn
|
30
|
+
|
31
|
+
def flush
|
32
|
+
end
|
33
|
+
|
34
|
+
def close
|
35
|
+
end
|
36
|
+
|
37
|
+
def build_message(message, &block)
|
38
|
+
if message.nil?
|
39
|
+
if block_given?
|
40
|
+
message = yield
|
41
|
+
else
|
42
|
+
message = "(nil)"
|
43
|
+
end
|
44
|
+
end
|
45
|
+
message.nil? ? "(nil)" : message.to_s
|
23
46
|
end
|
24
47
|
|
25
48
|
alias_method :fatal, :error
|
data/lib/killbill/payment.rb
CHANGED
@@ -1,9 +1,4 @@
|
|
1
1
|
require 'killbill/plugin'
|
2
|
-
require 'killbill/response/payment_status'
|
3
|
-
require 'killbill/response/payment_response'
|
4
|
-
require 'killbill/response/refund_response'
|
5
|
-
require 'killbill/response/payment_method_response'
|
6
|
-
require 'killbill/response/payment_method_response_internal'
|
7
2
|
|
8
3
|
module Killbill
|
9
4
|
module Plugin
|
data/lib/killbill/plugin.rb
CHANGED
@@ -20,44 +20,18 @@ module Killbill
|
|
20
20
|
@active = false
|
21
21
|
end
|
22
22
|
|
23
|
-
attr_writer :account_user_api,
|
24
|
-
:analytics_sanity_api,
|
25
|
-
:analytics_user_api,
|
26
|
-
:catalog_user_api,
|
27
|
-
:entitlement_migration_api,
|
28
|
-
:entitlement_timeline_api,
|
29
|
-
:entitlement_transfer_api,
|
30
|
-
:entitlement_user_api,
|
31
|
-
:invoice_migration_api,
|
32
|
-
:invoice_payment_api,
|
33
|
-
:invoice_user_api,
|
34
|
-
:meter_user_api,
|
35
|
-
:overdue_user_api,
|
36
|
-
:payment_api,
|
37
|
-
:tenant_user_api,
|
38
|
-
:usage_user_api,
|
39
|
-
:audit_user_api,
|
40
|
-
:custom_field_user_api,
|
41
|
-
:export_user_api,
|
42
|
-
:tag_user_api
|
43
23
|
# Extra services
|
44
24
|
attr_accessor :root,
|
45
25
|
:logger,
|
46
|
-
:conf_dir
|
26
|
+
:conf_dir,
|
27
|
+
:kb_apis
|
47
28
|
|
48
29
|
# Called by the Killbill lifecycle when instantiating the plugin
|
49
|
-
def initialize(
|
30
|
+
def initialize()
|
50
31
|
@active = false
|
51
|
-
|
52
|
-
services.each do |service_name, service_instance|
|
53
|
-
begin
|
54
|
-
self.send("#{service_name}=", service_instance)
|
55
|
-
rescue NoMethodError
|
56
|
-
warn "Ignoring unsupported service: #{service_name}"
|
57
|
-
end
|
58
|
-
end
|
59
32
|
end
|
60
33
|
|
34
|
+
|
61
35
|
def logger=(logger)
|
62
36
|
# logger is an OSGI LogService in the Killbill environment. For testing purposes,
|
63
37
|
# allow delegation to a standard logger
|
@@ -72,22 +46,6 @@ module Killbill
|
|
72
46
|
def after_request
|
73
47
|
end
|
74
48
|
|
75
|
-
class APINotAvailableError < NotImplementedError
|
76
|
-
end
|
77
|
-
|
78
|
-
def method_missing(m, *args, &block)
|
79
|
-
# m being a symbol, to_s is required for Ruby 1.8
|
80
|
-
if m.to_s =~ /_api$/
|
81
|
-
api = self.instance_variable_get("@#{m.to_s}")
|
82
|
-
if api.nil?
|
83
|
-
raise APINotAvailableError.new("API #{m} is not available")
|
84
|
-
else
|
85
|
-
api
|
86
|
-
end
|
87
|
-
else
|
88
|
-
raise NoMethodError.new("undefined method `#{m}' for #{self}")
|
89
|
-
end
|
90
|
-
end
|
91
49
|
end
|
92
50
|
end
|
93
51
|
end
|