Class: Centaman::Service::BookingTime
- Inherits:
-
Centaman::Service
- Object
- Wrapper
- Centaman::Service
- Centaman::Service::BookingTime
- Includes:
- JsonWrapper
- Defined in:
- lib/centaman/service/booking_time.rb
Constant Summary
Constants inherited from Centaman::Service
Constants inherited from Wrapper
Instance Attribute Summary collapse
-
#booking_type_id ⇒ Object
readonly
Returns the value of attribute booking_type_id.
-
#end_date ⇒ Object
readonly
Returns the value of attribute end_date.
-
#start_date ⇒ Object
readonly
Returns the value of attribute start_date.
-
#timed_ticket_type_id ⇒ Object
readonly
Returns the value of attribute timed_ticket_type_id.
Attributes inherited from Wrapper
#api_password, #api_token, #api_username
Class Method Summary collapse
Instance Method Summary collapse
- #after_init(args) ⇒ Object
- #endpoint ⇒ Object
- #format_date_to_string(date) ⇒ Object
- #object_class ⇒ Object
- #options ⇒ Object
- #parse_dates ⇒ Object
Methods included from JsonWrapper
#additional_hash_to_serialize_after_response, #build_object, #build_objects, #objects
Methods inherited from Centaman::Service
#after_post, #fetch_all, #payload, #payload_key, #post, #wrap_request_in_case_of_timeout
Methods inherited from Wrapper
#generate_token, #headers, #initialize, #options_hash
Constructor Details
This class inherits a constructor from Centaman::Wrapper
Instance Attribute Details
#booking_type_id ⇒ Object (readonly)
Returns the value of attribute booking_type_id.
4 5 6 |
# File 'lib/centaman/service/booking_time.rb', line 4 def booking_type_id @booking_type_id end |
#end_date ⇒ Object (readonly)
Returns the value of attribute end_date.
4 5 6 |
# File 'lib/centaman/service/booking_time.rb', line 4 def end_date @end_date end |
#start_date ⇒ Object (readonly)
Returns the value of attribute start_date.
4 5 6 |
# File 'lib/centaman/service/booking_time.rb', line 4 def start_date @start_date end |
#timed_ticket_type_id ⇒ Object (readonly)
Returns the value of attribute timed_ticket_type_id.
4 5 6 |
# File 'lib/centaman/service/booking_time.rb', line 4 def timed_ticket_type_id @timed_ticket_type_id end |
Class Method Details
.find(booking_type_id, booking_time_id, date) ⇒ Object
18 19 20 21 22 23 24 25 26 |
# File 'lib/centaman/service/booking_time.rb', line 18 def self.find(booking_type_id, booking_time_id, date) obj = new( booking_type_id: booking_type_id, booking_time_id: booking_time_id, start_date: date, end_date: date ) obj.objects.detect {|obj| obj.id == booking_time_id } end |
Instance Method Details
#after_init(args) ⇒ Object
6 7 8 9 10 11 12 |
# File 'lib/centaman/service/booking_time.rb', line 6 def after_init(args) @booking_type_id = args[:booking_type_id] @start_date = args[:start_date] @end_date = args[:end_date] parse_dates @timed_ticket_type_id = args[:id] # when finding a particular time end |
#endpoint ⇒ Object
28 29 30 |
# File 'lib/centaman/service/booking_time.rb', line 28 def endpoint '/ticket_services/TimedTicketType' end |
#format_date_to_string(date) ⇒ Object
46 47 48 |
# File 'lib/centaman/service/booking_time.rb', line 46 def format_date_to_string(date) date.strftime('%Y-%m-%d') end |
#object_class ⇒ Object
14 15 16 |
# File 'lib/centaman/service/booking_time.rb', line 14 def object_class Centaman::Object::BookingTime end |
#options ⇒ Object
32 33 34 35 36 37 38 39 |
# File 'lib/centaman/service/booking_time.rb', line 32 def super + [ { key: 'BookingTypeId', value: booking_type_id }, { key: 'StartDate', value: start_date }, { key: 'EndDate', value: end_date }, { key: 'id', value: timed_ticket_type_id }, ] end |
#parse_dates ⇒ Object
41 42 43 44 |
# File 'lib/centaman/service/booking_time.rb', line 41 def parse_dates @start_date = start_date.present? && start_date.is_a?(Date) ? format_date_to_string(start_date) : start_date @end_date = end_date.present? && end_date.is_a?(Date) ? format_date_to_string(end_date) : end_date end |