Module: JokerDMAPI::Domain
- Included in:
- Client
- Defined in:
- lib/joker-dmapi/domain.rb
Instance Method Summary collapse
-
#domain_create(domain, fields) ⇒ Object
Register new domain.
-
#domain_info(domain) ⇒ Object
Returns the information about a domain or
nilif not exists. -
#domain_registrant_update(domain, fields) ⇒ Object
Update registrant’s info.
-
#domain_renew(domain, period) ⇒ Object
Renew domain.
-
#domain_update(domain, fields) ⇒ Object
Update domain.
Instance Method Details
#domain_create(domain, fields) ⇒ Object
Register new domain
Takes domain and domain’s fields as hash:
:period-
registration period (years!!!)
:registrant-
registrant (owner) handle (registered)
:admin-
admin handle (registered)
:tech-
tech handle (registered)
:billing-
billing handle (registered)
:nservers-
an array of NS servers
Returned is a hash of response:
:headers:proc_id-
process ID (used at check result)
:tracking_id-
tracking ID
84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/joker-dmapi/domain.rb', line 84 def domain_create(domain, fields) unless ([ :period, :registrant, :admin, :tech, :billing, :nservers ] - fields.keys).empty? raise ArgumentError, "Required fields not found" end query :domain_register, { domain: domain, period: (fields[:period] * 12), owner_c: fields[:registrant], admin_c: fields[:admin], tech_c: fields[:tech], billing_c: fields[:billing], ns_list: fields[:nservers].join(':') } end |
#domain_info(domain) ⇒ Object
Returns the information about a domain or nil if not exists
Takes FQDN as string
Returned is a hash:
:fqdn-
FQDN
:status-
domain status
:registrant-
registrant (owner) as hash keys:
:name-
registrant’s name
:organization-
registrant’s organization
:address-
an array of registrant’s address
:postal_code-
registrant’s postal code
:country-
registrant’s country code
:owner_c_email-
owner’s email address
:email-
registrant’s email address
:phone-
registrant’s voice phone number
:fax-
registrant’s fax number
:reseller_lines-
an array of reseller data
:admin_c-
registrant’s admin-c handle
:tech_c-
registrant’s tech-c handle
:billing_c-
registrant’s billing-c handle
:nservers-
an array of NS servers
:created_date-
date and time of creation
:modified_date-
date and time of modification
:expires-
date and time of expiration
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/joker-dmapi/domain.rb', line 30 def domain_info(domain) response = query_no_raise :query_whois, domain: domain case response[:headers][:status_code] when '2303' then nil when '0' then result = {} response[:body].split("\n").each do |line| line.slice! /^domain\./ line_parsed = parse_line(line) next if line_parsed.is_a? String key, value = line_parsed.first case key when :fqdn, :status then result.merge! line_parsed when :name, :organization, :city, :postal_code, :country, :owner_c_email, :email, :phone, :fax then result[:registrant] = {} unless result.has_key? :registrant result[:registrant].merge! line_parsed when :address_1, :address_2, :address_3 then result[:registrant] = {} unless result.has_key? :registrant result[:registrant][:address] = [] unless result[:registrant].has_key? :address result[:registrant][:address] << value when :reseller_line then result[:reseller_lines] = [] unless result.has_key? :reseller_lines result[:reseller_lines] << value when :created_date, :modified_date, :expires then result[key] = DateTime.parse value when :admin_c, :tech_c, :billing_c then result.merge! line_parsed when :nservers_nserver_handle then result[:nservers] = [] unless result.has_key? :nservers result[:nservers] << value else next end end result else raise_response response end end |
#domain_registrant_update(domain, fields) ⇒ Object
Update registrant’s info
Takes domain and fields (see contact_update)
135 136 137 138 139 |
# File 'lib/joker-dmapi/domain.rb', line 135 def domain_registrant_update(domain, fields) fields = contact_prepare(fields) fields[:domain] = domain query :domain_owner_change, fields end |
#domain_renew(domain, period) ⇒ Object
Renew domain
Takes domain and period WARNING!!! period in YEARS
128 129 130 |
# File 'lib/joker-dmapi/domain.rb', line 128 def domain_renew(domain, period) query :domain_renew, { domain: domain, period: (12 * period) } end |
#domain_update(domain, fields) ⇒ Object
Update domain
Takes domain and domain’s fields as hash:
:admin-
admin handle (registered)
:tech-
tech handle (registered)
:billing-
billing handle (registered)
:nservers-
an array of NS servers
Returned is a hash of response:
:headers:proc_id-
process ID (used at check result)
:tracking_id-
tracking ID
111 112 113 114 115 116 117 118 119 120 121 122 |
# File 'lib/joker-dmapi/domain.rb', line 111 def domain_update(domain, fields) unless ([ :admin, :tech, :billing, :nservers ] - fields.keys).empty? raise ArgumentError, "Required fields not found" end query :domain_modify, { domain: domain, admin_c: fields[:admin], tech_c: fields[:tech], billing_c: fields[:billing], ns_list: fields[:nservers].join(':') } end |