pocket_client 0.1.2

  • README.md
  • CHANGELOG.md
  • Example
  • Installing
  • Versions
  • 0

Pub Package Build Status Coverage Status Github Issues

pocket_client

A library for authenticating and accessing the Pocket API from Dart

Quick start

Authentication:
import 'package:pocket_client/pocket_client.dart';

const consumerKey = '1234-abcd1234abcd1234abcd1234';
const redirectUrl = 'http://some.redirect.uri/autorizationFinished';

main() async {
  var authentication = new ClientAuthentication(consumerKey);

  var requestToken = await authentication.getRequestToken(redirectUrl);
  var url = ClientAuthentication.getAuthorizeUrl(requestToken, redirectUrl);
  // work whatever redirect magic you need here

  //..

  var userData = await authentication.getAccessToken(requestToken);
  onAuthorizationFinished(userData.accessToken);
} 

onAuthorizationFinished(String accessToken) {
  // now you have everything to communicate with Pocket 
}
Working with Pocket:
import 'package:pocket_client/pocket_client.dart';

const consumerKey = '1234-abcd1234abcd1234abcd1234';
const accessToken = '5678defg-5678-defg-5678-defg56';

main() async {
  var client = new Client(consumerKey, accessToken);

  var options = new RetrieveOptions()
    ..since = new DateTime(2015, 5, 4)
    ..search = 'Some search query'
    ..domain = 'http://domain.test'
    ..contentType = ContentType.video
    ..detailType = DetailType.complete
    ..isFavorite = true
    ..sortType = SortType.site
    ..state = State.all
    ..tag = 'cats'
    ..count = 100
    ..offset = 10;

  var response = await client.getData(options: options);
  Map<String, PocketData> items = response.items;
  // do whatever you want with pocket items

  var newItem = new ItemToAdd('http://www.funnycatpix.com/')
    ..title = 'FUNNY CAT PICTURES'
    ..tweetId = '123456'
    ..tags = ['cats', 'cool', 'share'];

  PocketData data = await client.addItem(newItem);
  // do whatever you want with received data
}

Api

See the Api documentation.

Examples

The basic example is in example file

Features and bugs

Please fill feature requests and bugs at the issue tracker.

License

pocket_client is distributed under the BSD license.

Changelog

0.1.2

  • Enabled strong mode and linting, fixed related problems

0.1.1

  • Fixed typo in documentation

0.1.0

  • Initial version, created by Ne4istb

example/pocket_client.dart

// Copyright (c) 2015, Ne4istb. All rights reserved. Use of this source code

// is governed by a BSD-style license that can be found in the LICENSE file.

library pocket_client.example;

import 'package:pocket_client/pocket_client.dart';

const consumerKey = '1234-abcd1234abcd1234abcd1234';
const redirectUrl = 'http://some.redirect.uri/autorizationFinished';
const accessToken = '5678defg-5678-defg-5678-defg56';

main() async {
  var authentication = new ClientAuthentication(consumerKey);

  var requestToken = await authentication.getRequestToken(redirectUrl);
  var url = ClientAuthentication.getAuthorizeUrl(requestToken, redirectUrl);
  // work whatever redirect magic you need here

  //..

  var userData = await authentication.getAccessToken(requestToken);
  onAuthorizationFinished(userData.accessToken);
}

onAuthorizationFinished(String accessToken) async {
  var client = new Client(consumerKey, accessToken);

  var options = new RetrieveOptions()
    ..since = new DateTime(2015, 5, 4)
    ..search = 'Some search query'
    ..domain = 'http://domain.test'
    ..contentType = ContentType.video
    ..detailType = DetailType.complete
    ..isFavorite = true
    ..sortType = SortType.site
    ..state = State.all
    ..tag = 'cats'
    ..count = 100
    ..offset = 10;

  var response = await client.getData(options: options);
  Map<String, PocketData> items = response.items;
  // do whatever you want with pocket items

  var newItem = new ItemToAdd('http://www.funnycatpix.com/')
    ..title = 'FUNNY CAT PICTURES'
    ..tweetId = '123456'
    ..tags = ['cats', 'cool', 'share'];

  PocketData data = await client.addItem(newItem);
  // do whatever you want with received data
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  pocket_client: ^0.1.2

2. Install it

You can install packages from the command line:

with pub:


$ pub get

Alternatively, your editor might support pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:pocket_client/pocket_client.dart';
  
Version Uploaded Documentation Archive
0.1.2 Jan 15, 2017 Go to the documentation of pocket_client 0.1.2 Download pocket_client 0.1.2 archive
0.1.1 Oct 5, 2015 Go to the documentation of pocket_client 0.1.1 Download pocket_client 0.1.1 archive
0.1.0 Oct 5, 2015 Go to the documentation of pocket_client 0.1.0 Download pocket_client 0.1.0 archive
Popularity:
Describes how popular the package is relative to other packages. [more]
0
Health:
Code health derived from static analysis. [more]
1
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
0
Overall:
Weighted score of the above. [more]
0
Learn more about scoring.

We analyzed this package on Oct 10, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.0.0
  • pana: 0.12.4

Platforms

Detected platforms: unsure

Low code quality prevents platform classification.

Health issues and suggestions

Fix lib/src/client.dart. (-68.52 points)

Analysis of lib/src/client.dart failed with 4 errors, 1 hint:

line 36 col 60: Undefined name 'JSON'.

line 41 col 60: Undefined name 'JSON'.

line 53 col 23: Undefined name 'JSON'.

line 74 col 23: Undefined name 'JSON'.

line 7 col 8: Unused import: 'dart:convert'.

Fix lib/src/client_authentication.dart. (-58.02 points)

Analysis of lib/src/client_authentication.dart failed with 3 errors, 1 hint:

line 29 col 23: Undefined name 'JSON'.

line 31 col 69: Undefined name 'JSON'.

line 41 col 23: Undefined name 'JSON'.

line 7 col 8: Unused import: 'dart:convert'.

Fix lib/src/actions.dart. (-25.38 points)

Analysis of lib/src/actions.dart failed with 1 error, 1 hint:

line 10 col 33: Undefined name 'JSON'.

line 3 col 8: Unused import: 'dart:convert'.

Fix additional 10 files with analysis or formatting issues. (-177.66 points)

Additional issues in the following files:

  • lib/src/author.dart (1 error, 1 hint)
  • lib/src/image_data.dart (1 error, 1 hint)
  • lib/src/pocket_data.dart (1 error, 1 hint)
  • lib/src/pocket_response.dart (1 error, 1 hint)
  • lib/src/tag.dart (1 error, 1 hint)
  • lib/src/user.dart (1 error, 1 hint)
  • lib/src/video_data.dart (1 error, 1 hint)
  • lib/src/client_base.dart (Run dartfmt to format lib/src/client_base.dart.)
  • lib/src/item_to_add.dart (Run dartfmt to format lib/src/item_to_add.dart.)
  • lib/src/retrieve_options.dart (Run dartfmt to format lib/src/retrieve_options.dart.)

Maintenance issues and suggestions

Fix platform conflicts. (-20 points)

Low code quality prevents platform classification.

Use analysis_options.yaml. (-10 points)

Rename old .analysis_options file to analysis_options.yaml.

Read more about the setup of analysis-options.yaml.

Package is getting outdated. (-73.42 points)

The package was released 90 weeks ago.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.21.0
http >=0.11.3+2 <0.12.0 0.11.3+17 0.12.0
Transitive dependencies
async 2.0.8
charcode 1.1.2
collection 1.14.11
http_parser 3.1.3
meta 1.1.6
path 1.6.2
source_span 1.4.1
string_scanner 1.0.4
typed_data 1.1.6
Dev dependencies
test >=0.12.0 <0.13.0