Sha256: 6f9fb5f3341251483e6094a401c72d95f34783da7dd485cf34c652699b030e9b
Contents?: true
Size: 826 Bytes
Versions: 1
Compression:
Stored size: 826 Bytes
Contents
module Rubyflare class Connect attr_reader :response API_URL = "https://api.cloudflare.com/client/v4/" def initialize(email, api_key) @email = email @api_key = api_key end %i(get post put patch delete).each do |method_name| define_method(method_name) do |endpoint, options = {}| options = options.to_json unless method_name == :get response = Curl.send(method_name, API_URL + endpoint, options) do |http| http.headers['X-Auth-Email'] = @email http.headers['X-Auth-Key'] = @api_key http.headers['Content-Type'] = 'application/json' http.headers['User-Agent'] = "Rubyflare/#{Rubyflare::VERSION}" end @response = Rubyflare::Response.new(method_name, endpoint, response.body_str) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rubyflare-0.2.0 | lib/rubyflare/connect.rb |