lecture-attendance-manager/app/lib/toggl.rb
Joshua Coles babbbf2be5
All checks were successful
Build and Publish Docker Container / build (push) Successful in 5m37s
Allow configuration of the service URLs by ENV variables
2023-10-07 14:56:13 +01:00

28 lines
862 B
Ruby

module Toggl
def self.entries_for_project(toggl_project_id, start_time:, end_time:)
JSON.parse(HTTParty.post(
"#{TOGGL_PORTAL_URL}/report",
body: {
"start_date": start_time.to_date.to_fs(),
"end_date": end_time.to_date.to_fs(),
"project_ids": [toggl_project_id]
}.to_json,
headers: { 'Content-Type' => 'application/json', 'Accept' => 'application/json' }
).body)
end
def self.start_time_entry(description:, project_id:)
HTTParty.post(
"#{TOGGL_PORTAL_URL}/start_time_entry",
body: {
"created_with": "Attendance Tracker",
"description": description,
"start": Time.now.utc.iso8601,
"duration": -1,
"project_id": project_id,
}.to_json,
headers: { 'Content-Type' => 'application/json', 'Accept' => 'application/json' }
)
end
end