beamsocial 0.1.5 → 0.2.0

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.
@@ -16,6 +16,7 @@ export declare class User {
16
16
  level: number;
17
17
  constructor(id: string, __token?: string, __url?: string);
18
18
  __load(data: Profile): void;
19
+ getPosts(): Promise<any>;
19
20
  follow(): Promise<void>;
20
21
  unfollow(): Promise<void>;
21
22
  block(): Promise<void>;
@@ -38,6 +38,38 @@ export class User {
38
38
  this.account_type = data.account_type;
39
39
  this.level = data.level;
40
40
  }
41
+ getPosts() {
42
+ return __awaiter(this, void 0, void 0, function* () {
43
+ try {
44
+ const res = yield axios.get(this.__url + `/posts`, {
45
+ headers: {
46
+ Authorization: `Bearer ${this.__token}`,
47
+ },
48
+ });
49
+ return res.data;
50
+ }
51
+ catch (err) {
52
+ if (axios.isAxiosError(err) && err.response) {
53
+ const res = err.response;
54
+ if (res.status == 401) {
55
+ throw new Error('Not logged in');
56
+ }
57
+ else if (res.status == 403) {
58
+ throw new Error('Private account');
59
+ }
60
+ else if (res.status == 404) {
61
+ throw new Error('User not found');
62
+ }
63
+ else {
64
+ throw new Error('Error following user');
65
+ }
66
+ }
67
+ else {
68
+ throw err;
69
+ }
70
+ }
71
+ });
72
+ }
41
73
  follow() {
42
74
  return __awaiter(this, void 0, void 0, function* () {
43
75
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "beamsocial",
3
- "version": "0.1.5",
3
+ "version": "0.2.0",
4
4
  "type": "module",
5
5
  "description": "API-wrapper pour Beam",
6
6
  "main": "index.js",