timefyi 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/timefyi.rb +80 -0
- metadata +46 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 103bbbb42512645775c4db8c0e1d4fdcd3f8423f0dfe46078d6ba932f9d0db02
|
|
4
|
+
data.tar.gz: f4a47043124a1ee012d5e458d699d37456e22086742ef408ea5ea35bb551c1d7
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 1bd77c2c84f4304d21d94c2b00660d14b45362739df437dcbb8348f9743ebff7886dda4421b834390d92017ed691eadfb5376cd622465247896dc7f76d89353a
|
|
7
|
+
data.tar.gz: b0c74360b2643b520fb9e0843349579b6b380f4ea2fb8027c1851ad21d3cda5ca7ad4d9f1a59ab4d1111c5794b0515e3498cbe81b58e1a85e54620944a062fb1
|
data/lib/timefyi.rb
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "net/http"
|
|
4
|
+
require "json"
|
|
5
|
+
require "uri"
|
|
6
|
+
|
|
7
|
+
# Ruby client for TimeFYI REST API (timefyi.com).
|
|
8
|
+
#
|
|
9
|
+
# client = TimeFYI::Client.new
|
|
10
|
+
# result = client.search("query")
|
|
11
|
+
#
|
|
12
|
+
module TimeFYI
|
|
13
|
+
class Client
|
|
14
|
+
BASE_URL = "https://timefyi.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/search/", q: query)
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
# List all cities.
|
|
25
|
+
def list_cities
|
|
26
|
+
get("/api/v1/cities/")
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
# Get city by slug.
|
|
30
|
+
def get_city(slug)
|
|
31
|
+
get("/api/v1/cities/#{slug}/")
|
|
32
|
+
end
|
|
33
|
+
# List all countries.
|
|
34
|
+
def list_countries
|
|
35
|
+
get("/api/v1/countries/")
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
# Get country by slug.
|
|
39
|
+
def get_country(slug)
|
|
40
|
+
get("/api/v1/countries/#{slug}/")
|
|
41
|
+
end
|
|
42
|
+
# List all faqs.
|
|
43
|
+
def list_faqs
|
|
44
|
+
get("/api/v1/faqs/")
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
# Get faq by slug.
|
|
48
|
+
def get_faq(slug)
|
|
49
|
+
get("/api/v1/faqs/#{slug}/")
|
|
50
|
+
end
|
|
51
|
+
# List all glossary.
|
|
52
|
+
def list_glossary
|
|
53
|
+
get("/api/v1/glossary/")
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
# Get term by slug.
|
|
57
|
+
def get_term(slug)
|
|
58
|
+
get("/api/v1/glossary/#{slug}/")
|
|
59
|
+
end
|
|
60
|
+
# List all guides.
|
|
61
|
+
def list_guides
|
|
62
|
+
get("/api/v1/guides/")
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
# Get guide by slug.
|
|
66
|
+
def get_guide(slug)
|
|
67
|
+
get("/api/v1/guides/#{slug}/")
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
private
|
|
71
|
+
|
|
72
|
+
def get(path, **params)
|
|
73
|
+
uri = URI.join(@base_url, path)
|
|
74
|
+
uri.query = URI.encode_www_form(params) unless params.empty?
|
|
75
|
+
response = Net::HTTP.get_response(uri)
|
|
76
|
+
raise "HTTP #{response.code}" unless response.is_a?(Net::HTTPSuccess)
|
|
77
|
+
JSON.parse(response.body)
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: timefyi
|
|
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 TimeFYI REST API at timefyi.com. Zero external dependencies.
|
|
14
|
+
email: dev@fyipedia.com
|
|
15
|
+
executables: []
|
|
16
|
+
extensions: []
|
|
17
|
+
extra_rdoc_files: []
|
|
18
|
+
files:
|
|
19
|
+
- lib/timefyi.rb
|
|
20
|
+
homepage: https://timefyi.com
|
|
21
|
+
licenses:
|
|
22
|
+
- MIT
|
|
23
|
+
metadata:
|
|
24
|
+
source_code_uri: https://github.com/fyipedia/timefyi-rb
|
|
25
|
+
documentation_uri: https://timefyi.com/api/v1/schema/
|
|
26
|
+
homepage_uri: https://timefyi.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 TimeFYI API
|
|
46
|
+
test_files: []
|