pinafore/routes/_api/user.js

20 lines
811 B
JavaScript
Raw Normal View History

import { get, paramsString, DEFAULT_TIMEOUT } from '../_utils/ajax'
2018-02-24 23:49:28 +01:00
import { auth, basename } from './utils'
2018-01-13 23:19:51 +01:00
2018-02-09 07:29:29 +01:00
export function getVerifyCredentials (instanceName, accessToken) {
let url = `${basename(instanceName)}/api/v1/accounts/verify_credentials`
return get(url, auth(accessToken), {timeout: DEFAULT_TIMEOUT})
2018-01-23 06:16:27 +01:00
}
2018-02-09 07:29:29 +01:00
export function getAccount (instanceName, accessToken, accountId) {
2018-01-23 06:16:27 +01:00
let url = `${basename(instanceName)}/api/v1/accounts/${accountId}`
return get(url, auth(accessToken), {timeout: DEFAULT_TIMEOUT})
2018-01-28 21:51:48 +01:00
}
2018-02-09 07:29:29 +01:00
export async function getRelationship (instanceName, accessToken, accountId) {
2018-01-28 21:51:48 +01:00
let url = `${basename(instanceName)}/api/v1/accounts/relationships`
url += '?' + paramsString({id: accountId})
let res = await get(url, auth(accessToken), {timeout: DEFAULT_TIMEOUT})
2018-01-28 21:51:48 +01:00
return res[0]
2018-02-09 07:29:29 +01:00
}