Class: Cloudflarer::Client
- Inherits:
-
Object
- Object
- Cloudflarer::Client
- Defined in:
- lib/cloudflarer/client.rb
Constant Summary collapse
- API_VERSION =
'v4'.freeze
- HOST =
'api.cloudflare.com'.freeze
- PATH =
"/client/#{API_VERSION}".freeze
- URL =
"https://#{HOST}#{PATH}".freeze
Instance Method Summary collapse
-
#initialize(api_key: nil, email: nil) ⇒ Client
constructor
A new instance of Client.
Constructor Details
#initialize(api_key: nil, email: nil) ⇒ Client
Returns a new instance of Client.
12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/cloudflarer/client.rb', line 12 def initialize(api_key: nil, email: nil) api_key ||= ENV['CLOUDFLARE_API_KEY'] raise ArgumentError, "API Key is required." unless api_key email ||= ENV['CLOUDFLARE_EMAIL'] raise ArgumentError, "Email is required" unless email headers = { 'X-Auth-Key' => api_key, 'X-Auth-Email' => email, 'Content-Type': 'application/json' } @connection = Faraday.new(URL, headers: headers) end |