Module: RegApi2

Extended by:
Action
Defined in:
lib/reg_api2.rb,
lib/reg_api2/user.rb,
lib/reg_api2/bill.rb,
lib/reg_api2/zone.rb,
lib/reg_api2/impl.rb,
lib/reg_api2/shop.rb,
lib/reg_api2/common.rb,
lib/reg_api2/folder.rb,
lib/reg_api2/domain.rb,
lib/reg_api2/action.rb,
lib/reg_api2/hosting.rb,
lib/reg_api2/version.rb,
lib/reg_api2/builder.rb,
lib/reg_api2/console.rb,
lib/reg_api2/service.rb,
lib/reg_api2/sym_hash.rb,
lib/reg_api2/api_error.rb,
lib/reg_api2/net_error.rb,
lib/reg_api2/entity/user.rb,
lib/reg_api2/contract_error.rb,
lib/reg_api2/result_contract.rb,
lib/reg_api2/request_contract.rb,
lib/reg_api2/entity/entity_base.rb

Overview

Provides r/w settings for API connection:

Provides shortcuts for API categories:

Provides dump hooks:

Please read README for API overview.

Examples:

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" }
])

Dump incoming API responses to $stderr

RegApi2.dump_responses :stderr

Defined Under Namespace

Modules: Action, Bill, Builder, Common, Domain, Entity, Folder, Hosting, Service, Shop, User, Zone Classes: ApiError, Console, ContractError, NetError, RequestContract, ResultContract, SymHash

Constant Summary

VERSION =

Gem version.

"0.0.16".freeze

Constants included from Action

Action::API_URI, Action::DEFAULT_IO_ENCODING, Action::DEFAULT_LANG, Action::DEFAULT_PASSWORD, Action::DEFAULT_USERNAME

Class Attribute Summary (collapse)

Class Method Summary (collapse)

Methods included from Action

clear_http, create_http, get_form_data, handle_response, http, make_action

Class Attribute Details

+ (String) ca_cert_path

Returns Path to certification authority certificate (nil by default).

Returns:

  • (String)

    Path to certification authority certificate (nil by default).



134
135
136
# File 'lib/reg_api2.rb', line 134

def ca_cert_path
  @ca_cert_path
end

+ (String, ...) dump_requests_to=(value)

Returns 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

Returns:

  • (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


37
38
39
# File 'lib/reg_api2/impl.rb', line 37

def dump_requests_to
  @dump_requests_to
end

+ (String, ...) dump_responses_to=(value)

Returns 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

Returns:

  • (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


47
48
49
# File 'lib/reg_api2/impl.rb', line 47

def dump_responses_to
  @dump_responses_to
end

+ (String) io_encoding

Returns IO encoding (utf-8 by default).

Returns:

  • (String)

    IO encoding (utf-8 by default).



128
129
130
# File 'lib/reg_api2.rb', line 128

def io_encoding
  @io_encoding
end

+ (String) lang

Returns Language (en by default).

Returns:

  • (String)

    Language (en by default).



131
132
133
# File 'lib/reg_api2.rb', line 131

def lang
  @lang
end

+ (String) password

Returns Password (test by default).

Returns:

  • (String)

    Password (test by default).



125
126
127
# File 'lib/reg_api2.rb', line 125

def password
  @password
end

+ (String) pem

Returns X.509 certificate (nil by default).

Returns:

  • (String)

    X.509 certificate (nil by default).



137
138
139
# File 'lib/reg_api2.rb', line 137

def pem
  @pem
end

+ (String) pem_password

Returns X.509 certificate password (nil by default).

Returns:

  • (String)

    X.509 certificate password (nil by default).



140
141
142
# File 'lib/reg_api2.rb', line 140

def pem_password
  @pem_password
end

+ (String) username

Returns User name (test by default).

Returns:

  • (String)

    User name (test by default).



122
123
124
# File 'lib/reg_api2.rb', line 122

def username
  @username
end

Class Method Details

+ (Module) bill

Shortcut for Bill methods.

Returns:



92
# File 'lib/reg_api2.rb', line 92

def bill; RegApi2::Bill; end

+ (Module) common

Shortcut for Common methods

Returns:



68
# File 'lib/reg_api2.rb', line 68

def common; RegApi2::Common; end

+ (Module) domain

Shortcut for Domain methods.

Returns:



74
# File 'lib/reg_api2.rb', line 74

def domain; RegApi2::Domain; end

+ (NilClass) dump_requests(to = nil, &code_block) {|path, form| ... }

Dumps outgoing API requests to given to or code block.

Examples:

Dump outgoing API requests to code block

RegApi2.dump_requests { |path, form| p path; p form }

Parameters:

  • to (String, Symbol, Lambda) (defaults to: nil)

    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
  • code_block (Code)

    Code block to be executed on every API request.

Yields:

  • (path, form)

    Request path and form to be sent.

Returns:

  • (NilClass)

    nil



66
67
68
69
70
71
72
# File 'lib/reg_api2/impl.rb', line 66

def dump_requests(to = nil, &code_block)
  if to.nil? && block_given?
    to = code_block
  end
  self.dump_requests_to = to
  nil
end

+ (NilClass) dump_responses(to = nil, &code_block) {|json| ... }

Dumps incoming API responses to given to or code block.

Examples:

Dump incoming API responses to $stdout

RegApi2.dump_responses :stdout

Parameters:

  • to (String, Symbol, Lambda) (defaults to: nil)

    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
  • code_block (Code)

    Code block to be executed on every API response.

Yields:

  • (json)

    Response parsed JSON data to be handled.

Returns:

  • (NilClass)

    nil



89
90
91
92
93
94
95
# File 'lib/reg_api2/impl.rb', line 89

def dump_responses(to = nil, &code_block)
  if to.nil? && block_given?
    to = code_block
  end
  self.dump_responses_to = to
  nil
end

+ (Module) folder

Shortcut for Folder methods.

Returns:



98
# File 'lib/reg_api2.rb', line 98

def folder; RegApi2::Folder; end

+ (Object) form_to_be_sent(path, form)

Placeholder to inspect sent form

Parameters:

  • path (String)
  • form (Hash)

Returns:

  • void



101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
# File 'lib/reg_api2/impl.rb', line 101

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

+ (Object) got_response(response)

Placeholder to inspect got response.

Parameters:

  • response (Net::HTTPResponse)

Returns:

  • void



120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
# File 'lib/reg_api2/impl.rb', line 120

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

+ (Module) hosting

Shortcut for Hosting methods.

Returns:



110
# File 'lib/reg_api2.rb', line 110

def hosting; RegApi2::Hosting; end

+ (Module) service

Shortcut for Service methods.

Returns:



86
# File 'lib/reg_api2.rb', line 86

def service; RegApi2::Service; end

+ (Module) shop

Shortcut for Shop methods.

Returns:



116
# File 'lib/reg_api2.rb', line 116

def shop; RegApi2::Shop; end

+ (Module) user

Shortcut for User methods.

Returns:



80
# File 'lib/reg_api2.rb', line 80

def user; RegApi2::User; end

+ (Module) zone

Shortcut for Zone methods.

Returns:



104
# File 'lib/reg_api2.rb', line 104

def zone; RegApi2::Zone; end