class Geocoder::Lookup::GooglePlacesSearch

def base_query_url(query)

def base_query_url(query)
  "#{protocol}://maps.googleapis.com/maps/api/place/findplacefromtext/json?"
end

def default_fields

def default_fields
  legacy = %w[id reference]
  basic = %w[business_status formatted_address geometry icon name 
    photos place_id plus_code types]
  contact = %w[opening_hours]
  atmosphere = %W[price_level rating user_ratings_total]
  format_fields(legacy, basic, contact, atmosphere)
end

def fields(query)

def fields(query)
  if query.options.has_key?(:fields)
    return format_fields(query.options[:fields])
  end
  if configuration.has_key?(:fields)
    return format_fields(configuration[:fields])
  end
  default_fields
end

def format_fields(*fields)

def format_fields(*fields)
  flattened = fields.flatten.compact
  return if flattened.empty?
  flattened.join(',')
end

def locationbias(query)

def locationbias(query)
  if query.options.has_key?(:locationbias)
    query.options[:locationbias]
  else
    configuration[:locationbias]
  end
end

def name

def name
  "Google Places Search"
end

def query_url_google_params(query)

def query_url_google_params(query)
  {
    input: query.text,
    inputtype: 'textquery',
    fields: fields(query),
    locationbias: locationbias(query),
    language: query.language || configuration.language
  }
end

def required_api_key_parts

def required_api_key_parts
  ["key"]
end

def result_root_attr

def result_root_attr
  'candidates'
end

def supported_protocols

def supported_protocols
  [:https]
end