Class: Spage::Api::Component
- Inherits:
-
Object
- Object
- Spage::Api::Component
- Includes:
- Spage::Api
- Defined in:
- lib/spage/api/component.rb
Overview
Component resources in the statuspage.io API
Instance Method Summary collapse
- #all(page_id:, per_page: 100, page: 1) ⇒ Object
- #create(component, page_id:) ⇒ Object
- #delete(page_id:, id:) ⇒ Object
- #find(page_id:, id:) ⇒ Object
- #update(component, page_id:, id:) ⇒ Object
Methods included from Spage::Api
Instance Method Details
#all(page_id:, per_page: 100, page: 1) ⇒ Object
12 13 14 15 16 17 18 19 20 |
# File 'lib/spage/api/component.rb', line 12 def all(page_id:, per_page: 100, page: 1) response = client.get("pages/#{page_id}/components", query: "per_page=#{per_page}&page=#{page}") handle_response(response) do response.body.map do |component| Spage::Component.new(component) end end end |
#create(component, page_id:) ⇒ Object
30 31 32 33 34 35 36 37 38 |
# File 'lib/spage/api/component.rb', line 30 def create(component, page_id:) json = Spage::Serializers::Component.new(component, update: true).to_json response = client.post("pages/#{page_id}/components", json) handle_response(response) do Spage::Component.new(response.body) end end |
#delete(page_id:, id:) ⇒ Object
50 51 52 53 54 55 56 |
# File 'lib/spage/api/component.rb', line 50 def delete(page_id:, id:) response = client.delete("pages/#{page_id}/components", id) handle_response(response) do true end end |
#find(page_id:, id:) ⇒ Object
22 23 24 25 26 27 28 |
# File 'lib/spage/api/component.rb', line 22 def find(page_id:, id:) response = client.get("pages/#{page_id}/components", id) handle_response(response) do Spage::Component.new(response.body) end end |
#update(component, page_id:, id:) ⇒ Object
40 41 42 43 44 45 46 47 48 |
# File 'lib/spage/api/component.rb', line 40 def update(component, page_id:, id:) json = Spage::Serializers::Component.new(component, update: true).to_json response = client.put("pages/#{page_id}/components", id, json) handle_response(response) do Spage::Component.new(response.body) end end |