short_io 0.1.9 → 0.1.10
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 +19 -10
- data/Gemfile.lock +1 -1
- data/README.md +1 -1
- data/lib/short_io/short_url.rb +93 -10
- data/lib/short_io/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b501e26aa3a32c19f90bb55620f0a7ec11603a861676eefa40d6f412448085d2
|
4
|
+
data.tar.gz: a72bb745a6f65bca47290fee7d783ae24ed44de296dce5492da3e5e6e734fbe9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 357d0b28e2f88b5e035865bd748bbc832cb3a34bb609e74c346e2f862164a56a6bf4d5a0860ece3c49a12746b9833657852f35376a378a0cba83232ed11a5f77
|
7
|
+
data.tar.gz: 97ba7f73234f850b3e219233121b33f3b3a14804b0732fc177884fe622628558b79fce2e96a63cf2881c063d17e7ffb564624ce5218fbc03a91c7088ec62e3d4
|
data/CHANGELOG.md
CHANGED
@@ -1,10 +1,19 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.10 (2022-02-10)
|
2
|
+
------------------
|
3
|
+
|
4
|
+
* add delete and update method
|
5
|
+
* initialize using four (4) parameters
|
6
|
+
* setup method using two (2) default parameters
|
7
|
+
* add documentation for domain_list, update, and delete
|
8
|
+
* update version to [0.1.10](https://rubygems.org/gems/short_io/versions/0.1.10)
|
9
|
+
|
10
|
+
0.1.9 (2022-02-03)
|
2
11
|
------------------
|
3
12
|
|
4
13
|
* add documentation
|
5
14
|
* update version to [0.1.9](https://rubygems.org/gems/short_io/versions/0.1.9)
|
6
15
|
|
7
|
-
0.1.8 (
|
16
|
+
0.1.8 (2022-02-03)
|
8
17
|
------------------
|
9
18
|
|
10
19
|
* add webmock gem
|
@@ -12,7 +21,7 @@
|
|
12
21
|
* add `:host_name`, `:api_key`, and `:options` attr_reader
|
13
22
|
* update version to [0.1.8](https://rubygems.org/gems/short_io/versions/0.1.8)
|
14
23
|
|
15
|
-
0.1.7 (
|
24
|
+
0.1.7 (2022-01-25)
|
16
25
|
------------------
|
17
26
|
|
18
27
|
* add test
|
@@ -20,42 +29,42 @@
|
|
20
29
|
* add check_variables method to raise error when `nil` or `empty` on host name or api_key
|
21
30
|
* update version to [0.1.7](https://rubygems.org/gems/short_io/versions/0.1.7)
|
22
31
|
|
23
|
-
0.1.6 (
|
32
|
+
0.1.6 (2022-01-25)
|
24
33
|
------------------
|
25
34
|
|
26
35
|
* fix version on CHANGELOG.md
|
27
36
|
* update version to [0.1.6](https://rubygems.org/gems/short_io/versions/0.1.6)
|
28
37
|
|
29
|
-
0.1.5 (
|
38
|
+
0.1.5 (2022-01-25)
|
30
39
|
------------------
|
31
40
|
|
32
41
|
* fix CHANGELOG.md path
|
33
42
|
* update version to [0.1.5](https://rubygems.org/gems/short_io/versions/0.1.5)
|
34
43
|
|
35
|
-
0.1.4 (
|
44
|
+
0.1.4 (2022-01-25)
|
36
45
|
------------------
|
37
46
|
|
38
47
|
* add CHANGELOG.md
|
39
48
|
* update version to [0.1.4](https://rubygems.org/gems/short_io/versions/0.1.4)
|
40
49
|
|
41
|
-
0.1.3 (
|
50
|
+
0.1.3 (2022-01-25)
|
42
51
|
------------------
|
43
52
|
|
44
53
|
* add Gemfile.lock
|
45
54
|
* update version to [0.1.3](https://rubygems.org/gems/short_io/versions/0.1.3)
|
46
55
|
|
47
|
-
0.1.2 (
|
56
|
+
0.1.2 (2022-01-25)
|
48
57
|
------------------
|
49
58
|
|
50
59
|
* fix sample usage on README.md
|
51
60
|
* update version to [0.1.2](https://rubygems.org/gems/short_io/versions/0.1.2)
|
52
61
|
|
53
|
-
0.1.1 (
|
62
|
+
0.1.1 (2022-01-25)
|
54
63
|
------------------
|
55
64
|
|
56
65
|
* update version to [0.1.1](https://rubygems.org/gems/short_io/versions/0.1.1) (no changes)
|
57
66
|
|
58
|
-
0.1.0 (
|
67
|
+
0.1.0 (2022-01-25)
|
59
68
|
------------------
|
60
69
|
|
61
70
|
* [YANKED](https://rubygems.org/gems/short_io/versions/0.1.0) Start create `short_io` gem
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
data/lib/short_io/short_url.rb
CHANGED
@@ -7,18 +7,21 @@ require 'json'
|
|
7
7
|
module ShortIo
|
8
8
|
# Add domain and list domains registerd to Short.io
|
9
9
|
class ShortUrl
|
10
|
-
REQUEST_TYPE
|
11
|
-
SHORT_IO_BASE_URL
|
10
|
+
REQUEST_TYPE = 'application/json'
|
11
|
+
SHORT_IO_BASE_URL = 'https://api.short.io/domains/'
|
12
|
+
SHORT_IO_API_BASE_URL = 'https://api.short.io/api/domains'
|
12
13
|
|
13
14
|
attr_reader :host_name, :api_key, :options
|
14
15
|
|
15
|
-
def initialize(host_name, api_key, options={})
|
16
|
+
def initialize(host_name, api_key, short_io_base_url=SHORT_IO_BASE_URL, options={})
|
16
17
|
@host_name ||= host_name
|
17
18
|
@api_key ||= api_key
|
18
|
-
@short_io_base_url ||=
|
19
|
+
@short_io_base_url ||= short_io_base_url
|
19
20
|
@options ||= options
|
20
|
-
|
21
|
-
|
21
|
+
unless options.key?(:domain_id)
|
22
|
+
options_default_value
|
23
|
+
check_variables
|
24
|
+
end
|
22
25
|
end
|
23
26
|
|
24
27
|
# Options Default Value
|
@@ -45,8 +48,8 @@ module ShortIo
|
|
45
48
|
|
46
49
|
# Prepare request
|
47
50
|
|
48
|
-
def setup
|
49
|
-
@url = URI(
|
51
|
+
def setup(action=nil, base_url=SHORT_IO_BASE_URL)
|
52
|
+
@url = action.nil? ? URI(base_url) : URI(base_url + action)
|
50
53
|
@http = Net::HTTP.new(@url.host, @url.port)
|
51
54
|
@http.use_ssl = true
|
52
55
|
@http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
@@ -95,17 +98,97 @@ module ShortIo
|
|
95
98
|
return response.read_body
|
96
99
|
end
|
97
100
|
|
101
|
+
# Delete a domain
|
102
|
+
#
|
103
|
+
# @return [JSON] return in JSON format.
|
104
|
+
#
|
105
|
+
# @example
|
106
|
+
# ShortIo::ShortUrl.new('example.com', 'YOUR_API_KEY', {domain_id: YOUR_DOMAIN_ID}).delete_domain
|
107
|
+
# response:
|
108
|
+
# {
|
109
|
+
# success: true
|
110
|
+
# }
|
111
|
+
#
|
112
|
+
# @see https://developers.short.io/docs/deleting-a-domain
|
113
|
+
|
114
|
+
def delete_domain
|
115
|
+
setup("delete/#{@options[:domain_id]}")
|
116
|
+
|
117
|
+
request = Net::HTTP::Post.new(@url)
|
118
|
+
request["authorization"] = @api_key
|
119
|
+
|
120
|
+
response = @http.request(request)
|
121
|
+
return response.read_body
|
122
|
+
end
|
123
|
+
|
124
|
+
# Udpadating a domain
|
125
|
+
#
|
126
|
+
# @return [JSON] return in JSON format.
|
127
|
+
#
|
128
|
+
# @example
|
129
|
+
# ShortIo::ShortUrl.new('example.com', 'YOUR_API_KEY', {domain_id: YOUR_DOMAIN_ID, root_redirect_url: 'YOUR_LINK'}).update_domain
|
130
|
+
# response:
|
131
|
+
# {
|
132
|
+
# success: true
|
133
|
+
# }
|
134
|
+
#
|
135
|
+
# @see https://developers.short.io/docs/updating-a-domain
|
136
|
+
|
137
|
+
def update_domain
|
138
|
+
setup("settings/#{@options[:domain_id]}")
|
139
|
+
|
140
|
+
request = Net::HTTP::Post.new(@url)
|
141
|
+
request["accept"] = REQUEST_TYPE
|
142
|
+
request["content-type"] = REQUEST_TYPE
|
143
|
+
request["authorization"] = @api_key
|
144
|
+
request.body = JSON.generate({ 'rootRedirect': "#{@options[:root_redirect_url]}" })
|
145
|
+
|
146
|
+
response = @http.request(request)
|
147
|
+
return response.read_body
|
148
|
+
end
|
149
|
+
|
98
150
|
# Domain List
|
99
151
|
#
|
100
152
|
# @return [JSON] return domain list in JSON format.
|
101
153
|
#
|
154
|
+
# @example
|
155
|
+
# ShortIo::ShortUrl.new('example.com', 'YOUR_API_KEY').domain_list
|
156
|
+
# response:
|
157
|
+
# {
|
158
|
+
# id: 7252,
|
159
|
+
# hostname: 'yrbrand.co',
|
160
|
+
# title: null,
|
161
|
+
# segmentKey: null,
|
162
|
+
# linkType: 'increment',
|
163
|
+
# state: 'not_configured',
|
164
|
+
# provider: 'cloudflare',
|
165
|
+
# redirect404: 'https://short.cm',
|
166
|
+
# hideReferer: 1,
|
167
|
+
# caseSensitive: true,
|
168
|
+
# exportEnabled: true,
|
169
|
+
# cloaking: false,
|
170
|
+
# jsRedir: true,
|
171
|
+
# incrementCounter: 'A',
|
172
|
+
# setupType: 'js',
|
173
|
+
# autodeletePeriod: 1,
|
174
|
+
# httpsLinks: true,
|
175
|
+
# clientStorage: '{"configurationHidden":false}',
|
176
|
+
# integrationGA: null,
|
177
|
+
# integrationFB: null,
|
178
|
+
# integrationAdroll: null,
|
179
|
+
# integrationGTM: null,
|
180
|
+
# createdAt: '2017-12-07T08:24:41.000Z',
|
181
|
+
# updatedAt: '2019-12-24T13:08:30.000Z',
|
182
|
+
# TeamId: 1381,
|
183
|
+
# unicodeHostname: 'yrbrand.co'
|
184
|
+
# }
|
185
|
+
#
|
102
186
|
# @see https://developers.short.io/docs/getting-a-list-of-domains
|
103
187
|
|
104
188
|
def domain_list
|
105
|
-
setup
|
189
|
+
setup(nil, SHORT_IO_API_BASE_URL)
|
106
190
|
request = Net::HTTP::Get.new(@url)
|
107
191
|
request["accept"] = REQUEST_TYPE
|
108
|
-
request["content-type"] = REQUEST_TYPE
|
109
192
|
request["authorization"] = @api_key
|
110
193
|
|
111
194
|
response = @http.request(request)
|
data/lib/short_io/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: short_io
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yosef Benny Widyokarsono
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-02-
|
11
|
+
date: 2022-02-10 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description:
|
14
14
|
email:
|