Skip to content

Commit

Permalink
refactoring, fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
misha-krainik committed Jan 4, 2024
1 parent f64c77c commit 8f08968
Show file tree
Hide file tree
Showing 13 changed files with 435 additions and 353 deletions.
1 change: 1 addition & 0 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ jobs:
- uses: actions/checkout@v3
- name: Build
run: cargo build --verbose --release

6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "getpocket"
version = "0.2.3"
version = "0.2.5-rc1"
edition = "2021"
description = "Rust API for https://getpocket.com/"
license = "AGPL-3.0-only"
Expand All @@ -14,11 +14,11 @@ unstable = []

[dependencies]
anyhow = "1"
async-trait = "0.1.68"
async-trait = "0.1"
reqwest = { version = "0.11", features = ["json"] }
serde = { version = "1", features = ["derive"] }
serde_json = "1"
thiserror = "1.0.40"
thiserror = "1"
tokio = { version = "1", features = ["full"] }

[[example]]
Expand Down
50 changes: 32 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
### GetPocket API crate
# GetPocket API crate

Official GetPocket API docs
https://getpocket.com/developer/docs/overview

[![Build](https://github.com/mikhail-krainik/getpocket/actions/workflows/rust.yml/badge.svg)](https://github.com/mikhail-krainik/getpocket/actions/workflows/rust.yml)

```rust
use getpocket;
```

License: AGPL-3.0-only

Crates.io
Expand All @@ -17,14 +13,19 @@ https://crates.io/crates/getpocket
Documentation
https://docs.rs/getpocket/latest/getpocket/

##### Tutorial
### Tutorial

```shell
$ cargo add getpocket
cargo add getpocket
```

```rust
use getpocket::{adding::AddingExt, GetPocket};
```

The GetPocket token can be obtained through the built-in `GetPocket::init` method, or you can use the ready-made method for executing requests.

##### List of items
### List of items

```rust
fn main() {
Expand All @@ -39,7 +40,8 @@ fn main() {
dbg!(&get_pocket.list_of_items().await.unwrap());
}
```
##### Response: List of items

### Response: List of items

```rust
RecordItem {
Expand Down Expand Up @@ -78,7 +80,8 @@ RecordItem {
},
}
```
##### Add new item

### Add new item

```rust
fn main() {
Expand All @@ -93,7 +96,8 @@ fn main() {
dbg!(&get_pocket.add_item("https://getpocket.com/developer/docs/v3/add").await.unwrap());
}
```
##### Response: Add new item

### Response: Add new item

```rust
RecordAdded {
Expand Down Expand Up @@ -138,7 +142,8 @@ RecordAdded {
status: 1,
}
```
##### Access token

### Access token

``` rust
async fn main() {
Expand All @@ -157,7 +162,8 @@ async fn main() {
.expect("Cannot init GetPocket instance");
}
```
##### Possible use case

### Possible use case

```rust
extern crate getpocket;
Expand Down Expand Up @@ -226,7 +232,8 @@ async fn init_get_pocket() -> GetPocket {
get_pocket
}
```
#### Archive item

### Archive item

```rust

Expand All @@ -251,7 +258,8 @@ async fn main() {
.unwrap());
}
```
##### Response: Archive item

### Response: Archive item

```rust
RecordModified {
Expand All @@ -261,13 +269,19 @@ RecordModified {
status: 1,
}
```
##### Run other examples

### Run other examples

```shell
$ cargo run --example list
cargo run --example list
```

#### Dependencies
```shell
cargo run --example add
```

### Dependencies

* tokio
* reqwest
* async-trait0
Expand Down
4 changes: 3 additions & 1 deletion examples/add.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
extern crate getpocket;

use getpocket::{adding::AddingExt, GetPocket};

#[path = "../tests/test_helper.rs"]
mod lib;

#[tokio::main]
async fn main() {
let get_pocket = lib::init_get_pocket().await;
let get_pocket: GetPocket = lib::init_get_pocket().await;

dbg!(&get_pocket
.add_item("https://getpocket.com/developer/docs/v3/add")
Expand Down
4 changes: 3 additions & 1 deletion examples/modify.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
extern crate getpocket;

use getpocket::{modifying::ModifyingExt, GetPocket};

#[path = "../tests/test_helper.rs"]
mod lib;

#[tokio::main]
async fn main() {
let get_pocket = lib::init_get_pocket().await;
let get_pocket: GetPocket = lib::init_get_pocket().await;

/*
[
Expand Down
Loading

0 comments on commit 8f08968

Please sign in to comment.