1110 lines
46 KiB
JavaScript
1110 lines
46 KiB
JavaScript
(function (root, factory) {
|
||
if (typeof module === 'object' && module.exports) {
|
||
module.exports = factory(root);
|
||
return;
|
||
}
|
||
|
||
root.GenealogyApi = factory(root);
|
||
})(typeof globalThis !== 'undefined' ? globalThis : window, function (root) {
|
||
'use strict';
|
||
|
||
var DEFAULT_CLIENT_ID = 'ced7e5f0498645c6ec642dcf450b036f';
|
||
var DEFAULT_TENANT_ID = '000000';
|
||
var DEFAULT_TOKEN_KEY = 'genealogy_auth_token';
|
||
var VERIFICATION_OPERATION_CODES = [
|
||
'password-login',
|
||
'sms-login',
|
||
'register',
|
||
'forgot-password',
|
||
'phone-change',
|
||
'account-deactivate'
|
||
];
|
||
var SMS_OPERATION_CODES = [
|
||
'sms-login',
|
||
'register',
|
||
'forgot-password',
|
||
'phone-change',
|
||
'account-deactivate'
|
||
];
|
||
|
||
function loadNodeModule(path) {
|
||
if (typeof require !== 'function') return null;
|
||
|
||
try {
|
||
return require(path);
|
||
} catch (error) {
|
||
return null;
|
||
}
|
||
}
|
||
|
||
function getConfigApi() {
|
||
var configFactory;
|
||
|
||
if (root.GenealogyConfig) return root.GenealogyConfig;
|
||
configFactory = loadNodeModule('../config.js');
|
||
return configFactory ? configFactory(root) : null;
|
||
}
|
||
|
||
function getStorageUtil() {
|
||
return root.StorageUtil || loadNodeModule('./StorageUtil.js');
|
||
}
|
||
|
||
function getAxiosRequestUtil() {
|
||
return root.AxiosRequestUtil || loadNodeModule('./AxiosRequestUtil.js');
|
||
}
|
||
|
||
function getStorage(store) {
|
||
if (store) return store;
|
||
|
||
try {
|
||
return root.localStorage;
|
||
} catch (error) {
|
||
return null;
|
||
}
|
||
}
|
||
|
||
function getTokenFromResponse(data) {
|
||
return data && data.access_token || '';
|
||
}
|
||
|
||
function pickDefined(source, allowedFields) {
|
||
var input = source || {};
|
||
var result = {};
|
||
|
||
allowedFields.forEach(function (field) {
|
||
if (input[field] !== undefined) result[field] = input[field];
|
||
});
|
||
return result;
|
||
}
|
||
|
||
function createChunkFormData(bodyOrFormData) {
|
||
var FormDataCtor = root.FormData;
|
||
var source = bodyOrFormData || {};
|
||
var formData;
|
||
|
||
if (FormDataCtor && bodyOrFormData instanceof FormDataCtor) return bodyOrFormData;
|
||
if (!FormDataCtor) throw new Error('当前环境不支持文件上传');
|
||
|
||
formData = new FormDataCtor();
|
||
formData.append('uploadId', source.uploadId);
|
||
formData.append('chunkIndex', source.chunkIndex);
|
||
formData.append('chunkMd5', source.chunkMd5);
|
||
formData.append('file', source.file);
|
||
return formData;
|
||
}
|
||
|
||
function buildApiUrl(baseUrl, path, query) {
|
||
var url = String(baseUrl || '').replace(/\/+$/, '') + '/' + String(path || '').replace(/^\/+/, '');
|
||
var params = new URLSearchParams();
|
||
|
||
Object.keys(query || {}).forEach(function (key) {
|
||
var value = query[key];
|
||
if (value !== undefined && value !== null && value !== '') params.append(key, value);
|
||
});
|
||
|
||
return params.toString() ? url + '?' + params.toString() : url;
|
||
}
|
||
|
||
function createClient(options) {
|
||
var settings = options || {};
|
||
var configApi = getConfigApi();
|
||
var config = configApi && configApi.getConfig ? configApi.getConfig() : {};
|
||
var storageUtil = getStorageUtil();
|
||
var axiosRequestUtil = getAxiosRequestUtil();
|
||
var store = getStorage(settings.tokenStore || settings.storage);
|
||
var clientId = settings.clientId || config.clientId || DEFAULT_CLIENT_ID;
|
||
var tenantId = settings.tenantId || config.tenantId || DEFAULT_TENANT_ID;
|
||
var tokenKey = settings.tokenKey || config.tokenKey || DEFAULT_TOKEN_KEY;
|
||
var baseUrl = settings.baseUrl || config.apiBaseUrl;
|
||
var requester;
|
||
|
||
if (!axiosRequestUtil || !axiosRequestUtil.createRequester) throw new Error('缺少 AxiosRequestUtil.createRequester');
|
||
if (!baseUrl) throw new Error('缺少接口基础地址');
|
||
|
||
function getToken() {
|
||
return storageUtil && storageUtil.read ? storageUtil.read(store, tokenKey) || '' : '';
|
||
}
|
||
|
||
function setToken(token) {
|
||
if (token && storageUtil && storageUtil.write) storageUtil.write(store, tokenKey, token);
|
||
}
|
||
|
||
function clearToken() {
|
||
if (storageUtil && storageUtil.remove) storageUtil.remove(store, tokenKey);
|
||
}
|
||
|
||
requester = axiosRequestUtil.createRequester({
|
||
baseUrl: baseUrl,
|
||
clientId: clientId,
|
||
getToken: getToken,
|
||
onUnauthorized: clearToken,
|
||
axiosInstance: settings.axiosInstance || root.axios
|
||
});
|
||
|
||
function request(method, path, requestOptions) {
|
||
// 请求函数保持私有,页面只能调用下方已在接口文档中定义的业务方法。
|
||
return requester(method, path, requestOptions || {});
|
||
}
|
||
|
||
function withTenant(body) {
|
||
return Object.assign({}, body || {}, { tenantId: tenantId });
|
||
}
|
||
|
||
function buildVerificationPath(operationCode, suffix) {
|
||
return '/genealogy/pc/auth/verification/' +
|
||
toRequiredOperationCode(operationCode, 'PC 认证动作', VERIFICATION_OPERATION_CODES) +
|
||
(suffix || '');
|
||
}
|
||
|
||
function buildSmsCodePath(operationCode) {
|
||
return '/genealogy/pc/auth/sms/' +
|
||
toRequiredOperationCode(operationCode, 'PC 短信认证动作', SMS_OPERATION_CODES) +
|
||
'/code';
|
||
}
|
||
|
||
function toRequiredPathId(value, label) {
|
||
if (typeof value === 'number' && !Number.isSafeInteger(value)) {
|
||
throw new Error('无效' + label);
|
||
}
|
||
var text = String(value === undefined || value === null ? '' : value).trim();
|
||
|
||
if (!text) throw new Error('缺少' + label);
|
||
return encodeURIComponent(text);
|
||
}
|
||
|
||
function toRequiredOperationCode(value, label, allowedValues) {
|
||
var text = String(value === undefined || value === null ? '' : value).trim();
|
||
|
||
if (!text) throw new Error('缺少' + label);
|
||
if (allowedValues.indexOf(text) === -1) throw new Error('不支持的' + label + ':' + text);
|
||
return encodeURIComponent(text);
|
||
}
|
||
|
||
function buildFeedPath(genealogyId, suffix) {
|
||
// 家族圈接口统一由家谱编号定位,避免页面拼接出未定义的请求路径。
|
||
return '/genealogy/pc/genealogies/' + toRequiredPathId(genealogyId, '家谱编号') + '/feeds' + (suffix || '');
|
||
}
|
||
|
||
function buildFeedDetailPath(genealogyId, feedId, suffix) {
|
||
return buildFeedPath(genealogyId, '/' + toRequiredPathId(feedId, '动态编号') + (suffix || ''));
|
||
}
|
||
|
||
function buildFeedCommentPath(genealogyId, feedId, commentId) {
|
||
var path = buildFeedDetailPath(genealogyId, feedId, '/comments');
|
||
|
||
return commentId === undefined || commentId === null || commentId === ''
|
||
? path
|
||
: path + '/' + toRequiredPathId(commentId, '评论编号');
|
||
}
|
||
|
||
function buildFeedReplyPath(genealogyId, feedId, commentId, suffix) {
|
||
return buildFeedCommentPath(genealogyId, feedId, commentId) + '/replies' + (suffix || '');
|
||
}
|
||
|
||
function buildGenerationPoemPath(genealogyId, suffix) {
|
||
return '/genealogy/pc/genealogies/' + toRequiredPathId(genealogyId, '家谱编号') + '/generation-poems' + (suffix || '');
|
||
}
|
||
|
||
function buildLineagePath(genealogyId, suffix) {
|
||
return '/genealogy/pc/genealogies/' + toRequiredPathId(genealogyId, '家谱编号') + '/lineage' + (suffix || '');
|
||
}
|
||
|
||
function buildLineagePersonPath(genealogyId, personId, suffix) {
|
||
return buildLineagePath(
|
||
genealogyId,
|
||
'/persons/' + toRequiredPathId(personId, '人物编号') + (suffix || '')
|
||
);
|
||
}
|
||
|
||
function buildGrowthRecordPath(genealogyId, recordId) {
|
||
var path = '/genealogy/pc/genealogies/' + toRequiredPathId(genealogyId, '家谱编号') + '/growth-records';
|
||
|
||
return recordId === undefined || recordId === null || recordId === ''
|
||
? path
|
||
: path + '/' + toRequiredPathId(recordId, '成长记录编号');
|
||
}
|
||
|
||
function buildRelativeRecordPath(genealogyId, relativeId) {
|
||
var path = '/genealogy/pc/genealogies/' + toRequiredPathId(genealogyId, '家谱编号') + '/relative-records';
|
||
|
||
return relativeId === undefined || relativeId === null || relativeId === ''
|
||
? path
|
||
: path + '/' + toRequiredPathId(relativeId, '亲友记录编号');
|
||
}
|
||
|
||
function buildMemoPath(genealogyId, memoId) {
|
||
var path = '/genealogy/pc/genealogies/' + toRequiredPathId(genealogyId, '家谱编号') + '/memos';
|
||
|
||
return memoId === undefined || memoId === null || memoId === ''
|
||
? path
|
||
: path + '/' + toRequiredPathId(memoId, '备忘录编号');
|
||
}
|
||
|
||
function buildMeritRecordPath(genealogyId, meritId) {
|
||
var path = '/genealogy/pc/genealogies/' + toRequiredPathId(genealogyId, '家谱编号') + '/merit-records';
|
||
|
||
return meritId === undefined || meritId === null || meritId === ''
|
||
? path
|
||
: path + '/' + toRequiredPathId(meritId, '功德记录编号');
|
||
}
|
||
|
||
function buildArticleCollectionPath(genealogyId) {
|
||
return '/genealogy/pc/genealogies/' + toRequiredPathId(genealogyId, '家谱编号') + '/articles';
|
||
}
|
||
|
||
function buildArticlePath(genealogyId, articleId) {
|
||
return buildArticleCollectionPath(genealogyId) + '/' + toRequiredPathId(articleId, '谱文编号');
|
||
}
|
||
|
||
function buildAlbumCollectionPath(genealogyId) {
|
||
return '/genealogy/pc/genealogies/' + toRequiredPathId(genealogyId, '家谱编号') + '/albums';
|
||
}
|
||
|
||
function buildAlbumPath(genealogyId, albumId) {
|
||
return buildAlbumCollectionPath(genealogyId) + '/' + toRequiredPathId(albumId, '相册编号');
|
||
}
|
||
|
||
function buildAlbumPhotoCollectionPath(genealogyId, albumId) {
|
||
return buildAlbumPath(genealogyId, albumId) + '/photos';
|
||
}
|
||
|
||
function buildAlbumPhotoPath(genealogyId, albumId, photoId) {
|
||
return buildAlbumPhotoCollectionPath(genealogyId, albumId) + '/' + toRequiredPathId(photoId, '相册照片编号');
|
||
}
|
||
|
||
function buildVideoCollectionPath(genealogyId) {
|
||
return '/genealogy/pc/genealogies/' + toRequiredPathId(genealogyId, '家谱编号') + '/videos';
|
||
}
|
||
|
||
function buildVideoPath(genealogyId, videoId) {
|
||
return buildVideoCollectionPath(genealogyId) + '/' + toRequiredPathId(videoId, '视频编号');
|
||
}
|
||
|
||
function buildCeremonyCollectionPath(genealogyId) {
|
||
return '/genealogy/pc/genealogies/' + toRequiredPathId(genealogyId, '家谱编号') + '/ceremonies';
|
||
}
|
||
|
||
function buildCeremonyPath(genealogyId, ceremonyId) {
|
||
return buildCeremonyCollectionPath(genealogyId) + '/' + toRequiredPathId(ceremonyId, '祭祀活动编号');
|
||
}
|
||
|
||
function buildCeremonyGiftPath(genealogyId, ceremonyId, giftId) {
|
||
return buildCeremonyPath(genealogyId, ceremonyId) + '/gifts/' + toRequiredPathId(giftId, '祭品编号');
|
||
}
|
||
|
||
function buildGenealogyMemberCollectionPath(genealogyId) {
|
||
return '/genealogy/pc/genealogies/' + toRequiredPathId(genealogyId, '家谱编号') + '/members';
|
||
}
|
||
|
||
function buildGenealogyMemberPath(genealogyId, memberId) {
|
||
return buildGenealogyMemberCollectionPath(genealogyId) + '/' + toRequiredPathId(memberId, '成员编号');
|
||
}
|
||
|
||
async function login(body) {
|
||
var data = await request('POST', '/genealogy/pc/auth/login', {
|
||
auth: false,
|
||
body: Object.assign(
|
||
pickDefined(body, ['phone', 'password', 'validToken']),
|
||
{ grantType: 'password', tenantId: tenantId }
|
||
)
|
||
});
|
||
var token = getTokenFromResponse(data);
|
||
|
||
if (!token) throw new Error('登录响应缺少 token');
|
||
setToken(token);
|
||
return data;
|
||
}
|
||
|
||
async function loginBySms(body) {
|
||
var data = await request('POST', '/genealogy/pc/auth/login/sms', {
|
||
auth: false,
|
||
body: Object.assign(
|
||
pickDefined(body, ['phone', 'smsCode']),
|
||
{ grantType: 'sms', tenantId: tenantId }
|
||
)
|
||
});
|
||
var token = getTokenFromResponse(data);
|
||
|
||
if (!token) throw new Error('登录响应缺少 token');
|
||
setToken(token);
|
||
return data;
|
||
}
|
||
|
||
async function deactivateAccount(body) {
|
||
var data = await request('POST', '/genealogy/pc/auth/account/deactivate', {
|
||
body: pickDefined(body, ['smsCode'])
|
||
});
|
||
clearToken();
|
||
return data;
|
||
}
|
||
|
||
async function logout() {
|
||
try {
|
||
return await request('DELETE', '/genealogy/pc/auth/logout');
|
||
} finally {
|
||
clearToken();
|
||
}
|
||
}
|
||
|
||
return {
|
||
clientId: clientId,
|
||
tenantId: tenantId,
|
||
tokenKey: tokenKey,
|
||
getToken: getToken,
|
||
setToken: setToken,
|
||
clearToken: clearToken,
|
||
buildApiUrl: function (path, query) {
|
||
return buildApiUrl(baseUrl, path, query);
|
||
},
|
||
register: function (body) {
|
||
return request('POST', '/genealogy/pc/auth/register', {
|
||
auth: false,
|
||
body: Object.assign(
|
||
pickDefined(body, ['phone', 'password', 'nickName', 'smsCode']),
|
||
{ grantType: 'password', tenantId: tenantId, registerSource: 'PC' }
|
||
)
|
||
});
|
||
},
|
||
login: login,
|
||
loginBySms: loginBySms,
|
||
sendSmsCode: function (operationCode, body) {
|
||
return request('POST', buildSmsCodePath(operationCode), {
|
||
auth: false,
|
||
// PC 认证目录以路径 operationCode 绑定动作;clientid 只由请求头提供。
|
||
body: Object.assign(
|
||
pickDefined(body, ['phone', 'validToken']),
|
||
{ grantType: 'sms', tenantId: tenantId }
|
||
)
|
||
});
|
||
},
|
||
currentProfile: function () {
|
||
return request('GET', '/genealogy/pc/auth/profile');
|
||
},
|
||
updateProfile: function (body) {
|
||
return request('PUT', '/genealogy/pc/auth/profile', {
|
||
body: pickDefined(body, ['nickName', 'realName', 'avatar', 'sex', 'birthday', 'email'])
|
||
});
|
||
},
|
||
changePassword: function (body) {
|
||
return request('PUT', '/genealogy/pc/auth/password', {
|
||
body: pickDefined(body, ['oldPassword', 'newPassword'])
|
||
});
|
||
},
|
||
resetPassword: function (body) {
|
||
return request('PUT', '/genealogy/pc/auth/password/reset', {
|
||
auth: false,
|
||
body: Object.assign(
|
||
pickDefined(body, ['phone', 'smsCode', 'newPassword']),
|
||
{ grantType: 'password', tenantId: tenantId }
|
||
)
|
||
});
|
||
},
|
||
changePhone: function (body) {
|
||
return request('PUT', '/genealogy/pc/auth/phone', {
|
||
body: pickDefined(body, ['phone', 'smsCode'])
|
||
});
|
||
},
|
||
deactivateAccount: deactivateAccount,
|
||
logout: logout,
|
||
initResumableUpload: function (body) {
|
||
return request('POST', '/genealogy/pc/files/resumable/init', { body: body });
|
||
},
|
||
uploadResumableChunk: function (bodyOrFormData) {
|
||
return request('POST', '/genealogy/pc/files/resumable/chunk', {
|
||
body: createChunkFormData(bodyOrFormData)
|
||
});
|
||
},
|
||
completeResumableUpload: function (body) {
|
||
return request('POST', '/genealogy/pc/files/resumable/complete', { body: body });
|
||
},
|
||
captchaRequirement: function (operationCode, query) {
|
||
var source = query || {};
|
||
|
||
return request('GET', buildVerificationPath(operationCode, '/require'), {
|
||
auth: false,
|
||
query: {
|
||
tenantId: source.tenantId || tenantId,
|
||
subject: source.subject
|
||
}
|
||
});
|
||
},
|
||
captchaChallenge: function (operationCode, body) {
|
||
return request('POST', buildVerificationPath(operationCode, '/challenge'), {
|
||
auth: false,
|
||
body: withTenant(pickDefined(body, ['subject']))
|
||
});
|
||
},
|
||
captchaVerify: function (operationCode, body) {
|
||
return request('POST', buildVerificationPath(operationCode, '/verify'), {
|
||
auth: false,
|
||
body: withTenant(pickDefined(body, [
|
||
'subject',
|
||
'challengeId',
|
||
'providerCode',
|
||
'captchaType',
|
||
'payload'
|
||
]))
|
||
});
|
||
},
|
||
captchaChallengeUrl: function (operationCode) {
|
||
return buildApiUrl(baseUrl, buildVerificationPath(operationCode, '/challenge'));
|
||
},
|
||
captchaVerifyUrl: function (operationCode) {
|
||
return buildApiUrl(baseUrl, buildVerificationPath(operationCode, '/verify'));
|
||
},
|
||
regionChildren: function (parentCode) {
|
||
return request('GET', '/genealogy/pc/region/children', { query: { parentCode: parentCode } });
|
||
},
|
||
regionPath: function (regionCode) {
|
||
return request('GET', '/genealogy/pc/region/path/' + encodeURIComponent(regionCode));
|
||
},
|
||
regionSearch: function (query) {
|
||
return request('GET', '/genealogy/pc/region/search', { query: query });
|
||
},
|
||
regionDetail: function (regionCode) {
|
||
return request('GET', '/genealogy/pc/region/' + encodeURIComponent(regionCode));
|
||
},
|
||
genealogyQuota: function () {
|
||
return request('GET', '/genealogy/pc/genealogies/quota');
|
||
},
|
||
genealogiesMine: function () {
|
||
return request('GET', '/genealogy/pc/genealogies/mine');
|
||
},
|
||
businessDictionary: function (dictType) {
|
||
return request('GET', '/genealogy/pc/dictionaries/' +
|
||
toRequiredPathId(dictType, '业务字典类型'));
|
||
},
|
||
saveGenealogyOrder: function (genealogyIds) {
|
||
return request('PUT', '/genealogy/pc/genealogies/mine/order', {
|
||
body: { genealogyIds: Array.isArray(genealogyIds) ? genealogyIds : [] }
|
||
});
|
||
},
|
||
publicGenealogies: function (query) {
|
||
return request('GET', '/genealogy/pc/genealogies/public', {
|
||
query: pickDefined(query, ['keyword'])
|
||
});
|
||
},
|
||
genealogyOptions: function (query) {
|
||
return request('GET', '/genealogy/pc/genealogies/options', { query: query });
|
||
},
|
||
genealogyDetail: function (genealogyId) {
|
||
return request('GET', '/genealogy/pc/genealogies/' + toRequiredPathId(genealogyId, '家谱编号'));
|
||
},
|
||
genealogyOverview: function (genealogyId) {
|
||
return request('GET', '/genealogy/pc/genealogies/' + toRequiredPathId(genealogyId, '家谱编号') + '/overview');
|
||
},
|
||
genealogyCompleteness: function (genealogyId) {
|
||
return request('GET', '/genealogy/pc/genealogies/' +
|
||
toRequiredPathId(genealogyId, '家谱编号') + '/completeness');
|
||
},
|
||
archiveGenealogy: function (genealogyId) {
|
||
return request('PUT', '/genealogy/pc/genealogies/' +
|
||
toRequiredPathId(genealogyId, '家谱编号') + '/archive');
|
||
},
|
||
restoreGenealogy: function (genealogyId) {
|
||
return request('PUT', '/genealogy/pc/genealogies/' +
|
||
toRequiredPathId(genealogyId, '家谱编号') + '/restore');
|
||
},
|
||
updateGenealogy: function (genealogyId, body) {
|
||
return request('PUT', '/genealogy/pc/genealogies/' +
|
||
toRequiredPathId(genealogyId, '家谱编号'), {
|
||
body: pickDefined(body, [
|
||
'genealogyName', 'surname', 'regionCode', 'ancestralHall', 'originPlace',
|
||
'addressDetail', 'coverOssId', 'intro', 'visibility', 'joinMode'
|
||
])
|
||
});
|
||
},
|
||
genealogyProfileReminders: function (genealogyId) {
|
||
return request('GET', '/genealogy/pc/genealogies/' +
|
||
toRequiredPathId(genealogyId, '家谱编号') + '/profile-reminders');
|
||
},
|
||
issueGenealogyInvitation: function (genealogyId, body) {
|
||
return request('POST', '/genealogy/pc/genealogies/' +
|
||
toRequiredPathId(genealogyId, '家谱编号') + '/invitations', {
|
||
body: pickDefined(body, ['lineagePersonId'])
|
||
});
|
||
},
|
||
previewGenealogyInvitation: function (token) {
|
||
var value = String(token === undefined || token === null ? '' : token).trim();
|
||
|
||
if (!value) throw new Error('缺少邀请令牌');
|
||
return request('GET', '/genealogy/pc/genealogies/invitations/preview', {
|
||
query: { token: value }
|
||
});
|
||
},
|
||
redeemGenealogyInvitation: function (body) {
|
||
return request('POST', '/genealogy/pc/genealogies/invitations/redeem', {
|
||
body: pickDefined(body, ['token'])
|
||
});
|
||
},
|
||
myGenealogyInvitations: function () {
|
||
return request('GET', '/genealogy/pc/genealogies/invitations/mine');
|
||
},
|
||
revokeGenealogyInvitation: function (inviteId) {
|
||
return request('DELETE', '/genealogy/pc/genealogies/invitations/' +
|
||
toRequiredPathId(inviteId, '邀请编号'));
|
||
},
|
||
genealogyDeletionCapability: function (genealogyId) {
|
||
return request('GET', '/genealogy/pc/genealogies/' +
|
||
toRequiredPathId(genealogyId, '家谱编号') + '/permanent-deletion/capability');
|
||
},
|
||
sendGenealogyDeletionCode: function (genealogyId, body) {
|
||
return request('POST', '/genealogy/pc/genealogies/' +
|
||
toRequiredPathId(genealogyId, '家谱编号') + '/permanent-deletion/code', {
|
||
body: pickDefined(body, ['validToken'])
|
||
});
|
||
},
|
||
permanentlyDeleteGenealogy: function (genealogyId, body) {
|
||
return request('POST', '/genealogy/pc/genealogies/' +
|
||
toRequiredPathId(genealogyId, '家谱编号') + '/permanent-deletion', {
|
||
body: pickDefined(body, ['genealogyName', 'smsCode'])
|
||
});
|
||
},
|
||
createGenealogy: function (body) {
|
||
return request('POST', '/genealogy/pc/genealogies', {
|
||
body: pickDefined(body, [
|
||
'genealogyName', 'surname', 'regionCode', 'ancestralHall', 'originPlace',
|
||
'addressDetail', 'coverOssId', 'intro', 'visibility', 'joinMode'
|
||
])
|
||
});
|
||
},
|
||
applyToGenealogy: function (genealogyId, body) {
|
||
return request('POST', '/genealogy/pc/genealogies/' +
|
||
toRequiredPathId(genealogyId, '家谱编号') + '/join-applies', {
|
||
body: pickDefined(body, ['applicantName', 'phone', 'relationDesc', 'applyReason'])
|
||
});
|
||
},
|
||
myGenealogyJoinApplies: function () {
|
||
return request('GET', '/genealogy/pc/genealogies/join-applies/mine');
|
||
},
|
||
pendingGenealogyJoinApplies: function (genealogyId) {
|
||
return request('GET', '/genealogy/pc/genealogies/' +
|
||
toRequiredPathId(genealogyId, '家谱编号') + '/join-applies/pending');
|
||
},
|
||
auditGenealogyJoinApply: function (genealogyId, applyId, body) {
|
||
return request('PUT', '/genealogy/pc/genealogies/' +
|
||
toRequiredPathId(genealogyId, '家谱编号') + '/join-applies/' +
|
||
toRequiredPathId(applyId, '申请编号') + '/audit', {
|
||
body: pickDefined(body, ['status', 'auditRemark'])
|
||
});
|
||
},
|
||
cancelGenealogyJoinApply: function (applyId) {
|
||
return request('DELETE', '/genealogy/pc/genealogies/join-applies/' +
|
||
toRequiredPathId(applyId, '申请编号'));
|
||
},
|
||
submitFeedback: function (body) {
|
||
return request('POST', '/genealogy/pc/feedback', {
|
||
body: pickDefined(body, ['feedbackType', 'feedbackContent', 'contactInfo'])
|
||
});
|
||
},
|
||
myFeedback: function () {
|
||
return request('GET', '/genealogy/pc/feedback');
|
||
},
|
||
helpArticles: function (query) {
|
||
return request('GET', '/genealogy/pc/help-articles', {
|
||
query: pickDefined(query, ['helpCategory'])
|
||
});
|
||
},
|
||
helpArticleDetail: function (helpId) {
|
||
return request('GET', '/genealogy/pc/help-articles/' +
|
||
toRequiredPathId(helpId, '帮助文章编号'));
|
||
},
|
||
siteArticles: function (query) {
|
||
var source = query || {};
|
||
var articleType = source.articleType === undefined || source.articleType === null
|
||
? ''
|
||
: String(source.articleType).trim();
|
||
var limit = source.limit;
|
||
var params = {};
|
||
|
||
if (articleType && ['news', 'notice', 'download'].indexOf(articleType) === -1) {
|
||
throw new Error('不支持的资讯类型:' + articleType);
|
||
}
|
||
if (limit !== undefined &&
|
||
(typeof limit !== 'number' || !Number.isInteger(limit) || limit < 1 || limit > 100)) {
|
||
throw new Error('资讯数量限制必须是 1 到 100 的整数');
|
||
}
|
||
if (articleType) params.articleType = articleType;
|
||
if (limit !== undefined) params.limit = limit;
|
||
return request('GET', '/genealogy/pc/site/articles', {
|
||
auth: false,
|
||
query: params
|
||
});
|
||
},
|
||
promotions: function (query) {
|
||
var source = query || {};
|
||
var platform = source.platform === undefined || source.platform === null
|
||
? ''
|
||
: String(source.platform).trim();
|
||
|
||
if (platform && ['all', 'app', 'pc', 'wechat'].indexOf(platform) === -1) {
|
||
throw new Error('不支持的推广平台:' + platform);
|
||
}
|
||
return request('GET', '/genealogy/pc/promotions', {
|
||
query: platform ? { platform: platform } : {}
|
||
});
|
||
},
|
||
vipPackages: function () {
|
||
return request('GET', '/genealogy/pc/vip/packages');
|
||
},
|
||
vipCapability: function () {
|
||
return request('GET', '/genealogy/pc/vip/capability');
|
||
},
|
||
createVipOrder: function (body) {
|
||
return request('POST', '/genealogy/pc/vip/orders', {
|
||
body: pickDefined(body, ['packageId', 'genealogyId'])
|
||
});
|
||
},
|
||
vipOrders: function () {
|
||
return request('GET', '/genealogy/pc/vip/orders');
|
||
},
|
||
vipPaymentStatus: function (transactionId) {
|
||
return request('GET', '/genealogy/pc/vip/orders/' +
|
||
toRequiredPathId(transactionId, '支付流水编号') + '/payment');
|
||
},
|
||
closeVipPayment: function (transactionId) {
|
||
return request('POST', '/genealogy/pc/vip/orders/' +
|
||
toRequiredPathId(transactionId, '支付流水编号') + '/close');
|
||
},
|
||
earningSummary: function () {
|
||
return request('GET', '/genealogy/pc/earnings/summary');
|
||
},
|
||
earningLedger: function (query) {
|
||
return request('GET', '/genealogy/pc/earnings/ledger', {
|
||
query: pickDefined(query, ['pageNum', 'pageSize'])
|
||
});
|
||
},
|
||
earningWithdrawals: function (query) {
|
||
return request('GET', '/genealogy/pc/earnings/withdrawals', {
|
||
query: pickDefined(query, ['pageNum', 'pageSize'])
|
||
});
|
||
},
|
||
createEarningWithdrawal: function (body) {
|
||
return request('POST', '/genealogy/pc/earnings/withdrawals', {
|
||
body: pickDefined(body, ['requestId', 'amount', 'payoutQrOssId', 'payoutAccountName'])
|
||
});
|
||
},
|
||
cancelEarningWithdrawal: function (withdrawalId) {
|
||
return request('POST', '/genealogy/pc/earnings/withdrawals/' +
|
||
toRequiredPathId(withdrawalId, '提现编号') + '/cancel');
|
||
},
|
||
personDocuments: function (genealogyId, query) {
|
||
return request('GET', '/genealogy/pc/genealogies/' +
|
||
toRequiredPathId(genealogyId, '家谱编号') + '/person-documents', {
|
||
query: pickDefined(query, ['lineagePersonId'])
|
||
});
|
||
},
|
||
personDocument: function (genealogyId, documentId, accessToken) {
|
||
var options = {};
|
||
|
||
if (accessToken) options.headers = { 'X-Content-Access-Token': accessToken };
|
||
return request('GET', '/genealogy/pc/genealogies/' +
|
||
toRequiredPathId(genealogyId, '家谱编号') + '/person-documents/' +
|
||
toRequiredPathId(documentId, '档案编号'), options);
|
||
},
|
||
createPersonDocument: function (genealogyId, body) {
|
||
return request('POST', '/genealogy/pc/genealogies/' +
|
||
toRequiredPathId(genealogyId, '家谱编号') + '/person-documents', {
|
||
body: pickDefined(body, [
|
||
'lineagePersonId', 'documentType', 'documentTitle', 'maskedIdentifier',
|
||
'description', 'sortOrder', 'status'
|
||
])
|
||
});
|
||
},
|
||
updatePersonDocument: function (genealogyId, documentId, body) {
|
||
return request('PUT', '/genealogy/pc/genealogies/' +
|
||
toRequiredPathId(genealogyId, '家谱编号') + '/person-documents/' +
|
||
toRequiredPathId(documentId, '档案编号'), {
|
||
body: pickDefined(body, [
|
||
'lineagePersonId', 'documentType', 'documentTitle', 'maskedIdentifier',
|
||
'description', 'sortOrder', 'status'
|
||
])
|
||
});
|
||
},
|
||
deletePersonDocument: function (genealogyId, documentId) {
|
||
return request('DELETE', '/genealogy/pc/genealogies/' +
|
||
toRequiredPathId(genealogyId, '家谱编号') + '/person-documents/' +
|
||
toRequiredPathId(documentId, '档案编号'));
|
||
},
|
||
addPersonDocumentResource: function (genealogyId, documentId, body) {
|
||
return request('POST', '/genealogy/pc/genealogies/' +
|
||
toRequiredPathId(genealogyId, '家谱编号') + '/person-documents/' +
|
||
toRequiredPathId(documentId, '档案编号') + '/resources', {
|
||
body: pickDefined(body, ['ossId', 'usageType', 'sortOrder'])
|
||
});
|
||
},
|
||
deletePersonDocumentResource: function (genealogyId, documentId, resourceId) {
|
||
return request('DELETE', '/genealogy/pc/genealogies/' +
|
||
toRequiredPathId(genealogyId, '家谱编号') + '/person-documents/' +
|
||
toRequiredPathId(documentId, '档案编号') + '/resources/' +
|
||
toRequiredPathId(resourceId, '附件编号'));
|
||
},
|
||
personDocumentResourceAccess: function (genealogyId, documentId, resourceId, accessToken) {
|
||
var options = {};
|
||
|
||
if (accessToken) options.headers = { 'X-Content-Access-Token': accessToken };
|
||
return request('GET', '/genealogy/pc/genealogies/' +
|
||
toRequiredPathId(genealogyId, '家谱编号') + '/person-documents/' +
|
||
toRequiredPathId(documentId, '档案编号') + '/resources/' +
|
||
toRequiredPathId(resourceId, '附件编号') + '/access', options);
|
||
},
|
||
protectPersonDocument: function (genealogyId, documentId, password) {
|
||
return request('PUT', '/genealogy/pc/genealogies/' +
|
||
toRequiredPathId(genealogyId, '家谱编号') + '/person-documents/' +
|
||
toRequiredPathId(documentId, '档案编号') + '/content-protection', {
|
||
body: { password: password }
|
||
});
|
||
},
|
||
unlockPersonDocument: function (genealogyId, documentId, password) {
|
||
return request('POST', '/genealogy/pc/genealogies/' +
|
||
toRequiredPathId(genealogyId, '家谱编号') + '/person-documents/' +
|
||
toRequiredPathId(documentId, '档案编号') + '/content-unlock', {
|
||
body: { password: password }
|
||
});
|
||
},
|
||
unprotectPersonDocument: function (genealogyId, documentId) {
|
||
return request('DELETE', '/genealogy/pc/genealogies/' +
|
||
toRequiredPathId(genealogyId, '家谱编号') + '/person-documents/' +
|
||
toRequiredPathId(documentId, '档案编号') + '/content-protection');
|
||
},
|
||
notifications: function (query) {
|
||
return request('GET', '/genealogy/pc/notifications', {
|
||
query: pickDefined(query, ['readStatus'])
|
||
});
|
||
},
|
||
notificationDetail: function (notificationId) {
|
||
return request('GET', '/genealogy/pc/notifications/' + toRequiredPathId(notificationId, '通知编号'));
|
||
},
|
||
unreadNotificationCount: function () {
|
||
return request('GET', '/genealogy/pc/notifications/unread-count');
|
||
},
|
||
markNotificationRead: function (notificationId) {
|
||
return request('POST', '/genealogy/pc/notifications/' + toRequiredPathId(notificationId, '通知编号') + '/read');
|
||
},
|
||
markAllNotificationsRead: function () {
|
||
return request('POST', '/genealogy/pc/notifications/read-all');
|
||
},
|
||
feeds: function (genealogyId) {
|
||
return request('GET', buildFeedPath(genealogyId));
|
||
},
|
||
feedsPage: function (genealogyId, query) {
|
||
return request('GET', buildFeedPath(genealogyId, '/page'), { query: query });
|
||
},
|
||
feedDetail: function (genealogyId, feedId) {
|
||
return request('GET', buildFeedDetailPath(genealogyId, feedId));
|
||
},
|
||
createFeed: function (genealogyId, body) {
|
||
return request('POST', buildFeedPath(genealogyId), { body: body });
|
||
},
|
||
updateFeed: function (genealogyId, feedId, body) {
|
||
return request('PUT', buildFeedDetailPath(genealogyId, feedId), { body: body });
|
||
},
|
||
deleteFeed: function (genealogyId, feedId) {
|
||
return request('DELETE', buildFeedDetailPath(genealogyId, feedId));
|
||
},
|
||
likeFeed: function (genealogyId, feedId) {
|
||
return request('POST', buildFeedDetailPath(genealogyId, feedId, '/likes'));
|
||
},
|
||
unlikeFeed: function (genealogyId, feedId) {
|
||
return request('DELETE', buildFeedDetailPath(genealogyId, feedId, '/likes'));
|
||
},
|
||
feedComments: function (genealogyId, feedId) {
|
||
return request('GET', buildFeedCommentPath(genealogyId, feedId));
|
||
},
|
||
feedCommentsPage: function (genealogyId, feedId, query) {
|
||
return request('GET', buildFeedCommentPath(genealogyId, feedId) + '/page', { query: query });
|
||
},
|
||
feedCommentReplies: function (genealogyId, feedId, commentId) {
|
||
return request('GET', buildFeedReplyPath(genealogyId, feedId, commentId));
|
||
},
|
||
feedCommentRepliesPage: function (genealogyId, feedId, commentId, query) {
|
||
return request('GET', buildFeedReplyPath(genealogyId, feedId, commentId, '/page'), { query: query });
|
||
},
|
||
createFeedComment: function (genealogyId, feedId, body) {
|
||
return request('POST', buildFeedCommentPath(genealogyId, feedId), { body: body });
|
||
},
|
||
deleteFeedComment: function (genealogyId, feedId, commentId) {
|
||
return request('DELETE', buildFeedCommentPath(genealogyId, feedId, commentId));
|
||
},
|
||
generationPoems: function (genealogyId) {
|
||
return request('GET', buildGenerationPoemPath(genealogyId));
|
||
},
|
||
generationPoemsManagement: function (genealogyId) {
|
||
return request('GET', buildGenerationPoemPath(genealogyId, '/management'));
|
||
},
|
||
createGenerationPoem: function (genealogyId, body) {
|
||
return request('POST', buildGenerationPoemPath(genealogyId), { body: body });
|
||
},
|
||
updateGenerationPoem: function (genealogyId, poemId, body) {
|
||
return request('PUT', buildGenerationPoemPath(genealogyId, '/' + toRequiredPathId(poemId, '字辈编号')), { body: body });
|
||
},
|
||
previewGenerationPoems: function (genealogyId, body) {
|
||
return request('POST', buildGenerationPoemPath(genealogyId, '/batch/preview'), { body: body });
|
||
},
|
||
saveGenerationPoems: function (genealogyId, body) {
|
||
return request('POST', buildGenerationPoemPath(genealogyId, '/batch/save'), { body: body });
|
||
},
|
||
lineagePersons: function (genealogyId) {
|
||
return request('GET', buildLineagePath(genealogyId, '/persons'));
|
||
},
|
||
lineagePersonsPage: function (genealogyId, query) {
|
||
return request('GET', buildLineagePath(genealogyId, '/persons/page'), { query: query });
|
||
},
|
||
lineagePersonOptions: function (genealogyId) {
|
||
return request('GET', buildLineagePath(genealogyId, '/persons/options'));
|
||
},
|
||
lineageTree: function (genealogyId) {
|
||
return request('GET', buildLineagePath(genealogyId, '/tree'));
|
||
},
|
||
createLineagePerson: function (genealogyId, body) {
|
||
return request('POST', buildLineagePath(genealogyId, '/persons'), { body: body });
|
||
},
|
||
lineagePersonDetail: function (genealogyId, personId) {
|
||
return request('GET', buildLineagePersonPath(genealogyId, personId));
|
||
},
|
||
updateLineagePerson: function (genealogyId, personId, body) {
|
||
return request('PUT', buildLineagePersonPath(genealogyId, personId), { body: body });
|
||
},
|
||
disableLineagePerson: function (genealogyId, personId) {
|
||
return request('DELETE', buildLineagePersonPath(genealogyId, personId));
|
||
},
|
||
createLineageChild: function (genealogyId, personId, body) {
|
||
return request('POST', buildLineagePersonPath(genealogyId, personId, '/children'), { body: body });
|
||
},
|
||
createLineageParent: function (genealogyId, personId, body) {
|
||
return request('POST', buildLineagePersonPath(genealogyId, personId, '/parents'), { body: body });
|
||
},
|
||
createLineageSibling: function (genealogyId, personId, body) {
|
||
return request('POST', buildLineagePersonPath(genealogyId, personId, '/siblings'), { body: body });
|
||
},
|
||
createLineageSpouse: function (genealogyId, personId, body) {
|
||
return request('POST', buildLineagePersonPath(genealogyId, personId, '/spouses'), { body: body });
|
||
},
|
||
growthRecords: function (genealogyId) {
|
||
return request('GET', buildGrowthRecordPath(genealogyId));
|
||
},
|
||
createGrowthRecord: function (genealogyId, body) {
|
||
return request('POST', buildGrowthRecordPath(genealogyId), { body: body });
|
||
},
|
||
growthRecordDetail: function (genealogyId, recordId) {
|
||
return request('GET', buildGrowthRecordPath(genealogyId, recordId));
|
||
},
|
||
updateGrowthRecord: function (genealogyId, recordId, body) {
|
||
return request('PUT', buildGrowthRecordPath(genealogyId, recordId), { body: body });
|
||
},
|
||
deleteGrowthRecord: function (genealogyId, recordId) {
|
||
return request('DELETE', buildGrowthRecordPath(genealogyId, recordId));
|
||
},
|
||
relativeRecords: function (genealogyId) {
|
||
return request('GET', buildRelativeRecordPath(genealogyId));
|
||
},
|
||
createRelativeRecord: function (genealogyId, body) {
|
||
return request('POST', buildRelativeRecordPath(genealogyId), { body: body });
|
||
},
|
||
relativeRecordDetail: function (genealogyId, relativeId) {
|
||
return request('GET', buildRelativeRecordPath(genealogyId, relativeId));
|
||
},
|
||
updateRelativeRecord: function (genealogyId, relativeId, body) {
|
||
return request('PUT', buildRelativeRecordPath(genealogyId, relativeId), { body: body });
|
||
},
|
||
deleteRelativeRecord: function (genealogyId, relativeId) {
|
||
return request('DELETE', buildRelativeRecordPath(genealogyId, relativeId));
|
||
},
|
||
memos: function (genealogyId) {
|
||
return request('GET', buildMemoPath(genealogyId));
|
||
},
|
||
createMemo: function (genealogyId, body) {
|
||
return request('POST', buildMemoPath(genealogyId), { body: body });
|
||
},
|
||
memoDetail: function (genealogyId, memoId) {
|
||
return request('GET', buildMemoPath(genealogyId, memoId));
|
||
},
|
||
updateMemo: function (genealogyId, memoId, body) {
|
||
return request('PUT', buildMemoPath(genealogyId, memoId), { body: body });
|
||
},
|
||
deleteMemo: function (genealogyId, memoId) {
|
||
return request('DELETE', buildMemoPath(genealogyId, memoId));
|
||
},
|
||
meritRecords: function (genealogyId) {
|
||
return request('GET', buildMeritRecordPath(genealogyId));
|
||
},
|
||
createMeritRecord: function (genealogyId, body) {
|
||
return request('POST', buildMeritRecordPath(genealogyId), {
|
||
body: pickDefined(body, ['donorName', 'meritType', 'meritTitle', 'meritContent', 'amount', 'meritTime', 'sortOrder', 'status'])
|
||
});
|
||
},
|
||
meritRecordDetail: function (genealogyId, meritId) {
|
||
return request('GET', buildMeritRecordPath(genealogyId, meritId));
|
||
},
|
||
updateMeritRecord: function (genealogyId, meritId, body) {
|
||
return request('PUT', buildMeritRecordPath(genealogyId, meritId), {
|
||
body: pickDefined(body, ['donorName', 'meritType', 'meritTitle', 'meritContent', 'amount', 'meritTime', 'sortOrder', 'status'])
|
||
});
|
||
},
|
||
deleteMeritRecord: function (genealogyId, meritId) {
|
||
return request('DELETE', buildMeritRecordPath(genealogyId, meritId));
|
||
},
|
||
articles: function (genealogyId) {
|
||
return request('GET', buildArticleCollectionPath(genealogyId));
|
||
},
|
||
createArticle: function (genealogyId, body) {
|
||
return request('POST', buildArticleCollectionPath(genealogyId), {
|
||
body: pickDefined(body, [
|
||
'categoryId', 'articleTitle', 'articleSummary', 'coverOssId',
|
||
'articleContent', 'authorName', 'sortOrder', 'status'
|
||
])
|
||
});
|
||
},
|
||
articleDetail: function (genealogyId, articleId) {
|
||
return request('GET', buildArticlePath(genealogyId, articleId));
|
||
},
|
||
updateArticle: function (genealogyId, articleId, body) {
|
||
return request('PUT', buildArticlePath(genealogyId, articleId), {
|
||
body: pickDefined(body, [
|
||
'categoryId', 'articleTitle', 'articleSummary', 'coverOssId',
|
||
'articleContent', 'authorName', 'sortOrder', 'status'
|
||
])
|
||
});
|
||
},
|
||
deleteArticle: function (genealogyId, articleId) {
|
||
return request('DELETE', buildArticlePath(genealogyId, articleId));
|
||
},
|
||
albums: function (genealogyId) {
|
||
return request('GET', buildAlbumCollectionPath(genealogyId));
|
||
},
|
||
createAlbum: function (genealogyId, body) {
|
||
return request('POST', buildAlbumCollectionPath(genealogyId), {
|
||
body: pickDefined(body, ['albumName', 'albumDesc', 'coverOssId', 'sortOrder', 'status'])
|
||
});
|
||
},
|
||
updateAlbum: function (genealogyId, albumId, body) {
|
||
return request('PUT', buildAlbumPath(genealogyId, albumId), {
|
||
body: pickDefined(body, ['albumName', 'albumDesc', 'coverOssId', 'sortOrder', 'status'])
|
||
});
|
||
},
|
||
albumPhotos: function (genealogyId, albumId) {
|
||
return request('GET', buildAlbumPhotoCollectionPath(genealogyId, albumId));
|
||
},
|
||
createAlbumPhoto: function (genealogyId, albumId, body) {
|
||
return request('POST', buildAlbumPhotoCollectionPath(genealogyId, albumId), {
|
||
body: pickDefined(body, [
|
||
'ossId', 'photoTitle', 'photoDesc', 'photographer',
|
||
'shootTime', 'sortOrder', 'status'
|
||
])
|
||
});
|
||
},
|
||
deleteAlbum: function (genealogyId, albumId) {
|
||
return request('DELETE', buildAlbumPath(genealogyId, albumId));
|
||
},
|
||
deleteAlbumPhoto: function (genealogyId, albumId, photoId) {
|
||
return request('DELETE', buildAlbumPhotoPath(genealogyId, albumId, photoId));
|
||
},
|
||
videos: function (genealogyId) {
|
||
return request('GET', buildVideoCollectionPath(genealogyId));
|
||
},
|
||
createVideo: function (genealogyId, body) {
|
||
return request('POST', buildVideoCollectionPath(genealogyId), { body: body });
|
||
},
|
||
videoDetail: function (genealogyId, videoId) {
|
||
return request('GET', buildVideoPath(genealogyId, videoId));
|
||
},
|
||
updateVideo: function (genealogyId, videoId, body) {
|
||
return request('PUT', buildVideoPath(genealogyId, videoId), { body: body });
|
||
},
|
||
deleteVideo: function (genealogyId, videoId) {
|
||
return request('DELETE', buildVideoPath(genealogyId, videoId));
|
||
},
|
||
ceremonies: function (genealogyId) {
|
||
return request('GET', buildCeremonyCollectionPath(genealogyId));
|
||
},
|
||
createCeremony: function (genealogyId, body) {
|
||
return request('POST', buildCeremonyCollectionPath(genealogyId), {
|
||
body: pickDefined(body, [
|
||
'ceremonyType', 'ceremonyTitle', 'ceremonyDesc', 'ceremonyTime',
|
||
'location', 'locationAddress', 'longitude', 'latitude',
|
||
'coverOssId', 'sortOrder', 'status'
|
||
])
|
||
});
|
||
},
|
||
ceremonyDetail: function (genealogyId, ceremonyId) {
|
||
return request('GET', buildCeremonyPath(genealogyId, ceremonyId));
|
||
},
|
||
updateCeremony: function (genealogyId, ceremonyId, body) {
|
||
return request('PUT', buildCeremonyPath(genealogyId, ceremonyId), {
|
||
body: pickDefined(body, [
|
||
'ceremonyType', 'ceremonyTitle', 'ceremonyDesc', 'ceremonyTime',
|
||
'location', 'locationAddress', 'longitude', 'latitude',
|
||
'coverOssId', 'sortOrder', 'status'
|
||
])
|
||
});
|
||
},
|
||
ceremonyGifts: function (genealogyId, ceremonyId) {
|
||
return request('GET', buildCeremonyPath(genealogyId, ceremonyId) + '/gifts');
|
||
},
|
||
createCeremonyGift: function (genealogyId, ceremonyId, body) {
|
||
return request('POST', buildCeremonyPath(genealogyId, ceremonyId) + '/gifts', {
|
||
body: pickDefined(body, ['giverName', 'giftAmount', 'giftMessage'])
|
||
});
|
||
},
|
||
replaceCeremonyInvitees: function (genealogyId, ceremonyId, inviteeUserIds) {
|
||
return request('PUT', buildCeremonyPath(genealogyId, ceremonyId) + '/invitees', {
|
||
body: { inviteeUserIds: Array.isArray(inviteeUserIds) ? inviteeUserIds : [] }
|
||
});
|
||
},
|
||
ceremonyInvitations: function (genealogyId, ceremonyId) {
|
||
return request('GET', buildCeremonyPath(genealogyId, ceremonyId) + '/invitations');
|
||
},
|
||
respondCeremonyInvitation: function (genealogyId, ceremonyId, body) {
|
||
return request('PUT', buildCeremonyPath(genealogyId, ceremonyId) + '/invitations/me', { body: body });
|
||
},
|
||
myCeremonyInvitations: function () {
|
||
return request('GET', '/genealogy/pc/genealogies/ceremony-invitations/mine');
|
||
},
|
||
deleteCeremony: function (genealogyId, ceremonyId) {
|
||
return request('DELETE', buildCeremonyPath(genealogyId, ceremonyId));
|
||
},
|
||
deleteCeremonyGift: function (genealogyId, ceremonyId, giftId) {
|
||
return request('DELETE', buildCeremonyGiftPath(genealogyId, ceremonyId, giftId));
|
||
},
|
||
genealogyMembers: function (genealogyId) {
|
||
return request('GET', buildGenealogyMemberCollectionPath(genealogyId));
|
||
},
|
||
genealogyMemberOptions: function (genealogyId) {
|
||
return request('GET', buildGenealogyMemberCollectionPath(genealogyId) + '/options');
|
||
},
|
||
updateGenealogyMember: function (genealogyId, memberId, body) {
|
||
return request('PUT', buildGenealogyMemberPath(genealogyId, memberId), {
|
||
body: pickDefined(body, ['memberName', 'relationName', 'roleType', 'lineagePersonId'])
|
||
});
|
||
},
|
||
removeGenealogyMember: function (genealogyId, memberId) {
|
||
return request('DELETE', buildGenealogyMemberPath(genealogyId, memberId));
|
||
},
|
||
leaveGenealogy: function (genealogyId) {
|
||
return request('DELETE', buildGenealogyMemberCollectionPath(genealogyId) + '/me');
|
||
},
|
||
transferGenealogyOwner: function (genealogyId, body) {
|
||
return request('PUT', buildGenealogyMemberCollectionPath(genealogyId) + '/owner-transfer', {
|
||
body: pickDefined(body, ['targetMemberId'])
|
||
});
|
||
}
|
||
};
|
||
}
|
||
|
||
function createDefaultClient() {
|
||
try {
|
||
return createClient();
|
||
} catch (error) {
|
||
return null;
|
||
}
|
||
}
|
||
|
||
return {
|
||
DEFAULT_CLIENT_ID: DEFAULT_CLIENT_ID,
|
||
DEFAULT_TENANT_ID: DEFAULT_TENANT_ID,
|
||
TOKEN_KEY: DEFAULT_TOKEN_KEY,
|
||
createClient: createClient,
|
||
defaultClient: createDefaultClient()
|
||
};
|
||
});
|