Class: DNSimple::TransferOrder

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/dnsimple/transfer_order.rb

Overview

Class representing a transfer order in DNSimple

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes) ⇒ TransferOrder

Returns a new instance of TransferOrder.



10
11
12
13
14
15
# File 'lib/dnsimple/transfer_order.rb', line 10

def initialize(attributes)
  attributes.each do |key, value|
    m = "#{key}=".to_sym
    self.send(m, value) if self.respond_to?(m)
  end
end

Instance Attribute Details

#idObject

Returns the value of attribute id.



6
7
8
# File 'lib/dnsimple/transfer_order.rb', line 6

def id
  @id
end

#statusObject

Returns the value of attribute status.



8
9
10
# File 'lib/dnsimple/transfer_order.rb', line 8

def status
  @status
end

Class Method Details

.create(name, authinfo = '', registrant = {}, extended_attributes = {}, options = {}) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/dnsimple/transfer_order.rb', line 17

def self.create(name, authinfo='', registrant={}, extended_attributes={}, options={})
  body = {:domain => {:name => name}, :transfer_order => {:authinfo => authinfo}}

  if registrant[:id]
    body[:domain][:registrant_id] = registrant[:id]
  else
    body.merge!(:contact => Contact.resolve_attributes(registrant))
  end

  body.merge!(:extended_attribute => extended_attributes)

  options.merge!({:body => body})
  options.merge!({:basic_auth => Client.credentials})

  response = self.post("#{Client.base_uri}/domain_transfers.json", options)

  pp response if Client.debug?

  case response.code
  when 201
    return TransferOrder.new(response["transfer_order"])
  when 401
    raise RuntimeError, "Authentication failed"
  else
    raise DNSimple::Error.new(name, response["errors"])
  end
end