instapaper-ts 1.1.2 → 1.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -95,9 +95,11 @@ declare class Instapaper {
95
95
  token?: OAuth.Token;
96
96
  });
97
97
  private makeRequest;
98
- private getAccessToken;
98
+ fetchToken: () => Promise<OAuth.Token>;
99
99
  private request;
100
100
  setCredentials: (username: string, password: string) => void;
101
+ withCredentials: (username: string, password: string) => this;
102
+ withToken: (token: OAuth.Token) => this;
101
103
  verifyCredentials: () => Promise<[User]>;
102
104
  bookmarks: {
103
105
  list: (params?: ListParams) => Promise<(Bookmark | Folder | User | Error | Meta)[]>;
package/dist/index.js CHANGED
@@ -59,7 +59,7 @@ var Instapaper = class {
59
59
  return response.text();
60
60
  }
61
61
  };
62
- getAccessToken = async () => {
62
+ fetchToken = async () => {
63
63
  assert(
64
64
  this.username && this.password,
65
65
  "Please set username and password with setCredentials()."
@@ -77,12 +77,11 @@ var Instapaper = class {
77
77
  key && secret,
78
78
  "There was an error fetching the token. One or both of key and secret is null."
79
79
  );
80
- this.token = { key, secret };
81
- return this.token;
80
+ return { key, secret };
82
81
  };
83
82
  request = async (endpoint, params = {}) => {
84
83
  if (!this.token) {
85
- this.token = await this.getAccessToken();
84
+ this.token = await this.fetchToken();
86
85
  }
87
86
  const url = this.baseUrl + endpoint;
88
87
  return this.makeRequest(url, params, this.token);
@@ -91,6 +90,14 @@ var Instapaper = class {
91
90
  this.username = username;
92
91
  this.password = password;
93
92
  };
93
+ withCredentials = (username, password) => {
94
+ this.setCredentials(username, password);
95
+ return this;
96
+ };
97
+ withToken = (token) => {
98
+ this.token = token;
99
+ return this;
100
+ };
94
101
  verifyCredentials = () => this.request("/1/account/verify_credentials");
95
102
  bookmarks = {
96
103
  list: (params = {}) => this.request(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "instapaper-ts",
3
- "version": "1.1.2",
3
+ "version": "1.1.3",
4
4
  "type": "module",
5
5
  "description": "A type-safe API client for Instapaper.",
6
6
  "main": "dist/index.js",