Class: Killbill::Plugin::Api::InvoicePluginApi

Inherits:
NotificationPluginApi show all
Defined in:
lib/killbill/gen/plugin-api/invoice_plugin_api.rb

Instance Attribute Summary

Attributes inherited from JPlugin

#delegate_plugin, #rack_handler

Instance Method Summary collapse

Methods inherited from NotificationPluginApi

#on_event

Methods inherited from JPlugin

#is_active, #logger, #start_plugin, #stop_plugin

Constructor Details

#initialize(real_class_name, services = {}) ⇒ InvoicePluginApi

Returns a new instance of InvoicePluginApi.



38
39
40
# File 'lib/killbill/gen/plugin-api/invoice_plugin_api.rb', line 38

def initialize(real_class_name, services = {})
  super(real_class_name, services)
end

Instance Method Details

#get_additional_invoice_items(invoice, dryRun, properties, context) ⇒ Object



75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
# File 'lib/killbill/gen/plugin-api/invoice_plugin_api.rb', line 75

def get_additional_invoice_items(invoice, dryRun, properties, context)

  # conversion for invoice [type = org.killbill.billing.invoice.api.Invoice]
  invoice = Killbill::Plugin::Model::Invoice.new.to_ruby(invoice) unless invoice.nil?

  # conversion for dryRun [type = boolean]
  if dryRun.nil?
    dryRun = false
  else
    tmp_bool = (dryRun.java_kind_of? java.lang.Boolean) ? dryRun.boolean_value : dryRun
    dryRun = tmp_bool ? true : false
  end

  # conversion for properties [type = java.lang.Iterable]
  tmp = []
  (properties.nil? ? [] : properties.iterator).each do |m|
    # conversion for m [type = org.killbill.billing.payment.api.PluginProperty]
    m = Killbill::Plugin::Model::PluginProperty.new.to_ruby(m) unless m.nil?
    tmp << m
  end
  properties = tmp

  # conversion for context [type = org.killbill.billing.util.callcontext.CallContext]
  context = Killbill::Plugin::Model::CallContext.new.to_ruby(context) unless context.nil?
  begin
    res = @delegate_plugin.get_additional_invoice_items(invoice, dryRun, properties, context)
    # conversion for res [type = java.util.List]
    tmp = java.util.ArrayList.new
    (res || []).each do |m|
      # conversion for m [type = org.killbill.billing.invoice.api.InvoiceItem]
      m = m.to_java unless m.nil?
      tmp.add(m)
    end
    res = tmp
    return res
  rescue Exception => e
    message = "Failure in get_additional_invoice_items: #{e}"
    unless e.backtrace.nil?
      message = "#{message}\n#{e.backtrace.join("\n")}"
    end
    logger.warn message
    raise Java::org.killbill.billing.payment.plugin.api.PaymentPluginApiException.new("get_additional_invoice_items failure", e.message)
  ensure
    @delegate_plugin.after_request
  end
end

#on_failure_call(context, properties) ⇒ Object



154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
# File 'lib/killbill/gen/plugin-api/invoice_plugin_api.rb', line 154

def on_failure_call(context, properties)

  # conversion for context [type = org.killbill.billing.invoice.plugin.api.InvoiceContext]
  context = Killbill::Plugin::Model::InvoiceContext.new.to_ruby(context) unless context.nil?

  # conversion for properties [type = java.lang.Iterable]
  tmp = []
  (properties.nil? ? [] : properties.iterator).each do |m|
    # conversion for m [type = org.killbill.billing.payment.api.PluginProperty]
    m = Killbill::Plugin::Model::PluginProperty.new.to_ruby(m) unless m.nil?
    tmp << m
  end
  properties = tmp
  begin
    res = @delegate_plugin.on_failure_call(context, properties)
    # conversion for res [type = org.killbill.billing.invoice.plugin.api.OnFailureInvoiceResult]
    res = res.to_java unless res.nil?
    return res
  rescue Exception => e
    message = "Failure in on_failure_call: #{e}"
    unless e.backtrace.nil?
      message = "#{message}\n#{e.backtrace.join("\n")}"
    end
    logger.warn message
    raise Java::org.killbill.billing.payment.plugin.api.PaymentPluginApiException.new("on_failure_call failure", e.message)
  ensure
    @delegate_plugin.after_request
  end
end

#on_success_call(context, properties) ⇒ Object



123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
# File 'lib/killbill/gen/plugin-api/invoice_plugin_api.rb', line 123

def on_success_call(context, properties)

  # conversion for context [type = org.killbill.billing.invoice.plugin.api.InvoiceContext]
  context = Killbill::Plugin::Model::InvoiceContext.new.to_ruby(context) unless context.nil?

  # conversion for properties [type = java.lang.Iterable]
  tmp = []
  (properties.nil? ? [] : properties.iterator).each do |m|
    # conversion for m [type = org.killbill.billing.payment.api.PluginProperty]
    m = Killbill::Plugin::Model::PluginProperty.new.to_ruby(m) unless m.nil?
    tmp << m
  end
  properties = tmp
  begin
    res = @delegate_plugin.on_success_call(context, properties)
    # conversion for res [type = org.killbill.billing.invoice.plugin.api.OnSuccessInvoiceResult]
    res = res.to_java unless res.nil?
    return res
  rescue Exception => e
    message = "Failure in on_success_call: #{e}"
    unless e.backtrace.nil?
      message = "#{message}\n#{e.backtrace.join("\n")}"
    end
    logger.warn message
    raise Java::org.killbill.billing.payment.plugin.api.PaymentPluginApiException.new("on_success_call failure", e.message)
  ensure
    @delegate_plugin.after_request
  end
end

#prior_call(context, properties) ⇒ Object



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/killbill/gen/plugin-api/invoice_plugin_api.rb', line 44

def prior_call(context, properties)

  # conversion for context [type = org.killbill.billing.invoice.plugin.api.InvoiceContext]
  context = Killbill::Plugin::Model::InvoiceContext.new.to_ruby(context) unless context.nil?

  # conversion for properties [type = java.lang.Iterable]
  tmp = []
  (properties.nil? ? [] : properties.iterator).each do |m|
    # conversion for m [type = org.killbill.billing.payment.api.PluginProperty]
    m = Killbill::Plugin::Model::PluginProperty.new.to_ruby(m) unless m.nil?
    tmp << m
  end
  properties = tmp
  begin
    res = @delegate_plugin.prior_call(context, properties)
    # conversion for res [type = org.killbill.billing.invoice.plugin.api.PriorInvoiceResult]
    res = res.to_java unless res.nil?
    return res
  rescue Exception => e
    message = "Failure in prior_call: #{e}"
    unless e.backtrace.nil?
      message = "#{message}\n#{e.backtrace.join("\n")}"
    end
    logger.warn message
    raise Java::org.killbill.billing.payment.plugin.api.PaymentPluginApiException.new("prior_call failure", e.message)
  ensure
    @delegate_plugin.after_request
  end
end