#mapping #entities #api #models #client #harvest #crops

crops_api_models

Unofficial mapping of the Harvest API entities

2 releases

0.1.1 Oct 29, 2024
0.1.0 Oct 29, 2024

#1 in #harvest

Download history 229/week @ 2024-10-28 29/week @ 2024-11-04

258 downloads per month
Used in crops_api_client

MIT license

33KB
434 lines

Crops API Models

Unofficial mapping of the Harvest API entities

Install

$ cargo add crops_api_models

Usage

use reqwest::{
    Method,
    blocking::{
        Client,
        Response,
    }
};

use harvest_api_models::UserMe;

fn main() {
    let bearer = "...";
    let acc_id = "...";
    let url = "https://api.harvestapp.com/v2/users/me";
    let method = Method::from_bytes("GET".as_bytes()).unwrap();
    let resp: Response = Client::new()
        .request(method, url)
        .header("Authorization", format!("Bearer {}", bearer))
        .header("Harvest-Account-Id", acc_id)
        .header("User-Agent", "harvest-api-models rust example")
        .send()
        .unwrap();
    let model: UserMe = resp.json().unwrap();
    println!("json: {:?}", model)
}

License

The MIT License (MIT)

Copyright © 2023 Ramon Moraes

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Dependencies

~1.3–2.1MB
~39K SLoC