Module: LolcationClient::NearIn

Includes:
Configurations
Defined in:
lib/lolcation_client/near_in.rb

Instance Method Summary collapse

Methods included from Configurations

#configs, #sandbox?, #service_url, #token

Instance Method Details

#near_in(options = {}) ⇒ Object

Raises:

  • (ArgumentError)


8
9
10
11
12
# File 'lib/lolcation_client/near_in.rb', line 8

def near_in(options = {})
  raise ArgumentError, 'Latitude and Longitude is required' unless options[:latitude].present? || options[:longitude].present?

  process(do_post(options.merge(sandbox: sandbox?)), options)
end

#process(response, options) ⇒ Object



14
15
16
17
18
19
20
21
22
# File 'lib/lolcation_client/near_in.rb', line 14

def process(response, options)
  json = JSON.parse(response.body, object_class: OpenStruct)

  list = json['localizations']

  return list.map{|item| item.id.to_i} if options[:only_ids]

  list
end