short_io 0.1.8 → 0.1.9
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/CHANGELOG.md +6 -0
- data/Gemfile.lock +1 -1
- data/lib/short_io/short_url.rb +43 -0
- data/lib/short_io/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d35d4b4870871ee21159f3e60963f1ae02af40dccdb9bc0ee518a65593c2b190
|
4
|
+
data.tar.gz: f7ed37b624cebc677b3139356007818c1c654972ea0f49b83be553c6fe660736
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fc8411a577139d9341cbe90b536ce6d042da4c36621f029d2a4c4588a5406ec8c9c1d4f9e87e73dfd426d7ceeff18640f5233a07451625db73219fce3f82bd13
|
7
|
+
data.tar.gz: a4bd6d18d129e60ac8f9e50f9244e1c883d1ca411bbbd9217cc4fbbacd8ef4e50ba6def774fb3c9ff9a16a7b929cb9fe5a137e236947b9af9976cf01b2b6ba7b
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
data/lib/short_io/short_url.rb
CHANGED
@@ -3,7 +3,9 @@ require 'net/http'
|
|
3
3
|
require 'openssl'
|
4
4
|
require 'json'
|
5
5
|
|
6
|
+
# @author Yosef Benny Widyokarsono
|
6
7
|
module ShortIo
|
8
|
+
# Add domain and list domains registerd to Short.io
|
7
9
|
class ShortUrl
|
8
10
|
REQUEST_TYPE = 'application/json'
|
9
11
|
SHORT_IO_BASE_URL = 'https://api.short.io/domains/'
|
@@ -19,6 +21,10 @@ module ShortIo
|
|
19
21
|
check_variables
|
20
22
|
end
|
21
23
|
|
24
|
+
# Options Default Value
|
25
|
+
#
|
26
|
+
# @return [Hash] return default options in Hash if no value provided.
|
27
|
+
|
22
28
|
def options_default_value
|
23
29
|
@options = {
|
24
30
|
hide_referer: options.key?(:hide_referer) ? options[:hide_referer] : false,
|
@@ -27,11 +33,18 @@ module ShortIo
|
|
27
33
|
}
|
28
34
|
end
|
29
35
|
|
36
|
+
# Check Variables
|
37
|
+
#
|
38
|
+
# @raise [HostNameError] if no Host Name provided.
|
39
|
+
# @raise [ApiKeyError] if no API Key provided.
|
40
|
+
|
30
41
|
def check_variables
|
31
42
|
raise ShortIo::HostNameError.new(host_name: 'Please provide a host name') if (@host_name.nil? || @host_name.empty?)
|
32
43
|
raise ShortIo::ApiKeyError.new(api_key: 'Please provide an API key') if (@api_key.nil? || @api_key.empty?)
|
33
44
|
end
|
34
45
|
|
46
|
+
# Prepare request
|
47
|
+
|
35
48
|
def setup
|
36
49
|
@url = URI(SHORT_IO_BASE_URL)
|
37
50
|
@http = Net::HTTP.new(@url.host, @url.port)
|
@@ -39,6 +52,30 @@ module ShortIo
|
|
39
52
|
@http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
40
53
|
end
|
41
54
|
|
55
|
+
# Add new domain
|
56
|
+
#
|
57
|
+
# @return [JSON] return in JSON format.
|
58
|
+
#
|
59
|
+
# @example
|
60
|
+
# ShortIo::ShortUrl.new('example.com', 'YOUR_API_KEY').add_domain
|
61
|
+
# {
|
62
|
+
# linkType: 'random',
|
63
|
+
# state: 'configured',
|
64
|
+
# cloaking: false,
|
65
|
+
# setupType: 'dns',
|
66
|
+
# httpsLinks: false,
|
67
|
+
# id: 91576,
|
68
|
+
# hostname: 'yourdomain.com',
|
69
|
+
# UserId: 9346,
|
70
|
+
# updatedAt: '2022-02-03T10:22:47.010Z',
|
71
|
+
# createdAt: '2022-02-03T10:22:46.649Z',
|
72
|
+
# provider: null,
|
73
|
+
# unicodeHostname: 'urdomain.com',
|
74
|
+
# clientStorage: null
|
75
|
+
# }
|
76
|
+
#
|
77
|
+
# @see https://developers.short.io/docs/adding-a-domain
|
78
|
+
|
42
79
|
def add_domain
|
43
80
|
setup
|
44
81
|
|
@@ -57,6 +94,12 @@ module ShortIo
|
|
57
94
|
response = @http.request(request)
|
58
95
|
return response.read_body
|
59
96
|
end
|
97
|
+
|
98
|
+
# Domain List
|
99
|
+
#
|
100
|
+
# @return [JSON] return domain list in JSON format.
|
101
|
+
#
|
102
|
+
# @see https://developers.short.io/docs/getting-a-list-of-domains
|
60
103
|
|
61
104
|
def domain_list
|
62
105
|
setup
|
data/lib/short_io/version.rb
CHANGED