Module: Booker::Helpers

Defined in:
lib/booker/helpers.rb

Class Method Summary collapse

Class Method Details

.format_date(time, zone = 'Eastern Time (US & Canada)') ⇒ Object

Formats a ruby date into the format the Booker wants it in their json API



6
7
8
9
10
# File 'lib/booker/helpers.rb', line 6

def self.format_date time, zone = 'Eastern Time (US & Canada)'
  return nil unless time

  "/Date(#{(time.in_time_zone(zone)).to_i * 1000})/"
end

.new_client_params(opts) ⇒ Object



19
20
21
22
23
24
25
26
27
# File 'lib/booker/helpers.rb', line 19

def self.new_client_params(opts)
   {
    'FirstName' => opts[:first_name],
    'LastName' => opts[:last_name],
    'HomePhone' => opts[:phone],
    'LocationID' => opts[:location_id],
    'Email' => opts[:email]
  }
end

.parse_date(time) ⇒ Object

Turn date given by booker api into ruby datetime



13
14
15
16
17
# File 'lib/booker/helpers.rb', line 13

def self.parse_date time
  return nil unless time

  Time.at( time.scan(/\d+/).first.to_i / 1000 ).to_datetime
end