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
@@ -0,0 +1,127 @@
1
+ ###################################################################################
2
+ # #
3
+ # Copyright 2010-2013 Ning, Inc. #
4
+ # #
5
+ # Ning licenses this file to you under the Apache License, version 2.0 #
6
+ # (the "License"); you may not use this file except in compliance with the #
7
+ # License. You may obtain a copy of the License at: #
8
+ # #
9
+ # http://www.apache.org/licenses/LICENSE-2.0 #
10
+ # #
11
+ # Unless required by applicable law or agreed to in writing, software #
12
+ # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT #
13
+ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the #
14
+ # License for the specific language governing permissions and limitations #
15
+ # under the License. #
16
+ # #
17
+ ###################################################################################
18
+
19
+
20
+ #
21
+ # DO NOT EDIT!!!
22
+ # File automatically generated by killbill-java-parser (git@github.com:killbill/killbill-java-parser.git)
23
+ #
24
+
25
+
26
+ module Killbill
27
+ module Plugin
28
+ module Api
29
+
30
+ java_package 'com.ning.billing.tenant.api'
31
+ class TenantUserApi
32
+
33
+ include com.ning.billing.tenant.api.TenantUserApi
34
+
35
+ def initialize(real_java_api)
36
+ @real_java_api = real_java_api
37
+ end
38
+
39
+
40
+ java_signature 'Java::com.ning.billing.tenant.api.Tenant createTenant(Java::com.ning.billing.tenant.api.TenantData, Java::com.ning.billing.util.callcontext.CallContext)'
41
+ def create_tenant(data, context)
42
+ # conversion for data [type = com.ning.billing.tenant.api.TenantData]
43
+ data = data.to_java unless data.nil?
44
+ # conversion for context [type = com.ning.billing.util.callcontext.CallContext]
45
+ context = context.to_java unless context.nil?
46
+ begin
47
+ res = @real_java_api.create_tenant(data, context)
48
+ # conversion for res [type = com.ning.billing.tenant.api.Tenant]
49
+ res = Killbill::Plugin::Model::Tenant.new.to_ruby(res) unless res.nil?
50
+ return res
51
+ rescue Java::com.ning.billing.tenant.api.TenantApiException => e
52
+ raise Killbill::Plugin::Model::TenantApiException.new.to_ruby(e)
53
+ end
54
+ end
55
+
56
+ java_signature 'Java::com.ning.billing.tenant.api.Tenant getTenantByApiKey(Java::java.lang.String)'
57
+ def get_tenant_by_api_key(key)
58
+ # conversion for key [type = java.lang.String]
59
+ key = key.to_s unless key.nil?
60
+ begin
61
+ res = @real_java_api.get_tenant_by_api_key(key)
62
+ # conversion for res [type = com.ning.billing.tenant.api.Tenant]
63
+ res = Killbill::Plugin::Model::Tenant.new.to_ruby(res) unless res.nil?
64
+ return res
65
+ rescue Java::com.ning.billing.tenant.api.TenantApiException => e
66
+ raise Killbill::Plugin::Model::TenantApiException.new.to_ruby(e)
67
+ end
68
+ end
69
+
70
+ java_signature 'Java::com.ning.billing.tenant.api.Tenant getTenantById(Java::java.util.UUID)'
71
+ def get_tenant_by_id(tenantId)
72
+ # conversion for tenantId [type = java.util.UUID]
73
+ tenantId = java.util.UUID.fromString(tenantId.to_s) unless tenantId.nil?
74
+ begin
75
+ res = @real_java_api.get_tenant_by_id(tenantId)
76
+ # conversion for res [type = com.ning.billing.tenant.api.Tenant]
77
+ res = Killbill::Plugin::Model::Tenant.new.to_ruby(res) unless res.nil?
78
+ return res
79
+ rescue Java::com.ning.billing.tenant.api.TenantApiException => e
80
+ raise Killbill::Plugin::Model::TenantApiException.new.to_ruby(e)
81
+ end
82
+ end
83
+
84
+ java_signature 'Java::java.util.List getTenantValueForKey(Java::java.lang.String, Java::com.ning.billing.util.callcontext.TenantContext)'
85
+ def get_tenant_value_for_key(key, context)
86
+ # conversion for key [type = java.lang.String]
87
+ key = key.to_s unless key.nil?
88
+ # conversion for context [type = com.ning.billing.util.callcontext.TenantContext]
89
+ context = context.to_java unless context.nil?
90
+ begin
91
+ res = @real_java_api.get_tenant_value_for_key(key, context)
92
+ # conversion for res [type = java.util.List]
93
+ tmp = []
94
+ (res || []).each do |m|
95
+ # conversion for m [type = java.lang.String]
96
+ tmp << m
97
+ end
98
+ res = tmp
99
+ return res
100
+ rescue Java::com.ning.billing.tenant.api.TenantApiException => e
101
+ raise Killbill::Plugin::Model::TenantApiException.new.to_ruby(e)
102
+ end
103
+ end
104
+
105
+ java_signature 'Java::void addTenantKeyValue(Java::java.lang.String, Java::java.lang.String, Java::com.ning.billing.util.callcontext.CallContext)'
106
+ def add_tenant_key_value(key, value, context)
107
+ # conversion for key [type = java.lang.String]
108
+ key = key.to_s unless key.nil?
109
+ # conversion for value [type = java.lang.String]
110
+ value = value.to_s unless value.nil?
111
+ # conversion for context [type = com.ning.billing.util.callcontext.CallContext]
112
+ context = context.to_java unless context.nil?
113
+ @real_java_api.add_tenant_key_value(key, value, context)
114
+ end
115
+
116
+ java_signature 'Java::void deleteTenantKey(Java::java.lang.String, Java::com.ning.billing.util.callcontext.CallContext)'
117
+ def delete_tenant_key(key, context)
118
+ # conversion for key [type = java.lang.String]
119
+ key = key.to_s unless key.nil?
120
+ # conversion for context [type = com.ning.billing.util.callcontext.CallContext]
121
+ context = context.to_java unless context.nil?
122
+ @real_java_api.delete_tenant_key(key, context)
123
+ end
124
+ end
125
+ end
126
+ end
127
+ end
@@ -0,0 +1,55 @@
1
+ ###################################################################################
2
+ # #
3
+ # Copyright 2010-2013 Ning, Inc. #
4
+ # #
5
+ # Ning licenses this file to you under the Apache License, version 2.0 #
6
+ # (the "License"); you may not use this file except in compliance with the #
7
+ # License. You may obtain a copy of the License at: #
8
+ # #
9
+ # http://www.apache.org/licenses/LICENSE-2.0 #
10
+ # #
11
+ # Unless required by applicable law or agreed to in writing, software #
12
+ # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT #
13
+ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the #
14
+ # License for the specific language governing permissions and limitations #
15
+ # under the License. #
16
+ # #
17
+ ###################################################################################
18
+
19
+
20
+ #
21
+ # DO NOT EDIT!!!
22
+ # File automatically generated by killbill-java-parser (git@github.com:killbill/killbill-java-parser.git)
23
+ #
24
+
25
+
26
+ module Killbill
27
+ module Plugin
28
+ module Model
29
+
30
+ java_package 'com.ning.billing.catalog.api'
31
+ class Unit
32
+
33
+ include com.ning.billing.catalog.api.Unit
34
+
35
+ attr_accessor :name
36
+
37
+ def initialize()
38
+ end
39
+
40
+ def to_java()
41
+ # conversion for name [type = java.lang.String]
42
+ @name = @name.to_s unless @name.nil?
43
+ self
44
+ end
45
+
46
+ def to_ruby(j_obj)
47
+ # conversion for name [type = java.lang.String]
48
+ @name = j_obj.name
49
+ self
50
+ end
51
+
52
+ end
53
+ end
54
+ end
55
+ end
@@ -19,7 +19,7 @@ module Killbill
19
19
  super(real_class_name, services)
20
20
  end
21
21
 
22
- java_signature 'void onEvent(Java::com.ning.billing.beatrix.bus.api.ExtBusEvent)'
22
+ java_signature 'void onEvent(Java::com.ning.billing.notification.plugin.api.ExtBusEvent)'
23
23
  def on_event(*args)
24
24
  do_call_handle_exception(__method__, *args) do |res|
25
25
  return nil
@@ -4,7 +4,6 @@ require 'singleton'
4
4
 
5
5
  require 'killbill/creator'
6
6
  require 'killbill/plugin'
7
- require 'killbill/jconverter'
8
7
 
9
8
  include Java
10
9
 
@@ -24,21 +23,24 @@ module Killbill
24
23
  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)'
25
24
  def process_payment(*args)
26
25
  do_call_handle_exception(__method__, *args) do |res|
27
- return JConverter.to_payment_info_plugin(res)
26
+ res.to_java
27
+ return res
28
28
  end
29
29
  end
30
30
 
31
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)'
32
32
  def get_payment_info(*args)
33
33
  do_call_handle_exception(__method__, *args) do |res|
34
- return JConverter.to_payment_info_plugin(res)
34
+ res.to_java
35
+ return res
35
36
  end
36
37
  end
37
38
 
38
39
  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)'
39
40
  def process_refund(*args)
40
41
  do_call_handle_exception(__method__, *args) do |res|
41
- return JConverter.to_refund_info_plugin(res)
42
+ res.to_java
43
+ return res
42
44
  end
43
45
  end
44
46
 
@@ -47,7 +49,7 @@ module Killbill
47
49
  do_call_handle_exception(__method__, *args) do |res|
48
50
  array_res = java.util.ArrayList.new
49
51
  res.each do |el|
50
- array_res.add(JConverter.to_refund_info_plugin(el))
52
+ array_res.add(el.to_java)
51
53
  end
52
54
  return array_res
53
55
  end
@@ -70,7 +72,8 @@ module Killbill
70
72
  java_signature 'Java::com.ning.billing.payment.api.PaymentMethodPlugin getPaymentMethodDetail(java.util.UUID, java.util.UUID, Java::com.ning.billing.util.callcontext.TenantContext)'
71
73
  def get_payment_method_detail(*args)
72
74
  do_call_handle_exception(__method__, *args) do |res|
73
- return JConverter.to_payment_method_response(res)
75
+ res.to_java
76
+ return res
74
77
  end
75
78
  end
76
79
 
@@ -86,7 +89,7 @@ module Killbill
86
89
  do_call_handle_exception(__method__, *args) do |res|
87
90
  array_res = java.util.ArrayList.new
88
91
  res.each do |el|
89
- array_res.add(JConverter.to_payment_method_info_plugin(el))
92
+ array_res.add(el.to_java)
90
93
  end
91
94
  return array_res
92
95
  end
@@ -65,67 +65,69 @@ module Killbill
65
65
  end
66
66
 
67
67
  def do_call_handle_exception(method_name, *args)
68
- begin
69
- rargs = convert_args(method_name, args)
70
- res = @delegate_plugin.send(method_name.to_s.snake_case.to_sym, *rargs)
71
- yield(res)
72
- rescue Exception => e
73
- wrap_and_throw_exception(method_name, e)
74
- ensure
75
- @delegate_plugin.after_request
76
- end
77
- end
78
-
79
- def wrap_and_throw_exception(api, e)
80
- message = "#{api} failure: #{e}"
81
- unless e.backtrace.nil?
82
- message = "#{message}\n#{e.backtrace.join("\n")}"
83
- end
84
- logger.warn message
85
- raise Java::com.ning.billing.payment.plugin.api.PaymentPluginApiException.new("#{api} failure", e.message)
86
- end
87
-
88
- def convert_args(api, args)
89
- args.collect! do |a|
90
- if a.nil?
91
- nil
92
- elsif a.java_kind_of? java.util.UUID
93
- JConverter.from_uuid(a)
94
- elsif a.java_kind_of? java.math.BigDecimal
95
- # A bit fragile if what we recieve is not a price...
96
- JConverter.from_big_decimal_with_cents_conversion(a)
97
- elsif a.java_kind_of? Java::com.ning.billing.catalog.api.Currency
98
- a.to_string
99
- elsif a.java_kind_of? Java::com.ning.billing.payment.api.PaymentMethodPlugin
100
- JConverter.from_payment_method_plugin(a)
101
- elsif a.java_kind_of? Java::com.ning.billing.beatrix.bus.api.ExtBusEvent
102
- JConverter.from_ext_bus_event(a)
103
- elsif ((a.java_kind_of? Java::boolean) || (a.java_kind_of? java.lang.Boolean))
104
- JConverter.from_boolean(a)
105
- # Require because it looks like if non boxed value are passed they already arrive as Ruby type
106
- elsif ((a.java_kind_of? TrueClass) || (a.java_kind_of? FalseClass))
107
- a
108
- elsif a.java_kind_of? java.util.List
109
- result = Array.new
110
- if a.size > 0
111
- first_element = a.get(0)
112
- if first_element.java_kind_of? Java::com.ning.billing.payment.plugin.api.PaymentMethodInfoPlugin
113
- a.each do |el|
114
- result << JConverter.from_payment_method_info_plugin(el)
115
- end
116
- else
117
- raise Java::com.ning.billing.payment.plugin.api.PaymentPluginApiException.new("#{api} failure", "Unexpected parameter type #{first_element.class} for list")
118
- end
119
- end
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)
125
- else
126
- # Since we don't pass the Context at this point, we can't raise any exceptions for unexpected types.
127
- raise Java::com.ning.billing.payment.plugin.api.PaymentPluginApiException.new("#{api} failure", "Unexpected parameter type #{a.class}")
128
- end
68
+ begin
69
+ rargs = convert_args(method_name, args)
70
+ res = @delegate_plugin.send(method_name.to_s.snake_case.to_sym, *rargs)
71
+ yield(res)
72
+ rescue Exception => e
73
+ wrap_and_throw_exception(method_name, e)
74
+ ensure
75
+ @delegate_plugin.after_request
76
+ end
77
+ end
78
+
79
+ def wrap_and_throw_exception(api, e)
80
+ message = "#{api} failure: #{e}"
81
+ unless e.backtrace.nil?
82
+ message = "#{message}\n#{e.backtrace.join("\n")}"
83
+ end
84
+ logger.warn message
85
+ raise Java::com.ning.billing.payment.plugin.api.PaymentPluginApiException.new("#{api} failure", e.message)
86
+ end
87
+
88
+ def convert_args(api, args)
89
+ args.collect! do |a|
90
+ if a.nil?
91
+ nil
92
+ elsif a.java_kind_of? java.util.UUID
93
+ a.nil? ? nil : a.to_s
94
+ elsif a.java_kind_of? java.math.BigDecimal
95
+ a.nil? ? 0 : a.to_s.to_i
96
+ elsif a.java_kind_of? Java::com.ning.billing.catalog.api.Currency
97
+ a.to_string
98
+ elsif a.java_kind_of? Java::com.ning.billing.payment.api.PaymentMethodPlugin
99
+ Killbill::Plugin::Model::PaymentMethodPlugin.new.to_ruby(a)
100
+ elsif a.java_kind_of? Java::com.ning.billing.notification.plugin.api.ExtBusEvent
101
+ Killbill::Plugin::Model::ExtBusEvent.new.to_ruby(a)
102
+ elsif ((a.java_kind_of? Java::boolean) || (a.java_kind_of? java.lang.Boolean))
103
+ elsif ((a.java_kind_of? TrueClass) || (a.java_kind_of? FalseClass))
104
+ if a.nil?
105
+ false
106
+ else
107
+ b_value = (a.java_kind_of? java.lang.Boolean) ? a.boolean_value : a
108
+ b_value ? true : false
109
+ end
110
+ elsif a.java_kind_of? java.util.List
111
+ result = Array.new
112
+ if a.size > 0
113
+ first_element = a.get(0)
114
+ if first_element.java_kind_of? Java::com.ning.billing.payment.plugin.api.PaymentMethodInfoPlugin
115
+ a.each do |el|
116
+ result << Killbill::Plugin::Model::PaymentMethodInfoPlugin.new.to_ruby(el)
117
+ end
118
+ else
119
+ raise Java::com.ning.billing.payment.plugin.api.PaymentPluginApiException.new("#{api} failure", "Unexpected parameter type #{first_element.class} for list")
120
+ end
121
+ end
122
+ result
123
+ elsif a.java_kind_of? Java::com.ning.billing.util.callcontext.CallContext
124
+ Killbill::Plugin::Model::CallContext.new.to_ruby(a)
125
+ elsif a.java_kind_of? Java::com.ning.billing.util.callcontext.TenantContext
126
+ Killbill::Plugin::Model::TenantContext.new.to_ruby(a)
127
+ else
128
+ # Since we don't pass the Context at this point, we can't raise any exceptions for unexpected types.
129
+ raise Java::com.ning.billing.payment.plugin.api.PaymentPluginApiException.new("#{api} failure", "Unexpected parameter type #{a.class}")
130
+ end
129
131
  end
130
132
  # Remove last argument if this is null (it means we passed a context)
131
133
  #args.delete_at(-1) if args[-1].nil?
@@ -1,4 +1,4 @@
1
-
1
+ require 'date'
2
2
 
3
3
  module Killbill
4
4
  module Plugin
@@ -8,21 +8,54 @@ module Killbill
8
8
  #
9
9
  class KillbillApi
10
10
 
11
-
12
- def initialize(japi_proxy)
13
- @japi_proxy = japi_proxy
14
- EXPORT_KILLBILL_API.each do |api|
15
-
11
+ def initialize(plugin_name, java_service_map)
12
+ @plugin_name = plugin_name
13
+ @services = {}
14
+ puts "STEPH ::::::::::::::::: #{java_service_map.inspect}"
15
+ java_service_map.each do |k,v|
16
+ @services[k.to_sym] = create_proxy_api(k, v)
16
17
  end
17
18
  end
18
19
 
20
+ #
21
+ # Returns the proxy to the java api
22
+ #
19
23
  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
24
+
25
+ puts "Looking for api #{m}"
26
+
27
+ return @services[m.to_sym] if @services.include? m.to_sym
23
28
  raise NoMethodError.new("undefined method `#{m}' for #{self}")
24
29
  end
25
30
 
31
+
32
+ def create_context(tenant_id=nil, user_token=nil, reason_code=nil, comments=nil)
33
+ context = Killbill::Plugin::Model::CallContext.new
34
+ context.tenant_id= tenant_id
35
+ context.user_token= user_token
36
+ context.user_name= @plugin_name
37
+ context.call_origin= :EXTERNAL
38
+ context.user_type= :SYSTEM
39
+ context.reason_code= reason_code
40
+ context.comments= comments
41
+ context.created_date= DateTime.new
42
+ context.updated_date= DateTime.new
43
+ context
44
+ end
45
+
46
+ private
47
+
48
+ def create_proxy_api(api_name, java_api)
49
+ if api_name == "overdue_user_api"
50
+ return nil
51
+ end
52
+
53
+ puts "create_proxy_api #{api_name} #{java_api.inspect}"
54
+
55
+ proxy_class_name = "Killbill::Plugin::Api::#{api_name.to_s.split('_').map{|e| e.capitalize}.join}"
56
+ proxy_class_name.to_class.new(java_api)
57
+ end
58
+
26
59
  end
27
60
  end
28
61
  end