module RegApi2

Provides r/w settings for API connection:

Provides shortcuts for API categories:

Provides dump hooks:

Please read {file:README.md} for API overview.

@example List of services by specified identifiers

RegApi2.service.nop(services: [
  { dname:"test.ru" },
  { dname: "test.su", servtype: "srv_hosting_ispmgr" },
  { service_id: 111111 },
  { service_id: "22bug22" },
  { surprise: "surprise.ru" }
])

@example Dump incoming API responses to ‘$stderr`

RegApi2.dump_responses :stderr

Constants

VERSION

Gem version.

Attributes

ca_cert_path[RW]

@!attribute [rw] ca_cert_path @return [String] Path to certification authority certificate (nil by default).

dump_requests_to[RW]

@!attribute [rw] dump_requests_to @return [String,Symbol,Lambda] Where to dump outgoing API request (nil by default).

| Value | Dump to |
| ----- | ------- |
| nil | Nothing |
| :stdout, "stdout" | $stdout |
| :stderr, "stderr" | $stderr |
| lambda | Calls this lambda with requested path and form hash |
dump_responses_to[RW]

@!attribute [rw] dump_responses_to @return [String,Symbol,Lambda] Where to dump incoming API response (nil by default).

| Value | Dump to |
| ----- | ------- |
| nil | Nothing |
| :stdout, "stdout" | $stdout |
| :stderr, "stderr" | $stderr |
| lambda | Calls this lambda with incoming parsed JSON data |
io_encoding[RW]

@!attribute [rw] io_encoding @return [String] IO encoding (‘utf-8` by default).

lang[RW]

@!attribute [rw] lang @return [String] Language (‘en` by default).

password[RW]

@!attribute [rw] password @return [String] Password (‘test` by default).

pem[RW]

@!attribute [rw] pem @return [String] X.509 certificate (nil by default).

pem_password[RW]

@!attribute [rw] pem_password @return [String] X.509 certificate password (nil by default).

username[RW]

@!attribute [rw] username @return [String] User name (‘test` by default).

Public Class Methods

bill() click to toggle source

Shortcut for {RegApi2::Bill} methods. @return [Module] {RegApi2::Bill} @api Shortcuts

# File lib/reg_api2.rb, line 91
def bill; RegApi2::Bill; end
common() click to toggle source

Shortcut for {RegApi2::Common} methods @return [Module] {RegApi2::Common} @api Shortcuts

# File lib/reg_api2.rb, line 67
def common; RegApi2::Common; end
domain() click to toggle source

Shortcut for {RegApi2::Domain} methods. @return [Module] {RegApi2::Domain} @api Shortcuts

# File lib/reg_api2.rb, line 73
def domain; RegApi2::Domain; end
dump_requests(to = nil, &code_block) click to toggle source

Dumps outgoing API requests to given ‘to` or code block. @param [String,Symbol,Lambda] to Where to dump incoming API response (nil by default).

| Value | Dump to |
| ----- | ------- |
| nil | Nothing |
| :stdout, "stdout" | $stdout |
| :stderr, "stderr" | $stderr |
| lambda | Calls this lambda with requested path and form hash |

@param [Code] code_block Code block to be executed on every API request. @yield [path, form] Request path and form to be sent. @return [NilClass] nil @example Dump outgoing API requests to code block

RegApi2.dump_requests { |path, form| p path; p form }
# File lib/reg_api2/impl.rb, line 65
def dump_requests(to = nil, &code_block)
  if to.nil? && block_given?
    to = code_block
  end
  self.dump_requests_to = to
  nil
end
dump_responses(to = nil, &code_block) click to toggle source

Dumps incoming API responses to given ‘to` or code block. @param [String,Symbol,Lambda] to Where to dump outgoing API response (nil by default).

| Value | Dump to |
| ----- | ------- |
| nil | Nothing |
| :stdout, "stdout" | $stdout |
| :stderr, "stderr" | $stderr |
| lambda | Calls this lambda with incoming parsed JSON data |

@param [Code] code_block Code block to be executed on every API response. @yield [json] Response parsed JSON data to be handled. @return [NilClass] nil @example Dump incoming API responses to ‘$stdout`

RegApi2.dump_responses :stdout
# File lib/reg_api2/impl.rb, line 88
def dump_responses(to = nil, &code_block)
  if to.nil? && block_given?
    to = code_block
  end
  self.dump_responses_to = to
  nil
end
folder() click to toggle source

Shortcut for {RegApi2::Folder} methods. @return [Module] {RegApi2::Folder} @api Shortcuts

# File lib/reg_api2.rb, line 97
def folder; RegApi2::Folder; end
form_to_be_sent(path, form) click to toggle source

Placeholder to inspect sent form @param [String] path @param [Hash] form @return void

# File lib/reg_api2/impl.rb, line 100
def form_to_be_sent(path, form)
  case dump_requests_to
  when :stderr, "stderr"
    $stderr.puts "RegApi2.Request:\n#{path}\n#{form}"
  when :stdout, "stdout"
    $stdout.puts "RegApi2.Request:\n#{path}\n#{form}"
  when Proc
    dump_requests_to.call(path, form)
  when nil
    ;
  else
    raise ArgumentError.new( "Bad dump_requests_to field: #{dump_requests_to.inspect}" )
  end
  nil
end
got_response(response) click to toggle source

Placeholder to inspect got response. @param [Net::HTTPResponse] response @return void

# File lib/reg_api2/impl.rb, line 119
def got_response(response)
  case dump_responses_to
  when :stderr, "stderr"
    $stderr.puts "RegApi2.Response:\n#{response}"
  when :stdout, "stdout"
    $stdout.puts "RegApi2.Response:\n#{response}"
  when Proc
    dump_responses_to.call(response)
  when nil
    ;
  else
    raise ArgumentError.new( "Bad dump_responses_to field: #{dump_responses_to.inspect}" )
  end
  nil
end
hosting() click to toggle source

Shortcut for {RegApi2::Hosting} methods. @return [Module] {RegApi2::Hosting} @api Shortcuts

# File lib/reg_api2.rb, line 109
def hosting; RegApi2::Hosting; end
service() click to toggle source

Shortcut for {RegApi2::Service} methods. @return [Module] {RegApi2::Service} @api Shortcuts

# File lib/reg_api2.rb, line 85
def service; RegApi2::Service; end
shop() click to toggle source

Shortcut for {RegApi2::Shop} methods. @return [Module] {RegApi2::Shop} @api Shortcuts

# File lib/reg_api2.rb, line 115
def shop; RegApi2::Shop; end
user() click to toggle source

Shortcut for {RegApi2::User} methods. @return [Module] {RegApi2::User} @api Shortcuts

# File lib/reg_api2.rb, line 79
def user; RegApi2::User; end
zone() click to toggle source

Shortcut for {RegApi2::Zone} methods. @return [Module] {RegApi2::Zone} @api Shortcuts

# File lib/reg_api2.rb, line 103
def zone; RegApi2::Zone; end

Private Instance Methods

bill() click to toggle source

Shortcut for {RegApi2::Bill} methods. @return [Module] {RegApi2::Bill} @api Shortcuts

# File lib/reg_api2.rb, line 91
def bill; RegApi2::Bill; end
common() click to toggle source

Shortcut for {RegApi2::Common} methods @return [Module] {RegApi2::Common} @api Shortcuts

# File lib/reg_api2.rb, line 67
def common; RegApi2::Common; end
domain() click to toggle source

Shortcut for {RegApi2::Domain} methods. @return [Module] {RegApi2::Domain} @api Shortcuts

# File lib/reg_api2.rb, line 73
def domain; RegApi2::Domain; end
folder() click to toggle source

Shortcut for {RegApi2::Folder} methods. @return [Module] {RegApi2::Folder} @api Shortcuts

# File lib/reg_api2.rb, line 97
def folder; RegApi2::Folder; end
hosting() click to toggle source

Shortcut for {RegApi2::Hosting} methods. @return [Module] {RegApi2::Hosting} @api Shortcuts

# File lib/reg_api2.rb, line 109
def hosting; RegApi2::Hosting; end
service() click to toggle source

Shortcut for {RegApi2::Service} methods. @return [Module] {RegApi2::Service} @api Shortcuts

# File lib/reg_api2.rb, line 85
def service; RegApi2::Service; end
shop() click to toggle source

Shortcut for {RegApi2::Shop} methods. @return [Module] {RegApi2::Shop} @api Shortcuts

# File lib/reg_api2.rb, line 115
def shop; RegApi2::Shop; end
user() click to toggle source

Shortcut for {RegApi2::User} methods. @return [Module] {RegApi2::User} @api Shortcuts

# File lib/reg_api2.rb, line 79
def user; RegApi2::User; end
zone() click to toggle source

Shortcut for {RegApi2::Zone} methods. @return [Module] {RegApi2::Zone} @api Shortcuts

# File lib/reg_api2.rb, line 103
def zone; RegApi2::Zone; end