class Gdsapi::Methods::GetPoints
Private Instance Methods
parse(body)
click to toggle source
Parsing routine invoked on JSON response parsed to hash @param [Hash] body - given response hash from GDS @return [Hash[Symbol => Array]] - point objects grouped by editing mode:
:upsert - objects inserted or updated since given timestamp :delete - objects deleted since given timestamp
# File lib/gdsapi/methods/get_points.rb, line 14 def parse(body) return {} if body.empty? points = body['points'] attributes = body['attributes'] grouped_points = points.group_by { |point| point['mod'] } parsed_points = grouped_points.map do |mod, hash_points| parsed_points = hash_points.map do |point| args = { id: point['id'], name: point['name'], latitude: point['latitude'], longitude: point['longitude'], parent: point['parent'], address: point['address'], attributes: match_attributes(point['attributes'], attributes), type: point['pointType'] } Gdsapi::Structs::Point.new args end [modes[mod], parsed_points] end Hash[parsed_points] end
path()
click to toggle source
# File lib/gdsapi/methods/get_points.rb, line 39 def path 'points' end
permitted_params()
click to toggle source
Query params :country [Number|String] - GDS country id for which points are fetched (optional) :location [Number|String] - GDS location id for which points are fetched (optional) :offset [Number|String] - number of records to be skipped when fetching chunks (optional) :limit [Number|String] - number of records to be fetched when fetching chunks (optional) :timestamp [String] - temporal checkpoint(i.e. date, records from which are interested)
(optional, format: yyyy-MM-dd’T’HH:mm:ssZ, GMT +2)
# File lib/gdsapi/methods/get_points.rb, line 62 def permitted_params %i(country location offset limit timestamp) end
transform_params(filtered_params)
click to toggle source
# File lib/gdsapi/methods/get_points.rb, line 43 def transform_params(filtered_params) filtered_params.tap do |params| if params[:timestamp] if params[:timestamp].respond_to?(:strftime) params[:timestamp] = params[:timestamp].strftime('%FT%T%z') else params[:timestamp] = params[:timestamp].to_s end end end end