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 +4 -4
- data/README.md +1 -1
- data/ip2geo.gemspec +1 -1
- data/lib/ip2geo/data/constants.rb +4 -0
- data/lib/ip2geo/helpers/select.rb +25 -0
- data/lib/ip2geo/methods/get_conversion.rb +1 -1
- data/lib/ip2geo/methods/get_conversions.rb +1 -1
- data/lib/ip2geo/methods/list_conversions.rb +1 -1
- data/lib/ip2geo.rb +2 -1
- metadata +3 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 1f351a6f513382254a1df63bc64e6d233c8e2aceb5d4c55bc05e5ff15a4a6a93
|
|
4
|
+
data.tar.gz: c591a9431462958e4318caf0f77ef5dbb41044e5eaf769f6409047548e42c348
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 41bae8ece7beef8885fc0db59c4547ead255a226943994ada71d3b25903480dbdb49d7314c47b897c4aecf00d926368da30221f5a331d549921951630300112b
|
|
7
|
+
data.tar.gz: 2c95e88aed0728cd15ff2155e4a5a2aa0cb617877e24e813e3cc98243c491ea1c80d5a26076540614d538d2a66d3f7ad309406c3908dc0531dacce8fefb259c6
|
data/README.md
CHANGED
data/ip2geo.gemspec
CHANGED
|
@@ -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=#{
|
|
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=#{
|
|
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=#{
|
|
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.
|
|
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.
|
|
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-
|
|
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
|