ipfyi 0.1.0
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 +7 -0
- data/lib/ipfyi.rb +107 -0
- metadata +46 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: ac30ca551a15958ce55088515eb3b3d8badcff47c535562f078ad27ad1693f27
|
|
4
|
+
data.tar.gz: 3fa5418a2fd55639f6ca49cc8feb3420654b7881fa2d2c2a0635fb9cf92c744c
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 22fb8a5538b02eba4aa69bd617f1a568176a18299c31e6ef148b59469ed771c8fd37c566ebe4489582123ba7572582de3f86860a9ebc08b893f4b3c5a0dd141c
|
|
7
|
+
data.tar.gz: 626e616ead42fa332fb52ee9c68c83ef79ae584dd8ac6ac469219281d386cf3acc33e41af4273ce514745fa99c39fd50da4534b4c1f1859d832e342793ae18cb
|
data/lib/ipfyi.rb
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "net/http"
|
|
4
|
+
require "json"
|
|
5
|
+
require "uri"
|
|
6
|
+
|
|
7
|
+
# Ruby client for IPFYI REST API (ipfyi.com).
|
|
8
|
+
#
|
|
9
|
+
# client = IPFYI::Client.new
|
|
10
|
+
# result = client.search("query")
|
|
11
|
+
#
|
|
12
|
+
module IPFYI
|
|
13
|
+
class Client
|
|
14
|
+
BASE_URL = "https://ipfyi.com"
|
|
15
|
+
|
|
16
|
+
def initialize(base_url: BASE_URL)
|
|
17
|
+
@base_url = base_url
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def search(query)
|
|
21
|
+
get("/api/v1/rest/search/", q: query)
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
# List all asns.
|
|
25
|
+
def list_asns
|
|
26
|
+
get("/api/v1/rest/asns/")
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
# Get asn by slug.
|
|
30
|
+
def get_asn(slug)
|
|
31
|
+
get("/api/v1/rest/asns/#{slug}/")
|
|
32
|
+
end
|
|
33
|
+
# List all cities.
|
|
34
|
+
def list_cities
|
|
35
|
+
get("/api/v1/rest/cities/")
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
# Get city by slug.
|
|
39
|
+
def get_city(slug)
|
|
40
|
+
get("/api/v1/rest/cities/#{slug}/")
|
|
41
|
+
end
|
|
42
|
+
# List all faqs.
|
|
43
|
+
def list_faqs
|
|
44
|
+
get("/api/v1/rest/faqs/")
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
# Get faq by slug.
|
|
48
|
+
def get_faq(slug)
|
|
49
|
+
get("/api/v1/rest/faqs/#{slug}/")
|
|
50
|
+
end
|
|
51
|
+
# List all glossary categories.
|
|
52
|
+
def list_glossary_categories
|
|
53
|
+
get("/api/v1/rest/glossary-categories/")
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
# Get glossary category by slug.
|
|
57
|
+
def get_glossary_category(slug)
|
|
58
|
+
get("/api/v1/rest/glossary-categories/#{slug}/")
|
|
59
|
+
end
|
|
60
|
+
# List all glossary terms.
|
|
61
|
+
def list_glossary_terms
|
|
62
|
+
get("/api/v1/rest/glossary-terms/")
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
# Get glossary term by slug.
|
|
66
|
+
def get_glossary_term(slug)
|
|
67
|
+
get("/api/v1/rest/glossary-terms/#{slug}/")
|
|
68
|
+
end
|
|
69
|
+
# List all ip ranges.
|
|
70
|
+
def list_ip_ranges
|
|
71
|
+
get("/api/v1/rest/ip-ranges/")
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
# Get ip range by slug.
|
|
75
|
+
def get_ip_range(slug)
|
|
76
|
+
get("/api/v1/rest/ip-ranges/#{slug}/")
|
|
77
|
+
end
|
|
78
|
+
# List all isps.
|
|
79
|
+
def list_isps
|
|
80
|
+
get("/api/v1/rest/isps/")
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
# Get isp by slug.
|
|
84
|
+
def get_isp(slug)
|
|
85
|
+
get("/api/v1/rest/isps/#{slug}/")
|
|
86
|
+
end
|
|
87
|
+
# List all threats.
|
|
88
|
+
def list_threats
|
|
89
|
+
get("/api/v1/rest/threats/")
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
# Get threat by slug.
|
|
93
|
+
def get_threat(slug)
|
|
94
|
+
get("/api/v1/rest/threats/#{slug}/")
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
private
|
|
98
|
+
|
|
99
|
+
def get(path, **params)
|
|
100
|
+
uri = URI.join(@base_url, path)
|
|
101
|
+
uri.query = URI.encode_www_form(params) unless params.empty?
|
|
102
|
+
response = Net::HTTP.get_response(uri)
|
|
103
|
+
raise "HTTP #{response.code}" unless response.is_a?(Net::HTTPSuccess)
|
|
104
|
+
JSON.parse(response.body)
|
|
105
|
+
end
|
|
106
|
+
end
|
|
107
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: ipfyi
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- FYIPedia
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2026-03-21 00:00:00.000000000 Z
|
|
12
|
+
dependencies: []
|
|
13
|
+
description: Ruby client for the IPFYI REST API at ipfyi.com. Zero external dependencies.
|
|
14
|
+
email: dev@fyipedia.com
|
|
15
|
+
executables: []
|
|
16
|
+
extensions: []
|
|
17
|
+
extra_rdoc_files: []
|
|
18
|
+
files:
|
|
19
|
+
- lib/ipfyi.rb
|
|
20
|
+
homepage: https://ipfyi.com
|
|
21
|
+
licenses:
|
|
22
|
+
- MIT
|
|
23
|
+
metadata:
|
|
24
|
+
source_code_uri: https://github.com/fyipedia/ipfyi-rb
|
|
25
|
+
documentation_uri: https://ipfyi.com/api/v1/schema/
|
|
26
|
+
homepage_uri: https://ipfyi.com
|
|
27
|
+
post_install_message:
|
|
28
|
+
rdoc_options: []
|
|
29
|
+
require_paths:
|
|
30
|
+
- lib
|
|
31
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
32
|
+
requirements:
|
|
33
|
+
- - ">="
|
|
34
|
+
- !ruby/object:Gem::Version
|
|
35
|
+
version: '3.0'
|
|
36
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - ">="
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '0'
|
|
41
|
+
requirements: []
|
|
42
|
+
rubygems_version: 3.0.3.1
|
|
43
|
+
signing_key:
|
|
44
|
+
specification_version: 4
|
|
45
|
+
summary: Ruby client for IPFYI API
|
|
46
|
+
test_files: []
|