festivo 0.2.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/festivo.rb +50 -0
- metadata +73 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 2d64465f8b6b3a00a7bc7f37b82673be3cea67958cb129d1980ac51b6d002c93
|
|
4
|
+
data.tar.gz: 973bed4ce9e6627723c42518fbded154748726cd869c53e83effd497f992810c
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 7327323c9ef532b4e0feae948ce489af7d4da2fc62a5e6fede4458a79e2e8a79d46b68bca93db6c6eb5e4f470c5382d72b53d4981384cdeae034b0000e65bf88
|
|
7
|
+
data.tar.gz: 64235ddbd599d34526bbc0f9487988c4bca4b4da0f5bdf9362c577168cd420a4f789eb8f0dfa0f8c66399765994da8e418db481d36e64167b3b0dc6192bc938b
|
data/lib/festivo.rb
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
require 'net/http'
|
|
2
|
+
require 'uri'
|
|
3
|
+
require 'json'
|
|
4
|
+
|
|
5
|
+
module Festivo
|
|
6
|
+
class Client
|
|
7
|
+
attr_accessor :api_key, :base_url
|
|
8
|
+
|
|
9
|
+
def initialize(api_key = nil, base_url = 'https://api.getfestivo.com')
|
|
10
|
+
@api_key = api_key
|
|
11
|
+
@base_url = base_url
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def get_holidays(country, year, regions: nil, type: nil, language: nil, timezone: nil)
|
|
15
|
+
params = { country: country, year: year }
|
|
16
|
+
params[:regions] = regions if regions
|
|
17
|
+
params[:type] = type if type
|
|
18
|
+
params[:language] = language if language
|
|
19
|
+
params[:timezone] = timezone if timezone
|
|
20
|
+
request('/v3/public-holidays/list', params)
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def get_city_holidays(country, city_code, year, type: nil, language: nil, timezone: nil)
|
|
24
|
+
get_holidays(country, year, regions: city_code, type: type, language: language, timezone: timezone)
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def get_regional_holidays(country, region_code, year, type: nil, language: nil, timezone: nil)
|
|
28
|
+
get_holidays(country, year, regions: region_code, type: type, language: language, timezone: timezone)
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def check_holiday(country, date, regions: nil)
|
|
32
|
+
params = { country: country, date: date }
|
|
33
|
+
params[:regions] = regions if regions
|
|
34
|
+
request('/v3/public-holidays/check', params)
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
private
|
|
38
|
+
|
|
39
|
+
def request(path, params = {})
|
|
40
|
+
uri = URI.join(@base_url, path)
|
|
41
|
+
uri.query = URI.encode_www_form(params)
|
|
42
|
+
req = Net::HTTP::Get.new(uri)
|
|
43
|
+
req['Accept'] = 'application/json'
|
|
44
|
+
req['Authorization'] = "Bearer #{@api_key}" if @api_key
|
|
45
|
+
res = Net::HTTP.start(uri.hostname, uri.port, use_ssl: uri.scheme == 'https') { |http| http.request(req) }
|
|
46
|
+
raise "Festivo API error: #{res.code} #{res.message}" unless res.is_a?(Net::HTTPSuccess)
|
|
47
|
+
JSON.parse(res.body)
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: festivo
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.2.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Festivo Team
|
|
8
|
+
bindir: bin
|
|
9
|
+
cert_chain: []
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
|
+
dependencies:
|
|
12
|
+
- !ruby/object:Gem::Dependency
|
|
13
|
+
name: net-http
|
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
|
15
|
+
requirements:
|
|
16
|
+
- - ">="
|
|
17
|
+
- !ruby/object:Gem::Version
|
|
18
|
+
version: '0'
|
|
19
|
+
type: :runtime
|
|
20
|
+
prerelease: false
|
|
21
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
22
|
+
requirements:
|
|
23
|
+
- - ">="
|
|
24
|
+
- !ruby/object:Gem::Version
|
|
25
|
+
version: '0'
|
|
26
|
+
- !ruby/object:Gem::Dependency
|
|
27
|
+
name: json
|
|
28
|
+
requirement: !ruby/object:Gem::Requirement
|
|
29
|
+
requirements:
|
|
30
|
+
- - ">="
|
|
31
|
+
- !ruby/object:Gem::Version
|
|
32
|
+
version: '0'
|
|
33
|
+
type: :runtime
|
|
34
|
+
prerelease: false
|
|
35
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
36
|
+
requirements:
|
|
37
|
+
- - ">="
|
|
38
|
+
- !ruby/object:Gem::Version
|
|
39
|
+
version: '0'
|
|
40
|
+
description: Official Ruby SDK for Festivo Public Holidays API. Access city-level,
|
|
41
|
+
regional, and global holiday data.
|
|
42
|
+
email:
|
|
43
|
+
- support@getfestivo.com
|
|
44
|
+
executables: []
|
|
45
|
+
extensions: []
|
|
46
|
+
extra_rdoc_files: []
|
|
47
|
+
files:
|
|
48
|
+
- lib/festivo.rb
|
|
49
|
+
homepage: https://getfestivo.com
|
|
50
|
+
licenses:
|
|
51
|
+
- MIT
|
|
52
|
+
metadata:
|
|
53
|
+
homepage_uri: https://getfestivo.com
|
|
54
|
+
source_code_uri: https://github.com/festivo-io/festivo-sdk
|
|
55
|
+
documentation_uri: https://getfestivo.com/docs
|
|
56
|
+
rdoc_options: []
|
|
57
|
+
require_paths:
|
|
58
|
+
- lib
|
|
59
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
60
|
+
requirements:
|
|
61
|
+
- - ">="
|
|
62
|
+
- !ruby/object:Gem::Version
|
|
63
|
+
version: '0'
|
|
64
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
65
|
+
requirements:
|
|
66
|
+
- - ">="
|
|
67
|
+
- !ruby/object:Gem::Version
|
|
68
|
+
version: '0'
|
|
69
|
+
requirements: []
|
|
70
|
+
rubygems_version: 3.6.9
|
|
71
|
+
specification_version: 4
|
|
72
|
+
summary: Festivo Public Holidays API Ruby SDK
|
|
73
|
+
test_files: []
|