Class: Nifcloud::Client

Inherits:
Auth
  • Object
show all
Defined in:
lib/nifcloud/client.rb

Direct Known Subclasses

DNS::Record, DNS::Zone

Constant Summary collapse

ENDPOINT =
'https://dns.api.nifcloud.com/'
VERSION =
'2012-12-12N2013-12-16'
AUTHORIZATION_HEADER =
'X-Nifty-Authorization'
DATE_HEADER =
'X-Nifty-Date'
NAMESPACE =
'https://route53.amazonaws.com/doc/2012-12-12/'

Constants inherited from Auth

Auth::ALGORITHM

Instance Attribute Summary

Attributes inherited from Auth

#time

Instance Method Summary collapse

Methods inherited from Auth

#signature_header

Constructor Details

#initialize(access_key, secret_key) ⇒ Client

Returns a new instance of Client.



13
14
15
16
# File 'lib/nifcloud/client.rb', line 13

def initialize(access_key, secret_key)
  super(access_key, secret_key)
  @http, @req, @uri = nil
end

Instance Method Details

#delete(path) ⇒ Object



36
37
38
39
40
41
42
# File 'lib/nifcloud/client.rb', line 36

def delete path
  init path
  @req = Net::HTTP::Delete.new @uri.request_uri
  init_header
  res = call
  Nifcloud::DNS::Response.new(XmlSimple.xml_in(res.body), res.code, res.body)
end

#get(path) ⇒ Object



18
19
20
21
22
23
24
# File 'lib/nifcloud/client.rb', line 18

def get path
  init path
  @req = Net::HTTP::Get.new @uri.request_uri
  init_header
  res = call
  Nifcloud::DNS::Response.new(XmlSimple.xml_in(res.body), res.code, res.body)
end

#post(path, body) ⇒ Object



26
27
28
29
30
31
32
33
34
# File 'lib/nifcloud/client.rb', line 26

def post(path, body)
  init path
  @req = Net::HTTP::Post.new @uri.request_uri
  @req.body = body
  @req.content_type = 'text/xml'
  init_header
  res = call
  Nifcloud::DNS::Response.new(XmlSimple.xml_in(res.body), res.code, res.body)
end