Class: Dozens::API

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/dozens/api.rb

Instance Method Summary collapse

Constructor Details

#initialize(user, key) ⇒ API

Returns a new instance of API.



13
14
15
16
17
18
19
# File 'lib/dozens/api.rb', line 13

def initialize(user, key)
  @user = user
  @key = key

  r = self.class.get("/authorize.json", :headers => { "X-Auth-User" => @user, "X-Auth-Key" => @key })
  @token = r['auth_token']
end

Instance Method Details

#get_record_list(zone_name) ⇒ Object



26
27
28
# File 'lib/dozens/api.rb', line 26

def get_record_list(zone_name)
  self.class.get("/record/#{ zone_name }.json", { :headers => authorization_headers })
end

#update_record(record_id, new_value, ttl = 60) ⇒ Object



21
22
23
24
# File 'lib/dozens/api.rb', line 21

def update_record(record_id, new_value, ttl=60)
  options = { :body => { "content" => new_value, "ttl" => ttl }.to_json, :headers => authorization_headers }
  self.class.post("/record/update/#{ record_id }.json", options)
end