Skip to content

Commit dcee4e8

Browse files
authored
Merge pull request #8 from MrGeneration/mh/maintenance
Enable rubocop; Bump version; Bump dependencies; Fix rubocop
2 parents 4df2b36 + 47a405b commit dcee4e8

File tree

6 files changed

+44
-38
lines changed

6 files changed

+44
-38
lines changed

.rubocop.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
AllCops:
2+
TargetRubyVersion: 3.0

Gemfile.lock

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
GEM
22
remote: https://rubygems.org/
33
specs:
4-
addressable (2.8.0)
5-
public_suffix (>= 2.0.2, < 5.0)
6-
json (2.3.0)
7-
public_suffix (4.0.6)
8-
rotp (5.1.0)
9-
addressable (~> 2.5)
10-
xmlrpc (0.3.0)
4+
json (2.6.3)
5+
rotp (6.2.2)
6+
webrick (1.8.1)
7+
xmlrpc (0.3.2)
8+
webrick
119

1210
PLATFORMS
1311
ruby
@@ -18,4 +16,4 @@ DEPENDENCIES
1816
xmlrpc
1917

2018
BUNDLED WITH
21-
1.16.1
19+
2.3.17

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ domrobot = INWX::Domrobot.new
3838
result = domrobot.set_language('en').
3939
use_ote.
4040
use_json.
41-
set_debug(true).
41+
show_debug(true).
4242
login(user, pass)
4343

4444
object = 'domain'

example.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@
2020
# or use the XML-RPC API instead
2121
# use_xml.
2222
# output everything you're sending and receiving in JSON pretty print
23-
set_debug(true).
24-
# optional 3rd parameter available: shared_secret for 2 factor auth
25-
login(user, pass)
23+
show_debug(true).
24+
# optional parameter: shared_secret for 2 factor auth (Base32 secret key)
25+
login(username: user, password: pass)
2626

2727
object = 'domain'
2828
method = 'check'

inwx-domrobot.gemspec

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
1+
# frozen_string_literal: true
2+
13
Gem::Specification.new do |s|
2-
s.name = 'inwx-domrobot'
3-
s.version = '3.1'
4-
s.date = '2019-09-12'
5-
s.summary = "INWX Domrobot"
6-
s.description = "Ruby Client to easily use the Domrobot API of INWX"
7-
s.authors = ["INWX"]
8-
s.email = 'support@inwx.de'
9-
s.files = ["lib/inwx-domrobot.rb"]
10-
s.homepage = 'https://rubygems.org/gems/inwx-domrobot'
11-
s.add_runtime_dependency 'json', '~> 2.1', '>= 2.1.0'
12-
s.add_runtime_dependency 'xmlrpc', '~> 0.3', '>= 0.3.0'
13-
s.add_runtime_dependency 'rotp', '~> 5.1', '>= 5.1.0'
14-
s.license = 'MIT'
15-
end
4+
s.name = 'inwx-domrobot'
5+
s.version = '4.0'
6+
s.date = '2023-05-01'
7+
s.summary = 'INWX Domrobot'
8+
s.description = 'Ruby Client to easily use the Domrobot API of INWX'
9+
s.authors = ['INWX']
10+
s.email = 'support@inwx.de'
11+
s.files = ['lib/inwx_domrobot.rb']
12+
s.homepage = 'https://rubygems.org/gems/inwx-domrobot'
13+
s.required_ruby_version = '>= 3.0.0'
14+
s.license = 'MIT'
15+
16+
s.add_runtime_dependency 'json', '~> 2.6.3', '>= 2.6.0'
17+
s.add_runtime_dependency 'rotp', '~> 6.2.2', '>= 6.2.0'
18+
s.add_runtime_dependency 'xmlrpc', '~> 0.3.2', '>= 0.3.0'
19+
end
Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@
77
require 'rotp'
88

99
module INWX
10+
# Domain Robot class
1011
class Domrobot
1112
attr_accessor :client, :cookie, :language, :api_type, :url, :debug
13+
1214
URL_LIVE = 'api.domrobot.com'
1315
URL_OTE = 'api.ote.domrobot.com'
1416
TYPE_JSON = '/jsonrpc/'
@@ -47,7 +49,7 @@ def use_xml
4749
self
4850
end
4951

50-
def set_debug(value)
52+
def show_debug(value)
5153
self.debug = value
5254
self
5355
end
@@ -61,7 +63,7 @@ def create_client
6163
end
6264
end
6365

64-
def login(username = false, password = false, shared_secret = nil)
66+
def login(username: false, password: false, shared_secret: nil)
6567
create_client
6668

6769
params = { user: username, pass: password, lang: language }
@@ -89,10 +91,10 @@ def call(object, method, params = {})
8991

9092
def call_xml(object, method, params = {})
9193
client.cookie = cookie
92-
res = client.call(object + '.' + method, params)
94+
res = client.call("#{object}.#{method}", params)
9395

9496
save_cookie(client.cookie)
95-
debug_sent = { method: object + '.' + method, params: params }
97+
debug_sent = { method: "#{object}.#{method}", params: params }
9698
output_debug(debug_sent.to_json, res.to_json)
9799

98100
res
@@ -101,7 +103,7 @@ def call_xml(object, method, params = {})
101103
def call_json(object, method, params = {})
102104
req = Net::HTTP::Post.new(api_type)
103105

104-
json_params = { method: object + '.' + method, params: params }
106+
json_params = { method: "#{object}.#{method}", params: params }
105107

106108
req.body = json_params.to_json
107109
req['Cookie'] = cookie
@@ -118,13 +120,13 @@ def save_cookie(cookie)
118120
end
119121

120122
def output_debug(sent, received)
121-
if debug
122-
puts 'Sent:'
123-
puts JSON.pretty_generate(JSON.parse(sent))
124-
puts 'Received:'
125-
puts JSON.pretty_generate(JSON.parse(received))
126-
puts '-------------------------'
127-
end
123+
return unless debug
124+
125+
puts 'Sent:'
126+
puts JSON.pretty_generate(JSON.parse(sent))
127+
puts 'Received:'
128+
puts JSON.pretty_generate(JSON.parse(received))
129+
puts '-------------------------'
128130
end
129131

130132
def get_secret_code(shared_secret)

0 commit comments

Comments
 (0)