mirror of
https://github.com/internetee/registry.git
synced 2025-08-04 00:42:04 +02:00
Make epp code map dynamic
This commit is contained in:
parent
c166967467
commit
5258c43faa
5 changed files with 57 additions and 28 deletions
|
@ -4,12 +4,6 @@ class Contact < ActiveRecord::Base
|
|||
|
||||
include EppErrors
|
||||
|
||||
EPP_CODE_MAP = {
|
||||
'2302' => ['Contact id already exists'],
|
||||
'2303' => [:not_found, :epp_obj_does_not_exist],
|
||||
'2005' => ['Phone nr is invalid', 'Email is invalid']
|
||||
}
|
||||
|
||||
EPP_ATTR_MAP = {}
|
||||
|
||||
has_one :address
|
||||
|
@ -81,7 +75,7 @@ class Contact < ActiveRecord::Base
|
|||
relation = get_relation(model)
|
||||
return true unless relation.nil? || relation.blank?
|
||||
false
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
@ -94,27 +88,35 @@ class Contact < ActiveRecord::Base
|
|||
false
|
||||
end
|
||||
|
||||
def epp_code_map
|
||||
{
|
||||
'2302' => [[:code, :epp_id_taken]],
|
||||
'2303' => [:not_found, :epp_obj_does_not_exist],
|
||||
'2005' => ['Phone nr is invalid', 'Email is invalid']
|
||||
}
|
||||
end
|
||||
|
||||
class << self
|
||||
|
||||
|
||||
def extract_attributes ph, type=:create
|
||||
|
||||
|
||||
contact_hash = {
|
||||
phone: ph[:voice],
|
||||
ident: ph[:ident],
|
||||
email: ph[:email]
|
||||
}
|
||||
|
||||
|
||||
contact_hash = contact_hash.merge({
|
||||
name: ph[:postalInfo][:name],
|
||||
org_name: ph[:postalInfo][:org]
|
||||
}) if ph[:postalInfo].is_a? Hash
|
||||
|
||||
|
||||
contact_hash[:code] = ph[:id] if type == :create
|
||||
|
||||
|
||||
contact_hash.delete_if { |k, v| v.nil? }
|
||||
end
|
||||
|
||||
|
||||
def check_availability(codes)
|
||||
codes = [codes] if codes.is_a?(String)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue