Module: RegApi2

Extended by:
Action
Defined in:
lib/reg_api2.rb,
lib/reg_api2/bill.rb,
lib/reg_api2/impl.rb,
lib/reg_api2/shop.rb,
lib/reg_api2/user.rb,
lib/reg_api2/zone.rb,
lib/reg_api2/action.rb,
lib/reg_api2/common.rb,
lib/reg_api2/domain.rb,
lib/reg_api2/folder.rb,
lib/reg_api2/builder.rb,
lib/reg_api2/console.rb,
lib/reg_api2/hosting.rb,
lib/reg_api2/service.rb,
lib/reg_api2/version.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 collapse

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

.ca_cert_pathString

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

.dump_requests_toString, ...

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

.dump_responses_toString, ...

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

.io_encodingString

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

.langString

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

.passwordString

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

.pemString

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

.pem_passwordString

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

.usernameString

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

.billModule

Shortcut for Bill methods.

Returns:



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

def bill; RegApi2::Bill; end

.commonModule

Shortcut for Common methods

Returns:



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

def common; RegApi2::Common; end

.domainModule

Shortcut for Domain methods.

Returns:



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

def domain; RegApi2::Domain; end

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

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

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

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

.folderModule

Shortcut for Folder methods.

Returns:



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

def folder; RegApi2::Folder; end

.form_to_be_sent(path, form) ⇒ Object

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

.got_response(response) ⇒ Object

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

.hostingModule

Shortcut for Hosting methods.

Returns:



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

def hosting; RegApi2::Hosting; end

.serviceModule

Shortcut for Service methods.

Returns:



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

def service; RegApi2::Service; end

.shopModule

Shortcut for Shop methods.

Returns:



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

def shop; RegApi2::Shop; end

.userModule

Shortcut for User methods.

Returns:



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

def user; RegApi2::User; end

.zoneModule

Shortcut for Zone methods.

Returns:



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

def zone; RegApi2::Zone; end