Skip to content

Commit 9746d2e

Browse files
jmcdo29maxime1992
authored andcommitted
fix: update PUT body to match forem's API
The PUT API for updating an article expects an `article` property on the body that that `body_markdown` is a part of. This should be a pretty simple API change along with the interface update. As a side note, I was not able to get tests running locally, but I'll adjust accordingly as I need to from the CI results. closes #35
1 parent a43d936 commit 9746d2e

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

src/article.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,13 +80,13 @@ export class Article {
8080

8181
public async publishArticle(): Promise<ArticlePublishedStatus> {
8282
const body: ArticleApi = {
83-
body_markdown: this.readArticleOnDisk(),
83+
article: { body_markdown: this.readArticleOnDisk() },
8484
};
8585

8686
let frontMatter: ArticleFrontMatter;
8787

8888
try {
89-
frontMatter = this.extractDataFromFrontMatter(body.body_markdown);
89+
frontMatter = this.extractDataFromFrontMatter(body.article.body_markdown);
9090
} catch {
9191
return Promise.resolve({
9292
articleId: this.articleConfig.id,
@@ -113,7 +113,7 @@ export class Article {
113113
};
114114
}
115115

116-
if (remoteArticleBodyMarkdown && remoteArticleBodyMarkdown.trim() === body.body_markdown.trim()) {
116+
if (remoteArticleBodyMarkdown && remoteArticleBodyMarkdown.trim() === body.article.body_markdown.trim()) {
117117
return {
118118
articleId: this.articleConfig.id,
119119
updateStatus: UpdateStatus.ALREADY_UP_TO_DATE as UpdateStatus.ALREADY_UP_TO_DATE,

src/dev-to-git.interface.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,11 @@ export interface ArticleConfig extends ArticleConfigFile {
1313
}
1414

1515
// https://dev.to/api#available-json-parameters
16+
// new Dev.to update parameters https://docs.forem.com/api/#operation/updateArticle
1617
export interface ArticleApi {
17-
body_markdown: string;
18+
article: {
19+
body_markdown: string;
20+
};
1821
}
1922

2023
export interface ArticleApiResponse {

0 commit comments

Comments
 (0)