Class: Killbill::Plugin::Api::CatalogPluginApi

Inherits:
NotificationPluginApi show all
Defined in:
lib/killbill/gen/plugin-api/catalog_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 = {}) ⇒ CatalogPluginApi

Returns a new instance of CatalogPluginApi.



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

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

Instance Method Details

#get_latest_catalog_version(properties, context) ⇒ 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
73
74
75
# File 'lib/killbill/gen/plugin-api/catalog_plugin_api.rb', line 44

def get_latest_catalog_version(properties, context)

  # 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.TenantContext]
  context = Killbill::Plugin::Model::TenantContext.new.to_ruby(context) unless context.nil?
  begin
    res = @delegate_plugin.get_latest_catalog_version(properties, context)
    # conversion for res [type = org.joda.time.DateTime]
    if !res.nil?
      res =  (res.kind_of? Time) ? DateTime.parse(res.to_s) : res
      res = Java::org.joda.time.DateTime.new(res.to_s, Java::org.joda.time.DateTimeZone::UTC)
    end
    return res
  rescue Exception => e
    message = "Failure in get_latest_catalog_version: #{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_latest_catalog_version failure", e.message)
  ensure
    @delegate_plugin.after_request
  end
end

#get_versioned_plugin_catalog(properties, context) ⇒ Object



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
# File 'lib/killbill/gen/plugin-api/catalog_plugin_api.rb', line 78

def get_versioned_plugin_catalog(properties, context)

  # 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.TenantContext]
  context = Killbill::Plugin::Model::TenantContext.new.to_ruby(context) unless context.nil?
  begin
    res = @delegate_plugin.get_versioned_plugin_catalog(properties, context)
    # conversion for res [type = org.killbill.billing.catalog.plugin.api.VersionedPluginCatalog]
    res = res.to_java unless res.nil?
    return res
  rescue Exception => e
    message = "Failure in get_versioned_plugin_catalog: #{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_versioned_plugin_catalog failure", e.message)
  ensure
    @delegate_plugin.after_request
  end
end