fix(core): Fixed module name inconsistencies and documentation links
This commit is contained in:
8
ts/00_commitinfo_data.ts
Normal file
8
ts/00_commitinfo_data.ts
Normal file
@ -0,0 +1,8 @@
|
||||
/**
|
||||
* autocreated commitinfo by @push.rocks/commitinfo
|
||||
*/
|
||||
export const commitinfo = {
|
||||
name: '@mojoio/medium',
|
||||
version: '1.0.5',
|
||||
description: 'an unofficial medium.com API package'
|
||||
}
|
@ -1 +1,3 @@
|
||||
export * from './medium.classes.mediumaccount';
|
||||
export * from './medium.classes.account.js';
|
||||
export * from './medium.classes.publication.js';
|
||||
export * from './medium.classes.post.js';
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { MediumPublication } from './medium.classes.publication';
|
||||
import * as plugins from './medium.plugins';
|
||||
import { MediumPublication } from './medium.classes.publication.js';
|
||||
import * as plugins from './medium.plugins.js';
|
||||
|
||||
export interface IMediumAccountData {
|
||||
id: string;
|
||||
@ -38,7 +38,7 @@ export class MediumAccount implements IMediumAccountData {
|
||||
return accountData;
|
||||
}
|
||||
|
||||
public async getPublications(): Promise<MediumPublication[]> {
|
||||
public async getAllPublications(): Promise<MediumPublication[]> {
|
||||
return MediumPublication.getAllPublications(this);
|
||||
}
|
||||
|
||||
@ -46,6 +46,10 @@ export class MediumAccount implements IMediumAccountData {
|
||||
return MediumPublication.getOwnPublications(this);
|
||||
}
|
||||
|
||||
public async getPublicationByName(nameArg: string): Promise<MediumPublication> {
|
||||
return MediumPublication.getPublicationByName(this, nameArg);
|
||||
}
|
||||
|
||||
public async request(routeArg: string, methodArg: 'POST' | 'GET', payloadArg?: any) {
|
||||
const response = await plugins.smartrequest.request(`${this.baseApiDomain}${routeArg}`, {
|
||||
headers: {
|
34
ts/medium.classes.post.ts
Normal file
34
ts/medium.classes.post.ts
Normal file
@ -0,0 +1,34 @@
|
||||
import { MediumPublication } from './medium.classes.publication.js';
|
||||
import * as plugins from './medium.plugins.js';
|
||||
|
||||
export interface IPostData {
|
||||
title: string;
|
||||
contentFormat: 'html' | 'markdown';
|
||||
content: string;
|
||||
canonicalUrl: string;
|
||||
tags: string[];
|
||||
publishStatus: 'public' | 'draft' | 'unlisted';
|
||||
}
|
||||
|
||||
export class MediumPost implements IPostData {
|
||||
// STATIC
|
||||
public static async createPost(mediumPublicationArg: MediumPublication, dataArg: IPostData) {
|
||||
const response = await mediumPublicationArg.mediumAccountRef.request(`/publications/${mediumPublicationArg.id}/posts`, 'POST', dataArg);
|
||||
const post = new MediumPost(mediumPublicationArg, response.body.data);
|
||||
return post;
|
||||
}
|
||||
|
||||
// INSTANCE
|
||||
mediumPublicationRef: MediumPublication;
|
||||
|
||||
title: string;
|
||||
contentFormat: 'html' | 'markdown';
|
||||
content: string;
|
||||
canonicalUrl: string;
|
||||
tags: string[];
|
||||
publishStatus: 'public' | 'draft' | 'unlisted';
|
||||
|
||||
constructor(mediumPublication: MediumPublication, dataArg: IPostData) {
|
||||
|
||||
}
|
||||
}
|
@ -1,5 +1,6 @@
|
||||
import { MediumAccount } from './medium.classes.mediumaccount';
|
||||
import * as plugins from './medium.plugins';
|
||||
import { MediumAccount } from './medium.classes.account.js';
|
||||
import { type IPostData, MediumPost } from './medium.classes.post.js';
|
||||
import * as plugins from './medium.plugins.js';
|
||||
|
||||
export interface IMediumPublication {
|
||||
id: string;
|
||||
@ -47,6 +48,11 @@ export class MediumPublication implements IMediumPublication {
|
||||
return ownPublications;
|
||||
}
|
||||
|
||||
public static async getPublicationByName(mediumAccountArg: MediumAccount, publicationNameArg: string) {
|
||||
const publications = await this.getAllPublications(mediumAccountArg);
|
||||
return publications.find(publicationArg => publicationArg.name === publicationNameArg);
|
||||
}
|
||||
|
||||
// INSTANCE
|
||||
public mediumAccountRef: MediumAccount;
|
||||
|
||||
@ -57,6 +63,12 @@ export class MediumPublication implements IMediumPublication {
|
||||
imageUrl: string;
|
||||
|
||||
constructor(mediumAccount: MediumAccount, dataArg: IMediumPublication) {
|
||||
this.mediumAccountRef = mediumAccount;
|
||||
Object.assign(this, dataArg);
|
||||
}
|
||||
|
||||
public async createPost(dataArg: IPostData): Promise<MediumPost> {
|
||||
const result = await MediumPost.createPost(this, dataArg);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
import * as smartpromise from '@pushrocks/smartpromise';
|
||||
import * as smartrequest from '@pushrocks/smartrequest';
|
||||
import * as smartpromise from '@push.rocks/smartpromise';
|
||||
import * as smartrequest from '@push.rocks/smartrequest';
|
||||
|
||||
export {
|
||||
smartpromise,
|
||||
|
Reference in New Issue
Block a user