Sha256: b30413aba209af50eb400c3a45f2f8b719d8793a1ecdedeb8059125855fbe6af
Contents?: true
Size: 1.2 KB
Versions: 6
Compression:
Stored size: 1.2 KB
Contents
class Kaui::Bundle < KillBillClient::Model::Bundle def self.find_by_id_or_key(bundle_id_or_key, options = {}) if bundle_id_or_key =~ /[A-Fa-f0-9]{8}-[A-Fa-f0-9]{4}-[A-Fa-f0-9]{4}-[A-Fa-f0-9]{4}-[A-Fa-f0-9]{12}/ bundle = find_by_id(bundle_id_or_key, options) rescue nil return bundle unless bundle.nil? end # Return the active one find_by_external_key(bundle_id_or_key, false, options) end def self.list_or_search(search_key = nil, offset = 0, limit = 10, options = {}) if search_key.present? find_in_batches_by_search_key(search_key, offset, limit, options) else find_in_batches(offset, limit, options) end end private def self.get_active_bundle_or_latest_created(bundles) return nil if bundles.empty? latest_start_date = nil latest_bundle = nil bundles.each do |b| b.subscriptions.each do |s| if s.product_category != 'ADD_ON' if latest_start_date.nil? || latest_start_date < s.start_date latest_start_date = s.start_date latest_bundle = b end return b if s.cancelled_date.nil? || s.cancelled_date > Time.now end end end latest_bundle end end
Version data entries
6 entries across 6 versions & 1 rubygems