Class: Glare::Client
- Inherits:
-
Object
- Object
- Glare::Client
- Defined in:
- lib/glare/client.rb
Constant Summary collapse
- BASE_URL =
'https://api.cloudflare.com/client/v4'.freeze
Instance Method Summary collapse
- #delete(query, params = nil) ⇒ Object
- #get(query, params) ⇒ Object
-
#initialize(email, auth_key) ⇒ Client
constructor
A new instance of Client.
- #post(query, data) ⇒ Object
- #put(query, data) ⇒ Object
Constructor Details
#initialize(email, auth_key) ⇒ Client
Returns a new instance of Client.
8 9 10 11 12 13 14 15 |
# File 'lib/glare/client.rb', line 8 def initialize(email, auth_key) @headers = { 'X-Auth-Email' => email, 'X-Auth-Key' => auth_key } @http = JSONClient.new @http.debug_dev = STDERR if ENV['CF_DEBUG'] end |
Instance Method Details
#delete(query, params = nil) ⇒ Object
29 30 31 |
# File 'lib/glare/client.rb', line 29 def delete(query, params=nil) ApiResponse.new(@http.delete(BASE_URL + query, params, @headers)).valid! end |
#get(query, params) ⇒ Object
17 18 19 |
# File 'lib/glare/client.rb', line 17 def get(query, params) ApiResponse.new(@http.get(BASE_URL + query, params, @headers)).valid! end |
#post(query, data) ⇒ Object
21 22 23 |
# File 'lib/glare/client.rb', line 21 def post(query, data) ApiResponse.new(@http.post(BASE_URL + query, data, @headers)).valid! end |
#put(query, data) ⇒ Object
25 26 27 |
# File 'lib/glare/client.rb', line 25 def put(query, data) ApiResponse.new(@http.put(BASE_URL + query, data, @headers)).valid! end |