Skip to content

Latest commit

 

History

History
92 lines (67 loc) · 2.81 KB

readme.md

File metadata and controls

92 lines (67 loc) · 2.81 KB

libpocket

Async bindings to Pocket API (https://getpocket.com).

Authentication

Note down the POCKET_CONSUMER_KEY you can find in Pocket's "My Applications" dashboard. Retrieve a POCKET_AUTHORIZATION_CODE for your POCKET_CONSUMER_KEY by running the examples/auth.rs example program and following the instructions.

POCKET_CONSUMER_KEY="<your-pocket-consumer-key>" cargo run --example auth

Set and export the variables in your shell for convenience:

export POCKET_CONSUMER_KEY="<your-pocket-consumer-key>"
export POCKET_AUTHORIZATION_CODE="<your-pocket-authorization-code>"

Debugging

This library integrates with the log logging façade crate. You can get debug information by prepending RUST_LOG=DEBUG to executable invocations that use this library, like the example programs or the tests. For example, to run all tests with debug information and backtraces:

RUST_LOG=DEBUG RUST_BACKTRACE=1 cargo test

Sample commands to hit Pocket's API directly

These might prove useful to debug HTTP responses, or to interact with Pocket's API directly in shell script without having to use this library (they are using HTTPie):

http https://getpocket.com/v3/get \
  consumer_key="$POCKET_CONSUMER_KEY" \
  access_token="$POCKET_AUTHORIZATION_CODE" \
  state=all \
  detailType=complete \
  search="Ana Vidovic"
http https://getpocket.com/v3/send \
  consumer_key="$POCKET_CONSUMER_KEY" \
  access_token="$POCKET_AUTHORIZATION_CODE" \
  actions=[{action="add", time=0, url="https://www.rust-lang.org/"}]
http https://getpocket.com/v3/send < json_document.json

See Pocket's API documentation for more endpoints and parameters.

Testing

To run the unit tests, you need to have POCKET_CONSUMER_KEY set.

cargo test --lib

To run the integration tests, you need to have both POCKET_CONSUMER_KEY and POCKET_AUTHORIZATION_CODE set. Additionally, your Pocket account needs to:

  1. have the URL https://getpocket.com/developer/docs/v3/modify#action_archive in its reading list; and
  2. have the items pdf.json, blog.json, video.json, and https://getpocket.com/developer/docs/v3/modify#action_archive in its reading list (including their tags). Note that the timestamps and identifiers are from my Pocket test account, so you will have to change those after recreating the items in your account.
cargo test --test integration_tests

Credits