Class: Centaman::Filter

Inherits:
Object
  • Object
show all
Defined in:
lib/centaman/filter.rb

Overview

:nodoc:

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args = {}) ⇒ Filter

Returns a new instance of Filter.



7
8
9
10
11
12
13
14
15
# File 'lib/centaman/filter.rb', line 7

def initialize(args = {})
  @booking_type_id = args[:booking_type_id].try(:to_i)
  @booking_time_id = args[:booking_time_id].try(:to_i)
  @start_date = args[:start_date]
  @end_date = args[:end_date]
  @membership_type_id = args.fetch(:membership_type_id, nil).try(:to_i)
  @member_code = args.fetch(:member_code, nil).try(:to_i)
  @email = args.fetch(:email, nil)
end

Instance Attribute Details

#booking_time_idObject (readonly)

Returns the value of attribute booking_time_id.



4
5
6
# File 'lib/centaman/filter.rb', line 4

def booking_time_id
  @booking_time_id
end

#booking_type_idObject (readonly)

Returns the value of attribute booking_type_id.



4
5
6
# File 'lib/centaman/filter.rb', line 4

def booking_type_id
  @booking_type_id
end

#emailObject (readonly)

Returns the value of attribute email.



4
5
6
# File 'lib/centaman/filter.rb', line 4

def email
  @email
end

#end_dateObject (readonly)

Returns the value of attribute end_date.



4
5
6
# File 'lib/centaman/filter.rb', line 4

def end_date
  @end_date
end

#member_codeObject (readonly)

Returns the value of attribute member_code.



4
5
6
# File 'lib/centaman/filter.rb', line 4

def member_code
  @member_code
end

#membership_type_idObject (readonly)

Returns the value of attribute membership_type_id.



4
5
6
# File 'lib/centaman/filter.rb', line 4

def membership_type_id
  @membership_type_id
end

#start_dateObject (readonly)

Returns the value of attribute start_date.



4
5
6
# File 'lib/centaman/filter.rb', line 4

def start_date
  @start_date
end

Instance Method Details

#add_onsObject



59
60
61
# File 'lib/centaman/filter.rb', line 59

def add_ons
  Centaman::Service::AddOn.new(membership_type_id: membership_type_id).objects
end

#booking_timesObject



34
35
36
37
38
39
40
# File 'lib/centaman/filter.rb', line 34

def booking_times
  @booking_times ||= Centaman::Service::BookingTime.new(
    booking_type_id: booking_type_id,
    start_date: start_date,
    end_date: end_date
  ).objects
end

#booking_typesObject



26
27
28
# File 'lib/centaman/filter.rb', line 26

def booking_types
  @booking_types ||= Centaman::Service::BookingType.new.objects
end

#capacityObject



46
47
48
# File 'lib/centaman/filter.rb', line 46

def capacity
  @capacity ||= Centaman::Service::Capacity.new(booking_time_id: booking_time_id, start_date: start_date).objects.first
end

#find_add_on(membership_type_id, id) ⇒ Object



63
64
65
# File 'lib/centaman/filter.rb', line 63

def find_add_on(membership_type_id, id)
  Centaman::Service::AddOn.find(membership_type_id, id)
end

#find_booking_time(booking_time_id) ⇒ Object



21
22
23
24
# File 'lib/centaman/filter.rb', line 21

def find_booking_time(booking_time_id)
  raise "booking_time_id is required for find_booking_time method of #{self.class.name} class" if booking_time_id.nil?
  booking_times.detect { |c| c.id.to_s == booking_time_id.to_s }
end

#find_booking_type(booking_type_id) ⇒ Object



17
18
19
# File 'lib/centaman/filter.rb', line 17

def find_booking_type(booking_type_id)
  booking_types.detect { |c| c.booking_type_id == booking_type_id }
end

#find_member(args) ⇒ Object



67
68
69
70
71
72
# File 'lib/centaman/filter.rb', line 67

def find_member(args)
  Centaman::Service::Member.new(
    member_code: args[:member_code],
    email: args[:email]
  ).objects
end

#find_membership_type(membership_type_id) ⇒ Object



54
55
56
57
# File 'lib/centaman/filter.rb', line 54

def find_membership_type(membership_type_id)
  raise "membership_type_id is required for find_membership_type method of #{self.class.name} class" if membership_type_id.nil?
  Centaman::Service::MembershipType.find(membership_type_id)
end

#gift_ticketsObject



42
43
44
# File 'lib/centaman/filter.rb', line 42

def gift_tickets
  @gift_tickets ||= Centaman::Service::GiftTicket.new.objects
end

#membership_typesObject



50
51
52
# File 'lib/centaman/filter.rb', line 50

def membership_types
  Centaman::Service::MembershipType.new.objects
end

#ticketsObject



30
31
32
# File 'lib/centaman/filter.rb', line 30

def tickets
  @tickets ||= Centaman::Service::TicketType.new(booking_time_id: booking_time_id).objects
end