[![Version](https://img.shields.io/crates/v/aoc_api)](https://crates.io/crates/aoc_api)
[![Downloads](https://img.shields.io/crates/d/aoc_api)](https://crates.io/crates/aoc_api)
a simple [Advent of Code](https://adventofcode.com) API written in Rust - also checkout the [C# version](https://github.com/antoniosubasic/AoC.API)
## Documentation
- [Add Crate](#add-crate)
- [Session initialization](#session-initialization)
- [Features](#features)
- [Get input](#get-input)
- [Get sample input](#get-sample-input)
- [Get achieved stars](#get-achieved-stars)
- [Submit answer](#submit-answer)
# Add Crate
```bash
cargo add aoc_api
```
```rust
use aoc_api::Session;
```
# Session initialization
```rust
let client = Session::new("session cookie": String, year: u16, day: u8); // Initializes a new Session instance
```
```rust
let client = Session::new("session cookie": String, input: String, pattern: Regex); // Initializes a new Session instance
```
>
> The Regex overload needs to have a regex group named "year" and a group named "day".
> How to name Regex groups
> How to obtain session cookie
# Features
## Get input
```rust
let input_text: Result> = client.get_input_text().await; // Retrieves the input text of the AoC puzzle
let input_lines: Result, Box> = client.get_input_lines().await; // Retrieves the input lines of the AoC puzzle
```
## Get sample input
```rust
let sample_input_text: Result> = client.get_sample_input_text(nth: u8).await; // Retrieves the nth sample input text of the AoC puzzle
let sample_input_lines: Result, Box> = client.get_sample_input_lines(nth: u8).await; // Retrieves the nth sample input lines of the AoC puzzle
```
## Get achieved stars
```rust
let achieved_stars: Result, Box> = client.get_all_stars().await; // Retrieves each year's number of stars earned (key: year, value: stars)
```
## Submit answer
```rust
let response: Result> = client.submit_answer(part: u8, answer: &str).await; // Submits an answer to part 1 or 2 of the AoC puzzle. Returns a response type with a success status and a cooldown period
```
*credits to:*
> [Max](https://github.com/Mqxx) - markdown info icons
> [Monday Morning Haskell](https://mmhaskell.com/) - documentation on how to obtaining session cookie
> [Developer.Mozilla](https://developer.mozilla.org) - documentation on how to name Regex groups