package otoggl
Bindings for Toggl API in OCaml
Install
Dune Dependency
Authors
Maintainers
Sources
dev-0.3.2.tbz
sha256=22ee2dc184836891b833d6791bea35f583e24bb2ce87ae4f6e5dcbdb272dc4c9
sha512=89508c18662001029e6d3707dae82edd67a17a7fecc200d7c0da3c4ac8f45b6676e0dec69483234f2170b31451f36735903c89e85cb2a713fe8a4df327964f74
doc/src/otoggl.lib/api.ml.html
Source file api.ml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144
open Types module F (Client : module type of Piaf.Client) = struct let create_client ?config () = Client.create ?config @@ Uri.of_string "https://api.track.toggl.com" module TimeEntry = struct open Lwt_result let create t (client : Client.t) = let body = {time_entry= t} |> string_of_wrapped_time_entry |> Piaf.Body.of_string in Client.post client ~body "/api/v8/time_entries" >>= Util.status_200_or_error >|= data_time_entry_of_string >|= fun x -> x.data let start t (client : Client.t) = let body = {time_entry= t} |> string_of_wrapped_time_entry |> Piaf.Body.of_string in Client.post client ~body "/api/v8/time_entries/start" >>= Util.status_200_or_error >|= data_time_entry_of_string >|= fun x -> x.data let stop (tid : tid) (client : Client.t) = let body = Piaf.Body.empty in "/api/v8/time_entries/" ^ string_of_int tid ^ "/stop" |> Client.put client ~body >>= Util.status_200_or_error >|= data_time_entry_of_string >|= fun x -> x.data let current (client : Client.t) = Client.get client "/api/v8/time_entries/current" >>= Util.status_200_or_error >|= data_time_entry_of_string >|= fun x -> x.data let details (tid : tid) (client : Client.t) = "/api/v8/time_entries/" ^ string_of_int tid |> Client.get client >>= Util.status_200_or_error >|= data_time_entry_of_string >|= fun x -> x.data let delete (tid : tid) (client : Client.t) = "/api/v8/time_entries/" ^ string_of_int tid |> Client.delete client >>= Util.status_200_or_error >|= tid_list_of_string let list ?start_date ?end_date (client : Client.t) = (* We will use timestamps set on UTC *) let tz_offset_s = 0 in let query = [] in let query = match end_date with | None -> query | Some date -> ("end_date", [Ptime.to_rfc3339 ~tz_offset_s date]) :: query in let query = match start_date with | None -> query | Some date -> ("start_date", [Ptime.to_rfc3339 ~tz_offset_s date]) :: query in Uri.make ~path:"/api/v8/time_entries" ~query () |> Uri.to_string |> Client.get client >>= Util.status_200_or_error >|= time_entry_list_of_string let update tid ?description ?start ?stop ?duration ? ?project ?workspace ?duronly ?billable (client : Client.t) = let time_entry = CCOption.( Types.create_time_entry_update_request ?description ?start ?stop ?duration ?tags ?pid:(project >|= function None -> None | Some p -> Some p.id) ?wid:(workspace >|= fun w -> w.id) ?duronly ?billable ()) in let body = create_wrapped_time_entry_update_request ~time_entry () |> string_of_wrapped_time_entry_update_request |> Piaf.Body.of_string in Client.put client ~body @@ "/api/v8/time_entries/" ^ string_of_int tid >>= Util.status_200_or_error >|= data_time_entry_of_string >|= fun x -> x.data end module Workspace = struct let list (client : Client.t) = let open Lwt_result in Client.get client "/api/v8/workspaces" >>= Util.status_200_or_error >|= workspace_list_of_string end module Project = struct open Lwt_result let list wid (client : Client.t) = let open Lwt_result in "/api/v8/workspaces/" ^ string_of_int wid ^ "/projects" |> Client.get client >>= Util.status_200_or_error >|= project_list_of_string let create t (client : Client.t) = let body = {project= t} |> string_of_wrapped_project_request |> Piaf.Body.of_string in Client.post client ~body "/api/v8/projects" >>= Util.status_200_or_error >|= data_project_of_string >|= fun x -> x.data let delete pid (client : Client.t) = "/api/v8/projects/" ^ string_of_int pid |> Client.delete client >>= Util.status_200_or_error >|= pid_list_of_string end end
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>