diff options
author | HJ <thechairman@thechairman.info> | 2024-02-03 15:10:00 -0500 |
---|---|---|
committer | HJ <thechairman@thechairman.info> | 2024-02-03 15:10:00 -0500 |
commit | 0c869b2782aeecb92dff232b46a499a3821f9f2c (patch) | |
tree | 8010032bf495ad120a4d586a7a96ebc9139e3f32 /aoc2023/build/packages/adglent/src/priv/aoc_client.gleam | |
parent | 96a3c5c179d8d3fff24eb2953e45f8dd15e2714c (diff) | |
download | gleam_aoc-0c869b2782aeecb92dff232b46a499a3821f9f2c.tar.gz gleam_aoc-0c869b2782aeecb92dff232b46a499a3821f9f2c.zip |
cleanup
Diffstat (limited to 'aoc2023/build/packages/adglent/src/priv/aoc_client.gleam')
-rw-r--r-- | aoc2023/build/packages/adglent/src/priv/aoc_client.gleam | 37 |
1 files changed, 0 insertions, 37 deletions
diff --git a/aoc2023/build/packages/adglent/src/priv/aoc_client.gleam b/aoc2023/build/packages/adglent/src/priv/aoc_client.gleam deleted file mode 100644 index e18bafa..0000000 --- a/aoc2023/build/packages/adglent/src/priv/aoc_client.gleam +++ /dev/null @@ -1,37 +0,0 @@ -import gleam/result.{try} -import gleam/httpc -import gleam/http/request -import gleam/int -import gleam/string - -pub fn get_input( - year: String, - day: String, - session: String, -) -> Result(String, String) { - let url = "https://adventofcode.com/" <> year <> "/day/" <> day <> "/input" - use request <- try( - request.to(url) - |> result.map_error(fn(error) { - "Could not create request for \"" <> url <> "\": " <> string.inspect( - error, - ) - }), - ) - - // Send the HTTP request to the server - use response <- try( - request - |> request.prepend_header("Accept", "application/json") - |> request.prepend_header("Cookie", "session=" <> session <> ";") - |> httpc.send - |> result.map_error(fn(error) { - "Error when requesting \"" <> url <> "\": " <> string.inspect(error) - }), - ) - - case response.status { - status if status >= 200 && status < 300 -> Ok(response.body) - status -> Error(int.to_string(status) <> " - " <> response.body) - } -} |