lib/nifcloud/client.rb in nifcloud-dns-0.2.1 vs lib/nifcloud/client.rb in nifcloud-dns-0.2.2

- old
+ new

@@ -1,10 +1,13 @@ -require "nifcloud/auth" -require "nifcloud/dns/response" +# frozen_string_literal: true + +require 'nifcloud/auth' +require 'nifcloud/dns/response' require 'net/https' module Nifcloud + # Client for nifcloud dns class Client < Auth ENDPOINT = 'https://dns.api.nifcloud.com/' VERSION = '2012-12-12N2013-12-16' AUTHORIZATION_HEADER = 'X-Nifty-Authorization' DATE_HEADER = 'X-Nifty-Date' @@ -13,11 +16,11 @@ def initialize(access_key, secret_key) super(access_key, secret_key) @http, @req, @uri = nil end - def get path + 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) @@ -31,20 +34,20 @@ init_header res = call Nifcloud::DNS::Response.new(XmlSimple.xml_in(res.body), res.code, res.body) end - def delete path + 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 private - def init path + def init(path) @uri = URI.parse("#{ENDPOINT}#{VERSION}/#{path}") @http = Net::HTTP.new(@uri.host, @uri.port) @http.use_ssl = true end