module Booker::Helpers

Public Class Methods

format_date(time, zone = 'Eastern Time (US & Canada)') click to toggle source

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

# 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) click to toggle source
# 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) click to toggle source

Turn date given by booker api into ruby datetime

# 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