Class: Ip2Geo::Methods::GetConversion
- Inherits:
-
Object
- Object
- Ip2Geo::Methods::GetConversion
- Defined in:
- lib/ip2geo/methods/get_conversion.rb
Class Method Summary collapse
-
.call(options = {}) ⇒ Hash?
Retrieve a single conversion by its ID.
Class Method Details
.call(options = {}) ⇒ Hash?
Retrieve a single conversion by its ID.
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/ip2geo/methods/get_conversion.rb', line 13 def call( = {}) conversion_id = [:conversion_id] select = [:select] unless conversion_id return error_response( Data.translate('conversions.conversion-id-is-required') ) end params = [] params << "select=#{select.map { |f| "data.#{f}" }.join(',')}" if select.is_a?(Array) && !select.empty? query_string = params.empty? ? '' : "?#{params.join('&')}" url = "#{Data::API_ENDPOINT}#{Data::ENDPOINTS[:CONVERSIONS][:GET]}#{query_string}" Helpers::Http.request(url, { conversionId: conversion_id }) rescue StandardError => e warn "[Ip2Geo::GetConversion] Error: #{e.}" nil end |