ip2geo 0.0.3 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 50f0c6bf97839c3537e0560bfb9a9092f4082a25402bd1dc93646509e9e3c198
4
- data.tar.gz: 463aeee751dcabf9ecfba98663c4a651158e7ce6f397ff1271b2b8c8cf8e4c3f
3
+ metadata.gz: 1f351a6f513382254a1df63bc64e6d233c8e2aceb5d4c55bc05e5ff15a4a6a93
4
+ data.tar.gz: c591a9431462958e4318caf0f77ef5dbb41044e5eaf769f6409047548e42c348
5
5
  SHA512:
6
- metadata.gz: 84d089b7a87965c1d59593adab9d03a3c8b8966e3a0c38c6a1321fc0dd5fd493259f0a4ede7f1597233fc142f201b5e4b7cd6d0b1a10c01f78704bbbdd56221a
7
- data.tar.gz: ee10736fb63cbadc5ce38c1059f43eb460d9dc21ee8d7aa0f544dabac25d4710caf32915a2e721920a119c4f9a3fef014e9906878f15b3b27c39b96bbd55d687
6
+ metadata.gz: 41bae8ece7beef8885fc0db59c4547ead255a226943994ada71d3b25903480dbdb49d7314c47b897c4aecf00d926368da30221f5a331d549921951630300112b
7
+ data.tar.gz: 2c95e88aed0728cd15ff2155e4a5a2aa0cb617877e24e813e3cc98243c491ea1c80d5a26076540614d538d2a66d3f7ad309406c3908dc0531dacce8fefb259c6
data/README.md CHANGED
@@ -28,7 +28,7 @@
28
28
  •
29
29
  <a href='https://ip2geo.dev/docs'>
30
30
  <b>
31
- Documentation
31
+ Docs
32
32
  </b>
33
33
  </a>
34
34
  •
data/ip2geo.gemspec CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = 'ip2geo'
5
- spec.version = '0.0.3'
5
+ spec.version = '0.0.4'
6
6
  spec.authors = ['Ip2Geo']
7
7
  spec.email = ['support@ip2geo.dev']
8
8
 
@@ -43,6 +43,10 @@ module Ip2Geo
43
43
  }.freeze
44
44
  }.freeze
45
45
 
46
+ # The stored fields of a conversion, which `select` names as they are; every other field is read under `data.`.
47
+ CONVERSION_COLUMNS = %w[id uniqueId data status startedAt completedAt createdAt].freeze
48
+ SELECT_DATA_PREFIX = 'data.'
49
+
46
50
  SELECT = {
47
51
  IP: 'ip',
48
52
  TYPE: 'type',
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Ip2Geo
4
+ module Helpers
5
+ class Select
6
+ class << self
7
+ # Build the `select` query value of the conversions routes. Stored fields (id, uniqueId, status,
8
+ # createdAt, ...) are sent as they are and geolocation fields (the SELECT constants) under `data.`,
9
+ # comma-separated. A field already written with the prefix is left alone. The API always returns
10
+ # `uniqueId` alongside the selected fields.
11
+ #
12
+ # @param select [Array<String>] The fields to return
13
+ # @return [String] The value of the `select` query parameter
14
+ def build(select)
15
+ select.map do |field|
16
+ field = field.to_s
17
+ stored = Data::CONVERSION_COLUMNS.include?(field) || field.start_with?(Data::SELECT_DATA_PREFIX)
18
+
19
+ stored ? field : "#{Data::SELECT_DATA_PREFIX}#{field}"
20
+ end.join(',')
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -21,7 +21,7 @@ module Ip2Geo
21
21
  end
22
22
 
23
23
  params = ["conversionId=#{conversion_id}"]
24
- params << "select=#{select.map { |f| "data.#{f}" }.join(',')}" if select.is_a?(Array) && !select.empty?
24
+ params << "select=#{Helpers::Select.build(select)}" if select.is_a?(Array) && !select.empty?
25
25
 
26
26
  query_string = "?#{params.join('&')}"
27
27
  url = "#{Data::API_ENDPOINT}#{Data::ENDPOINTS[:CONVERSIONS][:GET]}#{query_string}"
@@ -21,7 +21,7 @@ module Ip2Geo
21
21
  end
22
22
 
23
23
  params = []
24
- params << "select=#{select.map { |f| "data.#{f}" }.join(',')}" if select.is_a?(Array) && !select.empty?
24
+ params << "select=#{Helpers::Select.build(select)}" if select.is_a?(Array) && !select.empty?
25
25
 
26
26
  query_string = params.empty? ? '' : "?#{params.join('&')}"
27
27
  url = "#{Data::API_ENDPOINT}#{Data::ENDPOINTS[:CONVERSIONS][:GET]}#{query_string}"
@@ -21,7 +21,7 @@ module Ip2Geo
21
21
  params = []
22
22
  params << "offset=#{offset}" if offset.positive?
23
23
  params << "limit=#{limit}" if limit != 50
24
- params << "select=#{select.map { |f| "data.#{f}" }.join(',')}" if select.is_a?(Array) && !select.empty?
24
+ params << "select=#{Helpers::Select.build(select)}" if select.is_a?(Array) && !select.empty?
25
25
  params << "ipSearch=#{ip_search}" if ip_search
26
26
 
27
27
  query_string = params.empty? ? '' : "?#{params.join('&')}"
data/lib/ip2geo.rb CHANGED
@@ -24,6 +24,7 @@ require_relative 'ip2geo/data/messages'
24
24
  require_relative 'ip2geo/helpers/cache'
25
25
  require_relative 'ip2geo/helpers/http'
26
26
  require_relative 'ip2geo/helpers/ip_validation'
27
+ require_relative 'ip2geo/helpers/select'
27
28
  require_relative 'ip2geo/helpers/check_version'
28
29
  require_relative 'ip2geo/methods/init'
29
30
  require_relative 'ip2geo/methods/convert_ip'
@@ -33,7 +34,7 @@ require_relative 'ip2geo/methods/get_conversions'
33
34
  require_relative 'ip2geo/methods/list_conversions'
34
35
 
35
36
  module Ip2Geo
36
- VERSION = '0.0.3'
37
+ VERSION = '0.0.4'
37
38
 
38
39
  class << self
39
40
  # Initializes the SDK with the given API key.
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ip2geo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ip2Geo
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2026-10-05 00:00:00.000000000 Z
10
+ date: 2026-10-27 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: json
@@ -43,6 +43,7 @@ files:
43
43
  - lib/ip2geo/helpers/check_version.rb
44
44
  - lib/ip2geo/helpers/http.rb
45
45
  - lib/ip2geo/helpers/ip_validation.rb
46
+ - lib/ip2geo/helpers/select.rb
46
47
  - lib/ip2geo/methods/convert_ip.rb
47
48
  - lib/ip2geo/methods/convert_ips.rb
48
49
  - lib/ip2geo/methods/get_conversion.rb