This repository has been archived by the owner on Mar 19, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add methods to get followers and followings
- Loading branch information
Showing
3 changed files
with
129 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import agent from '../structures/agent' | ||
|
||
const getFollowers = async (profile, opts) => { // NOTE: opts = Number | Object; | ||
'use strict' | ||
|
||
if (typeof opts === 'number') { | ||
opts = { | ||
userId: opts | ||
} | ||
} | ||
|
||
opts = opts || {} | ||
|
||
const response = await agent( | ||
'/get_followers', | ||
{ | ||
query: { | ||
user_id: opts.userId || -1, | ||
page_size: opts.size || 50, | ||
page: opts.page || 1 | ||
} | ||
}, | ||
{ | ||
...profile, | ||
userId: '(null)' | ||
} | ||
) | ||
const data = await response.json() | ||
|
||
return data | ||
} | ||
|
||
export default getFollowers | ||
|
||
export const specification = { | ||
count: Number, | ||
next: Number, | ||
previous: Number, | ||
success: Boolean, | ||
users: [ | ||
{ | ||
bio: String, | ||
last_active_minutes: Number, | ||
name: String, | ||
photo_url: String, | ||
twitter: String, | ||
user_id: Number, | ||
username: String | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
import agent from '../structures/agent' | ||
|
||
const getFollowings = async (profile, opts) => { // NOTE: opts = Number | Object; | ||
'use strict' | ||
|
||
if (typeof opts === 'number') { | ||
opts = { | ||
userId: opts | ||
} | ||
} | ||
|
||
opts = opts || {} | ||
|
||
const response = await agent( | ||
'/get_followings', | ||
{ | ||
query: { | ||
user_id: opts.userId || -1, | ||
page_size: opts.size || 50, | ||
page: opts.page || 1 | ||
} | ||
}, | ||
{ | ||
...profile, | ||
userId: '(null)' | ||
} | ||
) | ||
const data = await response.json() | ||
|
||
return data | ||
} | ||
|
||
export default getFollowings | ||
|
||
export const specification = { | ||
clubs: [ | ||
{ | ||
club_id: Number, | ||
description: String, | ||
enable_private: Boolean, | ||
is_admin: Number, // Numeric-bool | ||
is_community: Boolean, | ||
is_follow_allowed: Boolean, | ||
is_membership_private: Boolean, | ||
name: String, | ||
num_followers: Number, | ||
num_members: Number, | ||
num_online: Number, | ||
photo_url: String, | ||
rules: [ | ||
{ | ||
desc: String, | ||
title: String | ||
} | ||
] | ||
} | ||
], | ||
count: Number, | ||
next: Number, | ||
previous: Number, | ||
success: Boolean, | ||
users: [ | ||
{ | ||
bio: String, | ||
last_active_minutes: Number, | ||
name: String, | ||
photo_url: String, | ||
twitter: String, | ||
user_id: Number, | ||
username: String | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters