Module: Pixela::Client::PixelMethods
- Included in:
- Pixela::Client
- Defined in:
- lib/pixela/client/pixel_methods.rb
Instance Method Summary collapse
-
#create_pixel(graph_id:, date: Date.today, quantity:) ⇒ Hashie::Mash
It records the quantity of the specified date as a "Pixel".
-
#decrement_pixel(graph_id:) ⇒ Hashie::Mash
Decrement quantity "Pixel" of the day (UTC).
-
#delete_pixel(graph_id:, date: Date.today) ⇒ Hashie::Mash
Delete the registered "Pixel".
-
#get_pixel(graph_id:, date: Date.today) ⇒ Hashie::Mash
Get registered quantity as "Pixel".
-
#increment_pixel(graph_id:) ⇒ Hashie::Mash
Increment quantity "Pixel" of the day (UTC).
-
#update_pixel(graph_id:, date: Date.today, quantity:) ⇒ Hashie::Mash
Update the quantity already registered as a "Pixel".
Instance Method Details
#create_pixel(graph_id:, date: Date.today, quantity:) ⇒ Hashie::Mash
It records the quantity of the specified date as a "Pixel".
16 17 18 19 20 21 22 23 24 25 |
# File 'lib/pixela/client/pixel_methods.rb', line 16 def create_pixel(graph_id:, date: Date.today, quantity:) params = { date: to_ymd(date), quantity: quantity.to_s, } with_error_handling do connection.post("users/#{username}/graphs/#{graph_id}", params, user_token_headers).body end end |
#decrement_pixel(graph_id:) ⇒ Hashie::Mash
Decrement quantity "Pixel" of the day (UTC).
119 120 121 122 123 |
# File 'lib/pixela/client/pixel_methods.rb', line 119 def decrement_pixel(graph_id:) with_error_handling do connection.put("users/#{username}/graphs/#{graph_id}/decrement", nil, user_token_headers).body end end |
#delete_pixel(graph_id:, date: Date.today) ⇒ Hashie::Mash
Delete the registered "Pixel".
83 84 85 86 87 |
# File 'lib/pixela/client/pixel_methods.rb', line 83 def delete_pixel(graph_id:, date: Date.today) with_error_handling do connection.delete("users/#{username}/graphs/#{graph_id}/#{to_ymd(date)}", nil, user_token_headers).body end end |
#get_pixel(graph_id:, date: Date.today) ⇒ Hashie::Mash
Get registered quantity as "Pixel".
40 41 42 43 44 |
# File 'lib/pixela/client/pixel_methods.rb', line 40 def get_pixel(graph_id:, date: Date.today) with_error_handling do connection.get("users/#{username}/graphs/#{graph_id}/#{to_ymd(date)}", nil, user_token_headers).body end end |
#increment_pixel(graph_id:) ⇒ Hashie::Mash
Increment quantity "Pixel" of the day (UTC).
101 102 103 104 105 |
# File 'lib/pixela/client/pixel_methods.rb', line 101 def increment_pixel(graph_id:) with_error_handling do connection.put("users/#{username}/graphs/#{graph_id}/increment", nil, user_token_headers).body end end |
#update_pixel(graph_id:, date: Date.today, quantity:) ⇒ Hashie::Mash
Update the quantity already registered as a "Pixel".
60 61 62 63 64 65 66 67 68 |
# File 'lib/pixela/client/pixel_methods.rb', line 60 def update_pixel(graph_id:, date: Date.today, quantity:) params = { quantity: quantity.to_s, } with_error_handling do connection.put("users/#{username}/graphs/#{graph_id}/#{to_ymd(date)}", params, user_token_headers).body end end |