@sollinked/sdk
Advanced tools
Comparing version 1.2.2 to 1.2.3
import { ApiResult, AuthCallParams } from "../../types"; | ||
import { ContentCNFT } from "../ContentPass/types"; | ||
import { HomepageUser, PublicUser, User, UserCreateParams, UserUpdateParams } from "./types"; | ||
import { HomepageUser, PublicUser, User, UserCreateParams, UserUpdateParams, UserUpdateTagParams } from "./types"; | ||
export declare const create: (params: UserCreateParams) => Promise<string | import("axios").AxiosResponse<ApiResult<User>, any>>; | ||
@@ -9,3 +9,5 @@ export declare const me: (params: AuthCallParams) => Promise<string | import("axios").AxiosResponse<ApiResult<User>, any>>; | ||
export declare const search: (username: string) => Promise<string | import("axios").AxiosResponse<ApiResult<HomepageUser[]>, any>>; | ||
export declare const searchAddress: (address: string) => Promise<string | import("axios").AxiosResponse<ApiResult<HomepageUser>, any>>; | ||
export declare const update: (id: number, params: UserUpdateParams) => Promise<string | import("axios").AxiosResponse<ApiResult<undefined>, any>>; | ||
export declare const updateTags: (id: number, params: UserUpdateTagParams) => Promise<string | import("axios").AxiosResponse<ApiResult<undefined>, any>>; | ||
export declare const getHomepageUsers: () => Promise<string | import("axios").AxiosResponse<ApiResult<HomepageUser[]>, any>>; |
@@ -44,2 +44,10 @@ import axios from '../Services/axios.js'; | ||
}; | ||
export const searchAddress = async (address) => { | ||
try { | ||
return await axios.get(`/user/searchAddress/${address}`); | ||
} | ||
catch (e) { | ||
return e.response.data; | ||
} | ||
}; | ||
export const update = async (id, params) => { | ||
@@ -77,2 +85,11 @@ try { | ||
}; | ||
export const updateTags = async (id, params) => { | ||
try { | ||
return await axios.post(`/user/updateTags/${id}`, params); | ||
} | ||
catch (e) { | ||
console.log(e); | ||
return e.response.data; | ||
} | ||
}; | ||
export const getHomepageUsers = async () => { | ||
@@ -79,0 +96,0 @@ try { |
@@ -35,2 +35,3 @@ import { AuthCallParams } from "../../types"; | ||
is_verified: boolean; | ||
tags?: UserTag[]; | ||
}; | ||
@@ -53,2 +54,6 @@ export interface UserCreateParams extends AuthCallParams { | ||
} | ||
export interface UserUpdateTagParams extends AuthCallParams { | ||
tags: string[]; | ||
hash: string; | ||
} | ||
export type PublicUser = { | ||
@@ -71,4 +76,6 @@ id: number; | ||
is_verified: boolean; | ||
tags?: UserTag[]; | ||
}; | ||
export type HomepageUser = { | ||
id: number; | ||
username: string; | ||
@@ -79,2 +86,7 @@ display_name: string; | ||
is_verified: boolean; | ||
tags?: UserTag[]; | ||
}; | ||
export type UserTag = { | ||
user_id: number; | ||
name: string; | ||
}; |
@@ -1,3 +0,3 @@ | ||
export declare const SOLLINKED_BACKEND_URL = "https://api.sollinked.com"; | ||
export declare const SOLLINKED_BACKEND_URL = "http://localhost:8081"; | ||
export declare const RESERVATION_STATUS_BLOCKED = -1; | ||
export declare const RESERVATION_STATUS_AVAILABLE = 0; |
@@ -1,3 +0,3 @@ | ||
export const SOLLINKED_BACKEND_URL = "https://api.sollinked.com"; | ||
export const SOLLINKED_BACKEND_URL = "http://localhost:8081"; | ||
export const RESERVATION_STATUS_BLOCKED = -1; | ||
export const RESERVATION_STATUS_AVAILABLE = 0; |
@@ -107,3 +107,3 @@ import { jsx as _jsx } from "react/jsx-runtime"; | ||
if (!auth.address || !auth.message || !signature) { | ||
return; | ||
throw new UninitializedError(); | ||
} | ||
@@ -138,3 +138,3 @@ let { address, message } = auth; | ||
if (!auth.address || !auth.message || !signature) { | ||
return; | ||
throw new UninitializedError(); | ||
} | ||
@@ -149,2 +149,17 @@ let { address, message } = auth; | ||
}, [user, auth, signature, me]); | ||
const updateAccountTags = useCallback(async (params) => { | ||
if (!user) { | ||
throw new UninitializedError(); | ||
} | ||
if (!auth.address || !auth.message || !signature) { | ||
throw new UninitializedError(); | ||
} | ||
let { address, message } = auth; | ||
let res = await account.updateTags(user.id, { address, message, signature, ...params }); | ||
if (typeof res === 'string') { | ||
return res; | ||
} | ||
await me(); | ||
return res; | ||
}, [user, auth, signature, me]); | ||
const getHomepageUsers = useCallback(async () => { | ||
@@ -170,2 +185,12 @@ let res = await account.getHomepageUsers(); | ||
}, []); | ||
const searchUserAddress = useCallback(async (address) => { | ||
let res = await account.searchAddress(address); | ||
if (typeof res === 'string') { | ||
return res; | ||
} | ||
if (!res.data.data) { | ||
return "Unable to get user"; | ||
} | ||
return res.data.data; | ||
}, []); | ||
const getUser = useCallback(async (username) => { | ||
@@ -186,3 +211,3 @@ let res = await account.get(username); | ||
if (!auth.address || !auth.message || !signature) { | ||
return; | ||
throw new UninitializedError(); | ||
} | ||
@@ -202,3 +227,3 @@ let { address, message } = auth; | ||
if (!auth.address || !auth.message || !signature) { | ||
return; | ||
throw new UninitializedError(); | ||
} | ||
@@ -218,3 +243,3 @@ let { address, message } = auth; | ||
if (!auth.address || !auth.message || !signature) { | ||
return; | ||
throw new UninitializedError(); | ||
} | ||
@@ -248,3 +273,3 @@ let { address, message } = auth; | ||
if (!auth.address || !auth.message || !signature) { | ||
return; | ||
throw new UninitializedError(); | ||
} | ||
@@ -266,3 +291,3 @@ let { address, message } = auth; | ||
if (!auth.address || !auth.message || !signature) { | ||
return; | ||
throw new UninitializedError(); | ||
} | ||
@@ -289,3 +314,3 @@ let { address, message } = auth; | ||
if (!auth.address || !auth.message || !signature) { | ||
return; | ||
throw new UninitializedError(); | ||
} | ||
@@ -305,3 +330,3 @@ let { address, message } = auth; | ||
if (!auth.address || !auth.message || !signature) { | ||
return; | ||
throw new UninitializedError(); | ||
} | ||
@@ -321,3 +346,3 @@ let { address, message } = auth; | ||
if (!auth.address || !auth.message || !signature) { | ||
return; | ||
throw new UninitializedError(); | ||
} | ||
@@ -337,3 +362,3 @@ let { address, message } = auth; | ||
if (!auth.address || !auth.message || !signature) { | ||
return; | ||
throw new UninitializedError(); | ||
} | ||
@@ -353,3 +378,3 @@ let { address, message } = auth; | ||
if (!auth.address || !auth.message || !signature) { | ||
return; | ||
throw new UninitializedError(); | ||
} | ||
@@ -368,3 +393,3 @@ let { address, message } = auth; | ||
if (!auth.address || !auth.message || !signature) { | ||
return; | ||
throw new UninitializedError(); | ||
} | ||
@@ -383,3 +408,3 @@ let { address, message } = auth; | ||
if (!auth.address || !auth.message || !signature) { | ||
return; | ||
throw new UninitializedError(); | ||
} | ||
@@ -399,3 +424,3 @@ let { address, message } = auth; | ||
if (!auth.address || !auth.message || !signature) { | ||
return; | ||
throw new UninitializedError(); | ||
} | ||
@@ -417,3 +442,3 @@ let { address, message } = auth; | ||
if (!auth.address || !auth.message || !signature) { | ||
return; | ||
throw new UninitializedError(); | ||
} | ||
@@ -433,3 +458,3 @@ let { address, message } = auth; | ||
if (!auth.address || !auth.message || !signature) { | ||
return; | ||
throw new UninitializedError(); | ||
} | ||
@@ -448,3 +473,3 @@ let { address, message } = auth; | ||
if (!auth.address || !auth.message || !signature) { | ||
return; | ||
throw new UninitializedError(); | ||
} | ||
@@ -463,3 +488,3 @@ let { address, message } = auth; | ||
if (!auth.address || !auth.message || !signature) { | ||
return; | ||
throw new UninitializedError(); | ||
} | ||
@@ -479,3 +504,3 @@ let { address, message } = auth; | ||
if (!auth.address || !auth.message || !signature) { | ||
return; | ||
throw new UninitializedError(); | ||
} | ||
@@ -495,3 +520,3 @@ let { address, message } = auth; | ||
if (!auth.address || !auth.message || !signature) { | ||
return; | ||
throw new UninitializedError(); | ||
} | ||
@@ -509,3 +534,3 @@ let { address, message } = auth; | ||
if (!auth.address || !auth.message || !signature) { | ||
return; | ||
throw new UninitializedError(); | ||
} | ||
@@ -525,3 +550,3 @@ let { address, message } = auth; | ||
if (!auth.address || !auth.message || !signature) { | ||
return; | ||
throw new UninitializedError(); | ||
} | ||
@@ -541,3 +566,3 @@ let { address, message } = auth; | ||
if (!auth.address || !auth.message || !signature) { | ||
return; | ||
throw new UninitializedError(); | ||
} | ||
@@ -556,3 +581,3 @@ let { address, message } = auth; | ||
if (!auth.address || !auth.message || !signature) { | ||
return; | ||
throw new UninitializedError(); | ||
} | ||
@@ -572,3 +597,3 @@ let { address, message } = auth; | ||
if (!auth.address || !auth.message || !signature) { | ||
return; | ||
throw new UninitializedError(); | ||
} | ||
@@ -594,3 +619,3 @@ let { address, message } = auth; | ||
if (!auth.address || !auth.message || !signature) { | ||
return; | ||
throw new UninitializedError(); | ||
} | ||
@@ -610,3 +635,3 @@ let { address, message } = auth; | ||
if (!auth.address || !auth.message || !signature) { | ||
return; | ||
throw new UninitializedError(); | ||
} | ||
@@ -626,3 +651,3 @@ let { address, message } = auth; | ||
if (!auth.address || !auth.message || !signature) { | ||
return; | ||
throw new UninitializedError(); | ||
} | ||
@@ -642,3 +667,3 @@ let { address, message } = auth; | ||
if (!auth.address || !auth.message || !signature) { | ||
return; | ||
throw new UninitializedError(); | ||
} | ||
@@ -664,3 +689,3 @@ let { address, message } = auth; | ||
if (!auth.address || !auth.message || !signature) { | ||
return; | ||
throw new UninitializedError(); | ||
} | ||
@@ -680,3 +705,3 @@ let { address, message } = auth; | ||
if (!auth.address || !auth.message || !signature) { | ||
return; | ||
throw new UninitializedError(); | ||
} | ||
@@ -715,5 +740,7 @@ let { address, message } = auth; | ||
update: updateAccount, | ||
updateTags: updateAccountTags, | ||
getHomepageUsers, | ||
get: getUser, | ||
search: searchUser, | ||
searchAddress: searchUserAddress, | ||
}, | ||
@@ -720,0 +747,0 @@ mail: { |
import { ReactNode } from "react"; | ||
import { HomepageUser, PublicUser, User, UserUpdateParams } from "./src/Account/types"; | ||
import { HomepageUser, PublicUser, User, UserUpdateParams, UserUpdateTagParams } from "./src/Account/types"; | ||
import { UpdateIntegrationParams } from "./src/Integration/types"; | ||
@@ -45,5 +45,7 @@ import { ReserveCalendarParams, UpdateUserReservationParams, UserReservation, UserReservationSetting } from "./src/Calendar/types"; | ||
update: (params: Omit<UserUpdateParams, keyof AuthCallParams>) => Promise<string | AxiosResponse<ApiResult<undefined>, any> | undefined>; | ||
updateTags: (params: Omit<UserUpdateTagParams, keyof AuthCallParams>) => Promise<string | AxiosResponse<ApiResult<undefined>, any> | undefined>; | ||
getHomepageUsers: () => Promise<string | HomepageUser[]>; | ||
get: (username: string) => Promise<string | PublicUser>; | ||
search: (username: string) => Promise<string | HomepageUser[]>; | ||
searchAddress: (address: string) => Promise<string | HomepageUser>; | ||
}; | ||
@@ -50,0 +52,0 @@ mail?: { |
{ | ||
"name": "@sollinked/sdk", | ||
"version": "1.2.2", | ||
"version": "1.2.3", | ||
"description": "SDK for Sollinked", | ||
@@ -5,0 +5,0 @@ "main": "./dist/index.js", |
import { ApiResult, AuthCallParams } from "../../types"; | ||
import { ContentCNFT } from "../ContentPass/types"; | ||
import axios from '../Services/axios.js'; | ||
import { HomepageUser, PublicUser, User, UserCreateParams, UserUpdateParams } from "./types"; | ||
import { HomepageUser, PublicUser, User, UserCreateParams, UserUpdateParams, UserUpdateTagParams } from "./types"; | ||
import _ from 'lodash'; | ||
@@ -62,2 +62,12 @@ | ||
export const searchAddress = async(address: string) => { | ||
try { | ||
return await axios.get<ApiResult<HomepageUser>>(`/user/searchAddress/${address}`); | ||
} | ||
catch(e: any) { | ||
return e.response.data as string; | ||
} | ||
} | ||
// update personal details | ||
@@ -106,2 +116,14 @@ export const update = async(id: number, params: UserUpdateParams) => { | ||
// update personal details | ||
export const updateTags = async(id: number, params: UserUpdateTagParams) => { | ||
try { | ||
return await axios.post<ApiResult<undefined>>(`/user/updateTags/${id}`, params); | ||
} | ||
catch(e: any) { | ||
console.log(e); | ||
return e.response.data as string; | ||
} | ||
} | ||
// public functions | ||
@@ -108,0 +130,0 @@ export const getHomepageUsers = async() => { |
@@ -36,2 +36,3 @@ import { AuthCallParams } from "../../types"; | ||
is_verified: boolean; | ||
tags?: UserTag[]; | ||
} | ||
@@ -57,2 +58,7 @@ | ||
export interface UserUpdateTagParams extends AuthCallParams { | ||
tags: string[]; | ||
hash: string; | ||
} | ||
export type PublicUser = { | ||
@@ -75,5 +81,7 @@ id: number; | ||
is_verified: boolean; | ||
tags?: UserTag[]; | ||
} | ||
export type HomepageUser = { | ||
id: number; | ||
username: string; | ||
@@ -84,2 +92,8 @@ display_name: string; | ||
is_verified: boolean; | ||
tags?: UserTag[]; | ||
} | ||
export type UserTag = { | ||
user_id: number; | ||
name: string; | ||
} |
@@ -1,4 +0,4 @@ | ||
export const SOLLINKED_BACKEND_URL = "https://api.sollinked.com"; | ||
// export const SOLLINKED_BACKEND_URL = "http://localhost:8081"; | ||
// export const SOLLINKED_BACKEND_URL = "https://api.sollinked.com"; | ||
export const SOLLINKED_BACKEND_URL = "http://localhost:8081"; | ||
export const RESERVATION_STATUS_BLOCKED = -1; | ||
export const RESERVATION_STATUS_AVAILABLE = 0; |
import { ReactNode } from "react"; | ||
import { HomepageUser, PublicUser, User, UserUpdateParams } from "./src/Account/types"; | ||
import { HomepageUser, PublicUser, User, UserUpdateParams, UserUpdateTagParams } from "./src/Account/types"; | ||
import { UpdateIntegrationParams } from "./src/Integration/types"; | ||
@@ -50,5 +50,7 @@ import { ReserveCalendarParams, UpdateUserReservationParams, UserReservation, UserReservationSetting } from "./src/Calendar/types"; | ||
update: (params: Omit<UserUpdateParams, keyof AuthCallParams>) => Promise<string | AxiosResponse<ApiResult<undefined>, any> | undefined>; | ||
updateTags: (params: Omit<UserUpdateTagParams, keyof AuthCallParams>) => Promise<string | AxiosResponse<ApiResult<undefined>, any> | undefined>; | ||
getHomepageUsers: () => Promise<string | HomepageUser[]>; | ||
get: (username: string) => Promise<string | PublicUser>; | ||
search: (username: string) => Promise<string | HomepageUser[]>; | ||
searchAddress: (address: string) => Promise<string | HomepageUser>; | ||
}, | ||
@@ -55,0 +57,0 @@ mail?: { |
Sorry, the diff of this file is not supported yet
158938
4155