Class: StatusCake::Client
- Inherits:
-
Object
- Object
- StatusCake::Client
- Defined in:
- lib/statuscake/client.rb
Constant Summary collapse
- ENDPOINT =
'https://app.statuscake.com'
- USER_AGENT =
"Ruby StatusCake Client #{StatusCake::VERSION}"
- DEFAULT_ADAPTERS =
[ Faraday::Adapter::NetHttp, Faraday::Adapter::Test ]
- OPTIONS =
[ :API, :Username, ]
- APIs =
{ '/API/Alerts' => {:method => :get}, '/API/ContactGroups/Update' => {:method => :put}, '/API/ContactGroups' => {:method => :get}, '/API/Tests/Checks' => {:method => :get}, '/API/Tests/Periods' => {:method => :get}, '/API/Tests' => {:method => :get}, '/API/Tests/Details' => {:method => :get}, # Delete test when HTTP method is "DELETE" # see https://www.statuscake.com/api/Tests/Deleting%20a%20Test.md '/API/Tests/Update' => {:method => :put}, '/API/Locations/json' => {:method => :get, :alias => :locations}, '/API/Locations/txt' => {:method => :get}, '/API/Locations/xml' => {:method => :get}, '/API/Auth' => {:method => :get}, }
Instance Method Summary collapse
-
#initialize(options) ⇒ Client
constructor
A new instance of Client.
Constructor Details
#initialize(options) ⇒ Client
Returns a new instance of Client.
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/statuscake/client.rb', line 32 def initialize() @options = {} OPTIONS.each do |key| @options[key] = .delete(key) end [:url] ||= ENDPOINT @conn = Faraday.new() do |faraday| faraday.request :url_encoded faraday.response :json, :content_type => /\bjson$/ faraday.response :raise_error yield(faraday) if block_given? unless DEFAULT_ADAPTERS.any? {|i| faraday.builder.handlers.include?(i) } faraday.adapter Faraday.default_adapter end end @conn.headers[:user_agent] = USER_AGENT end |