Module: Pixela::Client::GraphMethods
- Included in:
- Pixela::Client
- Defined in:
- lib/pixela/client/graph_methods.rb
Instance Method Summary collapse
-
#create_graph(graph_id:, name:, unit:, type:, color:) ⇒ Hashie::Mash
Create a new pixelation graph definition.
-
#delete_graph(graph_id) ⇒ Hashie::Mash
Delete the predefined pixelation graph definition.
-
#get_graphs ⇒ Array<Hashie::Mash>
Get all predefined pixelation graph definitions.
-
#graph_url(graph_id:, date: nil) ⇒ String
Get graph url.
-
#update_graph(graph_id:, name:, unit:, color:) ⇒ Hashie::Mash
Update predefined pixelation graph definitions.
Instance Method Details
#create_graph(graph_id:, name:, unit:, type:, color:) ⇒ Hashie::Mash
Create a new pixelation graph definition.
18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/pixela/client/graph_methods.rb', line 18 def create_graph(graph_id:, name:, unit:, type:, color:) params = { id: graph_id, name: name, unit: unit, type: type, color: color, } with_error_handling do connection.post("users/#{username}/graphs", params, user_token_headers).body end end |
#delete_graph(graph_id) ⇒ Hashie::Mash
Delete the predefined pixelation graph definition.
107 108 109 110 111 |
# File 'lib/pixela/client/graph_methods.rb', line 107 def delete_graph(graph_id) with_error_handling do connection.delete("users/#{username}/graphs/#{graph_id}", nil, user_token_headers).body end end |
#get_graphs ⇒ Array<Hashie::Mash>
Get all predefined pixelation graph definitions.
42 43 44 45 46 |
# File 'lib/pixela/client/graph_methods.rb', line 42 def get_graphs with_error_handling do connection.get("users/#{username}/graphs", nil, user_token_headers).body.graphs end end |
#graph_url(graph_id:, date: nil) ⇒ String
Get graph url
60 61 62 63 64 65 66 |
# File 'lib/pixela/client/graph_methods.rb', line 60 def graph_url(graph_id:, date: nil) url = "#{Pixela::Client::API_ENDPOINT}/users/#{username}/graphs/#{graph_id}" url << "?date=#{to_ymd(date)}" if date url end |
#update_graph(graph_id:, name:, unit:, color:) ⇒ Hashie::Mash
Update predefined pixelation graph definitions.
83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/pixela/client/graph_methods.rb', line 83 def update_graph(graph_id:, name:, unit:, color:) params = { name: name, unit: unit, color: color, } with_error_handling do connection.put("users/#{username}/graphs/#{graph_id}", params, user_token_headers).body end end |