socialfi
Version:
Build social features into your app with ease
743 lines (742 loc) • 27.8 kB
JavaScript
/* eslint-disable */
/* tslint:disable */
/*
* ---------------------------------------------------------------
* ## THIS FILE WAS GENERATED VIA SWAGGER-TYPESCRIPT-API ##
* ## ##
* ## AUTHOR: acacode ##
* ## SOURCE: https://github.com/acacode/swagger-typescript-api ##
* ---------------------------------------------------------------
*/
import axios from 'axios';
export var ContentType;
(function (ContentType) {
ContentType["Json"] = "application/json";
ContentType["FormData"] = "multipart/form-data";
ContentType["UrlEncoded"] = "application/x-www-form-urlencoded";
ContentType["Text"] = "text/plain";
})(ContentType || (ContentType = {}));
export class HttpClient {
constructor({ securityWorker, secure, format, ...axiosConfig } = {}) {
this.securityData = null;
this.setSecurityData = (data) => {
this.securityData = data;
};
this.request = async ({ secure, path, type, query, format, body, ...params }) => {
const secureParams = ((typeof secure === 'boolean' ? secure : this.secure) &&
this.securityWorker &&
(await this.securityWorker(this.securityData))) ||
{};
const requestParams = this.mergeRequestParams(params, secureParams);
const responseFormat = format || this.format || undefined;
if (type === ContentType.FormData && body && body !== null && typeof body === 'object') {
body = this.createFormData(body);
}
if (type === ContentType.Text && body && body !== null && typeof body !== 'string') {
body = JSON.stringify(body);
}
return this.instance
.request({
...requestParams,
headers: {
...(requestParams.headers || {}),
...(type ? { 'Content-Type': type } : {}),
},
params: query,
responseType: responseFormat,
data: body,
url: path,
})
.then((response) => response.data);
};
this.instance = axios.create({
...axiosConfig,
baseURL: axiosConfig.baseURL || 'https://api.usetapestry.dev/api/v1',
});
this.secure = secure;
this.format = format;
this.securityWorker = securityWorker;
}
mergeRequestParams(params1, params2) {
const method = params1.method || (params2 && params2.method);
return {
...this.instance.defaults,
...params1,
...(params2 || {}),
headers: {
...((method &&
this.instance.defaults.headers[method.toLowerCase()]) ||
{}),
...(params1.headers || {}),
...((params2 && params2.headers) || {}),
},
};
}
stringifyFormItem(formItem) {
if (typeof formItem === 'object' && formItem !== null) {
return JSON.stringify(formItem);
}
else {
return `${formItem}`;
}
}
createFormData(input) {
if (input instanceof FormData) {
return input;
}
return Object.keys(input || {}).reduce((formData, key) => {
const property = input[key];
const propertyContent = property instanceof Array ? property : [property];
for (const formItem of propertyContent) {
const isFileType = formItem instanceof Blob || formItem instanceof File;
formData.append(key, isFileType ? formItem : this.stringifyFormItem(formItem));
}
return formData;
}, new FormData());
}
}
/**
* @title Tapestry API Reference
* @version 1.0.0
* @baseUrl https://api.usetapestry.dev/api/v1
*
* Documentation for all routes in the API
*/
export class SocialFi extends HttpClient {
constructor() {
super(...arguments);
this.profiles = {
/**
* @description For creating a user profile. The endpoint will first check to see if the wallet exists elsewhere on the graph. If it does, we will create a new profile that is namespaced to your app and associate with the wallet you pass in. If the wallet does not yet exist, we will create a node for the wallet, a node for the profile (namespaced to your app) and an edge indicating that the wallet you passed in is associated with the profile on your app.
*
* @tags Profiles
* @name FindOrCreateCreate
* @summary Find or create a profile
* @request POST:/profiles/findOrCreate
*/
findOrCreateCreate: (query, data, params = {}) => this.request({
path: `/profiles/findOrCreate`,
method: 'POST',
query: query,
body: data,
type: ContentType.Json,
format: 'json',
...params,
}),
/**
* No description
*
* @tags Profiles
* @name ProfilesList
* @summary Get profiles
* @request GET:/profiles/
*/
profilesList: (query, params = {}) => this.request({
path: `/profiles/`,
method: 'GET',
query: query,
format: 'json',
...params,
}),
/**
* @description Get comprehensive profile information including node details and follower/following counts
*
* @tags Profiles
* @name ProfilesDetail
* @summary Find a profile
* @request GET:/profiles/{id}
*/
profilesDetail: ({ id, ...query }, params = {}) => this.request({
path: `/profiles/${id}`,
method: 'GET',
query: query,
format: 'json',
...params,
}),
/**
* No description
*
* @tags Profiles
* @name ProfilesUpdate
* @summary Update a profile
* @request PUT:/profiles/{id}
*/
profilesUpdate: ({ id, ...query }, data, params = {}) => this.request({
path: `/profiles/${id}`,
method: 'PUT',
query: query,
body: data,
type: ContentType.Json,
format: 'json',
...params,
}),
/**
* @description Get a list of profiles that follow a user
*
* @tags Profiles
* @name FollowersDetail
* @summary Get followers
* @request GET:/profiles/{id}/followers
*/
followersDetail: ({ id, ...query }, params = {}) => this.request({
path: `/profiles/${id}/followers`,
method: 'GET',
query: query,
format: 'json',
...params,
}),
/**
* @description Get a list of profiles that follow a user across all connected wallets and contacts
*
* @tags Profiles
* @name FollowersGlobalDetail
* @summary Get global followers
* @request GET:/profiles/{id}/followers/global
*/
followersGlobalDetail: ({ id, ...query }, params = {}) => this.request({
path: `/profiles/${id}/followers/global`,
method: 'GET',
query: query,
format: 'json',
...params,
}),
/**
* @description Get a list of profiles that a user follows
*
* @tags Profiles
* @name FollowingDetail
* @summary Get following
* @request GET:/profiles/{id}/following
*/
followingDetail: ({ id, ...query }, params = {}) => this.request({
path: `/profiles/${id}/following`,
method: 'GET',
query: query,
format: 'json',
...params,
}),
/**
* @description Get a list of profiles that a user follows across all connected wallets and contacts
*
* @tags Profiles
* @name FollowingGlobalDetail
* @summary Get global following
* @request GET:/profiles/{id}/following/global
*/
followingGlobalDetail: ({ id, ...query }, params = {}) => this.request({
path: `/profiles/${id}/following/global`,
method: 'GET',
query: query,
format: 'json',
...params,
}),
/**
* @description Helpful for creating UIs like "this user is followed by {number} other users you follow"
*
* @tags Profiles
* @name FollowingWhoFollowDetail
* @summary Get a list of profiles in a user's network that also follow a given profile
* @request GET:/profiles/{id}/following-who-follow
*/
followingWhoFollowDetail: ({ id, ...query }, params = {}) => this.request({
path: `/profiles/${id}/following-who-follow`,
method: 'GET',
query: query,
format: 'json',
...params,
}),
/**
* @description Helpful for populating UIs like "people you may know"
*
* @tags Profiles
* @name SuggestedDetail
* @summary Get suggested profiles to follow
* @request GET:/profiles/suggested/{identifier}
*/
suggestedDetail: ({ identifier, ...query }, params = {}) => this.request({
path: `/profiles/suggested/${identifier}`,
method: 'GET',
query: query,
format: 'json',
...params,
}),
/**
* No description
*
* @tags Profiles
* @name SuggestedGlobalDetail
* @summary Get suggested profiles to invite
* @request GET:/profiles/suggested/{identifier}/global
*/
suggestedGlobalDetail: ({ identifier, ...query }, params = {}) => this.request({
path: `/profiles/suggested/${identifier}/global`,
method: 'GET',
query: query,
format: 'json',
...params,
}),
/**
* @description Retrieve all referral connections for a user profile, including both users who made referrals (upstream) and users who were referred (downstream) by this profile, with depth indicating the number of connection levels (defaults to 2, maximum 6). For example, depth=1 shows direct referrals, while depth=2 includes referrals made by those direct referrals.
*
* @tags Profiles
* @name ReferralsDetail
* @summary Retrieve referrals
* @request GET:/profiles/{id}/referrals
*/
referralsDetail: ({ id, ...query }, params = {}) => this.request({
path: `/profiles/${id}/referrals`,
method: 'GET',
query: query,
format: 'json',
...params,
}),
/**
* @description Get a list of profiles in the namespace that own a specific token. Optionally filter to only show profiles that the requesting user follows.
*
* @tags Profiles
* @name TokenOwnersDetail
* @summary Get profiles that own a specific token
* @request GET:/profiles/token-owners/{tokenAddress}
*/
tokenOwnersDetail: ({ tokenAddress, ...query }, params = {}) => this.request({
path: `/profiles/token-owners/${tokenAddress}`,
method: 'GET',
query: query,
format: 'json',
...params,
}),
};
this.followers = {
/**
* No description
*
* @tags Followers
* @name PostFollowers
* @summary Follow a profile
* @request POST:/followers/add
*/
postFollowers: (query, data, params = {}) => this.request({
path: `/followers/add`,
method: 'POST',
query: query,
body: data,
type: ContentType.Json,
format: 'json',
...params,
}),
/**
* No description
*
* @tags Followers
* @name RemoveCreate
* @summary Unfollow a profile
* @request POST:/followers/remove
*/
removeCreate: (query, data, params = {}) => this.request({
path: `/followers/remove`,
method: 'POST',
query: query,
body: data,
type: ContentType.Json,
format: 'json',
...params,
}),
/**
* @description Verifies if exists a FOLLOW edge between the startId and endId passed as query params.
*
* @tags Followers
* @name StateList
* @summary Is user following a specific profile
* @request GET:/followers/state
*/
stateList: (query, params = {}) => this.request({
path: `/followers/state`,
method: 'GET',
query: query,
format: 'json',
...params,
}),
};
this.contents = {
/**
* @description Filter and sort data using optional query parameters: 'filterField' with 'filterValue' to search by property (searches for null values if filterValue is omitted), 'requireFields' for a comma-separated list of properties that must not be null in results, and 'orderByField' with 'orderByDirection' (asc/desc) to sort the results.
*
* @tags Contents
* @name ContentsList
* @summary Get contents
* @request GET:/contents/
*/
contentsList: (query, params = {}) => this.request({
path: `/contents/`,
method: 'GET',
query: query,
format: 'json',
...params,
}),
/**
* No description
*
* @tags Contents
* @name ContentsDetail
* @summary Get content by id
* @request GET:/contents/{id}
*/
contentsDetail: ({ id, ...query }, params = {}) => this.request({
path: `/contents/${id}`,
method: 'GET',
query: query,
format: 'json',
...params,
}),
/**
* No description
*
* @tags Contents
* @name ContentsUpdate
* @summary Update content
* @request PUT:/contents/{id}
*/
contentsUpdate: ({ id, ...query }, data, params = {}) => this.request({
path: `/contents/${id}`,
method: 'PUT',
query: query,
body: data,
type: ContentType.Json,
format: 'json',
...params,
}),
/**
* No description
*
* @tags Contents
* @name ContentsDelete
* @summary Delete content
* @request DELETE:/contents/{id}
*/
contentsDelete: ({ id, ...query }, params = {}) => this.request({
path: `/contents/${id}`,
method: 'DELETE',
query: query,
format: 'json',
...params,
}),
/**
* No description
*
* @tags Contents
* @name FindOrCreateCreate
* @summary Find or create content
* @request POST:/contents/findOrCreate
*/
findOrCreateCreate: (query, data, params = {}) => this.request({
path: `/contents/findOrCreate`,
method: 'POST',
query: query,
body: data,
type: ContentType.Json,
format: 'json',
...params,
}),
/**
* No description
*
* @tags Contents
* @name BatchReadCreate
* @summary Get multiple contents
* @request POST:/contents/batch/read
*/
batchReadCreate: (query, data, params = {}) => this.request({
path: `/contents/batch/read`,
method: 'POST',
query: query,
body: data,
type: ContentType.Json,
format: 'json',
...params,
}),
};
this.comments = {
/**
* @description must filter by author (profileId), content (contentId), or target profile (targetProfileId)
*
* @tags Comments
* @name CommentsList
* @summary Get comments
* @request GET:/comments/
*/
commentsList: (query, params = {}) => this.request({
path: `/comments/`,
method: 'GET',
query: query,
format: 'json',
...params,
}),
/**
* No description
*
* @tags Comments
* @name CommentsCreate
* @summary Create comment
* @request POST:/comments/
*/
commentsCreate: (query, data, params = {}) => this.request({
path: `/comments/`,
method: 'POST',
query: query,
body: data,
type: ContentType.Json,
format: 'json',
...params,
}),
/**
* No description
*
* @tags Comments
* @name CommentsDetail
* @summary Get comment details
* @request GET:/comments/{id}
*/
commentsDetail: ({ id, ...query }, params = {}) => this.request({
path: `/comments/${id}`,
method: 'GET',
query: query,
format: 'json',
...params,
}),
/**
* No description
*
* @tags Comments
* @name CommentsUpdate
* @summary Update comment
* @request PUT:/comments/{id}
*/
commentsUpdate: ({ id, ...query }, data, params = {}) => this.request({
path: `/comments/${id}`,
method: 'PUT',
query: query,
body: data,
type: ContentType.Json,
format: 'json',
...params,
}),
/**
* No description
*
* @tags Comments
* @name CommentsDelete
* @summary Delete comment
* @request DELETE:/comments/{id}
*/
commentsDelete: ({ id, ...query }, params = {}) => this.request({
path: `/comments/${id}`,
method: 'DELETE',
query: query,
format: 'json',
...params,
}),
/**
* No description
*
* @tags Comments
* @name RepliesDetail
* @summary Get comment replies
* @request GET:/comments/{id}/replies
*/
repliesDetail: ({ id, ...query }, params = {}) => this.request({
path: `/comments/${id}/replies`,
method: 'GET',
query: query,
format: 'json',
...params,
}),
/**
* No description
*
* @tags Comments
* @name BatchReadCreate
* @summary Get multiple comment details
* @request POST:/comments/batch/read
*/
batchReadCreate: (query, data, params = {}) => this.request({
path: `/comments/batch/read`,
method: 'POST',
query: query,
body: data,
type: ContentType.Json,
format: 'json',
...params,
}),
};
this.likes = {
/**
* No description
*
* @tags Likes
* @name LikesCreate
* @summary Create like
* @request POST:/likes/{nodeId}
*/
likesCreate: ({ nodeId, ...query }, data, params = {}) => this.request({
path: `/likes/${nodeId}`,
method: 'POST',
query: query,
body: data,
type: ContentType.Json,
format: 'json',
...params,
}),
/**
* No description
*
* @tags Likes
* @name LikesDelete
* @summary Remove like
* @request DELETE:/likes/{nodeId}
*/
likesDelete: ({ nodeId, ...query }, data, params = {}) => this.request({
path: `/likes/${nodeId}`,
method: 'DELETE',
query: query,
body: data,
type: ContentType.Json,
format: 'json',
...params,
}),
};
this.wallets = {
/**
* @description This endpoint is restricted, talk to Tapestry to get access
*
* @tags Wallets
* @name ConnectCreate
* @summary Create a connection between two wallets
* @request POST:/wallets/{address}/connect
*/
connectCreate: ({ address, ...query }, data, params = {}) => this.request({
path: `/wallets/${address}/connect`,
method: 'POST',
query: query,
body: data,
type: ContentType.Json,
format: 'json',
...params,
}),
/**
* No description
*
* @tags Wallets
* @name SocialCountsDetail
* @summary Get socials counts for a given wallet
* @request GET:/wallets/{address}/socialCounts
*/
socialCountsDetail: ({ address, ...query }, params = {}) => this.request({
path: `/wallets/${address}/socialCounts`,
method: 'GET',
query: query,
format: 'json',
...params,
}),
};
this.search = {
/**
* @description Search for profiles by id or username
*
* @tags Search
* @name ProfilesList
* @summary Search profiles
* @request GET:/search/profiles
*/
profilesList: (query, params = {}) => this.request({
path: `/search/profiles`,
method: 'GET',
query: query,
format: 'json',
...params,
}),
};
this.notifications = {
/**
* @description only supports wallet notifications for now. recipient must be a wallet address
*
* @tags Notifications
* @name NotificationsCreate
* @summary Send a notification
* @request POST:/notifications/
*/
notificationsCreate: (query, data, params = {}) => this.request({
path: `/notifications/`,
method: 'POST',
query: query,
body: data,
type: ContentType.Json,
format: 'json',
...params,
}),
};
this.activity = {
/**
* @description Get activity feed for a user including follows, content, likes, comments and new followers
*
* @tags Activity
* @name FeedList
* @summary Get activity feed
* @request GET:/activity/feed
*/
feedList: (query, params = {}) => this.request({
path: `/activity/feed`,
method: 'GET',
query: query,
format: 'json',
...params,
}),
/**
* @description Get swap transactions from wallets that the user follows or for a specific token
*
* @tags Activity
* @name SwapList
* @summary Get swap activity from followed wallets or specific token
* @request GET:/activity/swap
*/
swapList: (query, params = {}) => this.request({
path: `/activity/swap`,
method: 'GET',
query: query,
format: 'json',
...params,
}),
};
this.identities = {
/**
* @description Retrieves all connected wallets/contacts associated with a specified wallet/contact. For each wallet/contact, returns up to 5 profiles. To retrieve the complete list of profiles for a specific wallet/contact, use the /identities/{id}/profiles endpoint
*
* @tags Identities
* @name IdentitiesDetail
* @summary Finds connected wallets/contacts from an id. this id should be a wallet address or a contact id. when using a contact id, specify the contactType via query params
* @request GET:/identities/{id}
*/
identitiesDetail: ({ id, ...query }, params = {}) => this.request({
path: `/identities/${id}`,
method: 'GET',
query: query,
format: 'json',
...params,
}),
/**
* @description This endpoint retrieves all profiles that were created by a specific wallet/contact.
*
* @tags Identities
* @name ProfilesDetail
* @summary Finds associated profiles across namespaces using a wallet address or a contact id. when using a contact id, specify the contactType via query params
* @request GET:/identities/{id}/profiles
*/
profilesDetail: ({ id, ...query }, params = {}) => this.request({
path: `/identities/${id}/profiles`,
method: 'GET',
query: query,
format: 'json',
...params,
}),
};
}
}