Class: Registrar::Provider::OpenSRS::Order

Inherits:
Object
  • Object
show all
Defined in:
lib/registrar/provider/opensrs/order.rb

Instance Method Summary collapse

Constructor Details

#initialize(xml) ⇒ Order

Returns a new instance of Order.



6
7
8
9
# File 'lib/registrar/provider/opensrs/order.rb', line 6

def initialize(xml)
  @xml = Nokogiri::XML(xml) 
  @domains = []
end

Instance Method Details

#add_domain(domain_name, registrant) ⇒ Object



28
29
30
31
# File 'lib/registrar/provider/opensrs/order.rb', line 28

def add_domain(domain_name, registrant)
  @domains << create_domain(domain_name, registrant)
  self
end

#complete?Boolean

Returns:

  • (Boolean)


19
20
21
22
# File 'lib/registrar/provider/opensrs/order.rb', line 19

def complete?
  status = field_hash_element("status").inner_text
  status != 'pending' || status != 'waiting_ca_owner_approval'
end

#domainsObject



24
25
26
# File 'lib/registrar/provider/opensrs/order.rb', line 24

def domains
  @domains
end

#idObject



11
12
13
# File 'lib/registrar/provider/opensrs/order.rb', line 11

def id
  field_hash_element('id').inner_text
end

#successful?Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/registrar/provider/opensrs/order.rb', line 15

def successful?
  element("is_success").inner_text == '1'
end

#to_orderObject



33
34
35
36
37
38
39
# File 'lib/registrar/provider/opensrs/order.rb', line 33

def to_order
  order = Registrar::Order.new(id)
  order.successful= successful?
  order.status= complete? ? :closed : :open
  domains.each { |domain| order.domains<< domain }
  order
end