timefyi 0.1.0 → 0.1.1
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/lib/timefyi/client.rb +48 -0
- data/lib/timefyi/version.rb +5 -0
- data/lib/timefyi.rb +2 -78
- metadata +13 -7
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 965d5d6a519e7a1ce650841cb6951b737fa7ed76721f7fc2115cc4672bd3e5e7
|
|
4
|
+
data.tar.gz: 4270def8c07f3cc4abb7b96be5ed24620759a40f0e7776c85af377c9c703d87c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 732966565a933ad7305358ea743206406b1e20f184f74d2b06b86829d6a214c33eca8981e70390a68fed87f57bd75d35f53403d05ccdcee701a68246f0c86932
|
|
7
|
+
data.tar.gz: b9f9a3942b0556fcdaee3254dd7aa99150968e80b293a0a1e0c863cf3d7863dc6c8b993732a838d68c2a744af39d216f44a8f7088bdd26997f12ba14bb8ef81e
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "net/http"
|
|
4
|
+
require "json"
|
|
5
|
+
require "uri"
|
|
6
|
+
|
|
7
|
+
module TimeFYI
|
|
8
|
+
class Client
|
|
9
|
+
DEFAULT_BASE_URL = "https://timefyi.com/api"
|
|
10
|
+
|
|
11
|
+
def initialize(base_url: DEFAULT_BASE_URL)
|
|
12
|
+
@base_url = base_url
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def search(query)
|
|
16
|
+
get("/search/", q: query)
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def entity(slug)
|
|
20
|
+
get("/city/#{slug}/")
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def glossary_term(slug)
|
|
24
|
+
get("/glossary/#{slug}/")
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def random
|
|
28
|
+
get("/random/")
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
private
|
|
32
|
+
|
|
33
|
+
def get(path, params = {})
|
|
34
|
+
uri = URI("#{@base_url}#{path}")
|
|
35
|
+
uri.query = URI.encode_www_form(params) unless params.empty?
|
|
36
|
+
|
|
37
|
+
response = Net::HTTP.get_response(uri)
|
|
38
|
+
|
|
39
|
+
unless response.is_a?(Net::HTTPSuccess)
|
|
40
|
+
raise Error, "HTTP #{response.code}: #{response.body}"
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
JSON.parse(response.body, symbolize_names: true)
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
class Error < StandardError; end
|
|
48
|
+
end
|
data/lib/timefyi.rb
CHANGED
|
@@ -1,80 +1,4 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
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
|
|
3
|
+
require_relative "timefyi/version"
|
|
4
|
+
require_relative "timefyi/client"
|
metadata
CHANGED
|
@@ -1,29 +1,35 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: timefyi
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- FYIPedia
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-03-
|
|
11
|
+
date: 2026-03-30 00:00:00.000000000 Z
|
|
12
12
|
dependencies: []
|
|
13
|
-
description:
|
|
14
|
-
|
|
13
|
+
description: API client for timefyi.com. Timezone operations, business hours, and
|
|
14
|
+
sunrise/sunset. Zero dependencies.
|
|
15
|
+
email:
|
|
16
|
+
- hello@fyipedia.com
|
|
15
17
|
executables: []
|
|
16
18
|
extensions: []
|
|
17
19
|
extra_rdoc_files: []
|
|
18
20
|
files:
|
|
19
21
|
- lib/timefyi.rb
|
|
22
|
+
- lib/timefyi/client.rb
|
|
23
|
+
- lib/timefyi/version.rb
|
|
20
24
|
homepage: https://timefyi.com
|
|
21
25
|
licenses:
|
|
22
26
|
- MIT
|
|
23
27
|
metadata:
|
|
24
|
-
source_code_uri: https://github.com/fyipedia/timefyi-rb
|
|
25
|
-
documentation_uri: https://timefyi.com/api/v1/schema/
|
|
26
28
|
homepage_uri: https://timefyi.com
|
|
29
|
+
source_code_uri: https://github.com/fyipedia/timefyi-rb
|
|
30
|
+
changelog_uri: https://github.com/fyipedia/timefyi-rb/blob/main/CHANGELOG.md
|
|
31
|
+
documentation_uri: https://timefyi.com/developers/
|
|
32
|
+
bug_tracker_uri: https://github.com/fyipedia/timefyi-rb/issues
|
|
27
33
|
post_install_message:
|
|
28
34
|
rdoc_options: []
|
|
29
35
|
require_paths:
|
|
@@ -42,5 +48,5 @@ requirements: []
|
|
|
42
48
|
rubygems_version: 3.0.3.1
|
|
43
49
|
signing_key:
|
|
44
50
|
specification_version: 4
|
|
45
|
-
summary:
|
|
51
|
+
summary: Timezone operations, business hours, and sunrise/sunset
|
|
46
52
|
test_files: []
|