Add registrant phone to whois record json

This commit is contained in:
Thiago Youssef 2022-07-11 11:20:05 -03:00 committed by olegphenomenon
parent 3401a9fc47
commit 5c70e9f38b
5 changed files with 21 additions and 17 deletions

View file

@ -3,7 +3,6 @@ module Api
class ContactRequestsController < BaseController class ContactRequestsController < BaseController
before_action :authenticate_shared_key before_action :authenticate_shared_key
# POST api/v1/contact_requests/
def create def create
return head(:bad_request) if contact_request_params[:email].blank? return head(:bad_request) if contact_request_params[:email].blank?
@ -19,6 +18,8 @@ module Api
process_id(params[:id]) process_id(params[:id])
end end
private
def process_id(id) def process_id(id)
record = ContactRequest.find_by(id: id) record = ContactRequest.find_by(id: id)
return :not_found unless record return :not_found unless record

View file

@ -47,7 +47,7 @@ module Zone::WhoisQueryable
def registrant_vars def registrant_vars
{ registrant: Setting.registry_juridical_name, registrant_reg_no: Setting.registry_reg_no, { registrant: Setting.registry_juridical_name, registrant_reg_no: Setting.registry_reg_no,
registrant_ident_country_code: Setting.registry_country_code, registrant_kind: 'org', registrant_ident_country_code: Setting.registry_country_code, registrant_kind: 'org',
registrant_disclosed_attributes: %w[name email] } registrant_disclosed_attributes: %w[name email phone] }
end end
def contact_vars def contact_vars

View file

@ -15,7 +15,15 @@ class ContactRequest < ApplicationRecord
attr_readonly :secret, attr_readonly :secret,
:valid_to :valid_to
def self.save_record(params) def update_record(params)
self.status = params['status'] if params['status']
self.ip_address = params['ip'] if params['ip']
self.message_id = params['ip'] if params['message_id']
save!
end
class << self
def save_record(params)
contact_request = new(params) contact_request = new(params)
contact_request.secret = create_random_secret contact_request.secret = create_random_secret
contact_request.valid_to = set_valid_to_24_hours_from_now contact_request.valid_to = set_valid_to_24_hours_from_now
@ -24,18 +32,12 @@ class ContactRequest < ApplicationRecord
contact_request contact_request
end end
def update_record(params) def create_random_secret
self.status = params['status'] if params['status']
self.ip_address = params['ip'] if params['ip']
self.message_id = params['ip'] if params['message_id']
save!
end
def self.create_random_secret
SecureRandom.hex(64) SecureRandom.hex(64)
end end
def self.set_valid_to_24_hours_from_now def set_valid_to_24_hours_from_now
(Time.zone.now + 24.hours) (Time.zone.now + 24.hours)
end end
end end
end

View file

@ -51,6 +51,7 @@ class WhoisRecord < ApplicationRecord
end end
h[:email] = registrant.email h[:email] = registrant.email
h[:phone] = registrant.phone
h[:registrant_changed] = registrant.updated_at.try(:to_s, :iso8601) h[:registrant_changed] = registrant.updated_at.try(:to_s, :iso8601)
h[:registrant_disclosed_attributes] = registrant.disclosed_attributes h[:registrant_disclosed_attributes] = registrant.disclosed_attributes

View file

@ -113,7 +113,7 @@ Update contact.
| address[city] | false | String | | New city name | | address[city] | false | String | | New city name |
| address[state] | false | String | | New state name | | address[state] | false | String | | New state name |
| address[country_code] | false | String | | New country code in 2 letter format (ISO 3166-1 alpha-2) | | address[country_code] | false | String | | New country code in 2 letter format (ISO 3166-1 alpha-2) |
| disclosed_attributes | false | Array | | Possible values: "name", "email" | disclosed_attributes | false | Array | | Possible values: "name", "email", "phone"
#### Request #### Request