|
| 1 | +import { axios } from "@pipedream/platform"; |
| 2 | +import constants from "./common/constants.mjs"; |
| 3 | + |
1 | 4 | export default { |
2 | 5 | type: "app", |
3 | 6 | app: "akismet", |
4 | | - propDefinitions: {}, |
| 7 | + propDefinitions: { |
| 8 | + blog: { |
| 9 | + type: "string", |
| 10 | + label: "Blog URL", |
| 11 | + description: "The URL of the blog where the comment was posted", |
| 12 | + }, |
| 13 | + userIp: { |
| 14 | + type: "string", |
| 15 | + label: "User IP", |
| 16 | + description: "The IP address of the comment author", |
| 17 | + }, |
| 18 | + permalink: { |
| 19 | + type: "string", |
| 20 | + label: "Permalink", |
| 21 | + description: "The full permanent URL of the entry the comment was submitted to", |
| 22 | + }, |
| 23 | + userAgent: { |
| 24 | + type: "string", |
| 25 | + label: "User Agent", |
| 26 | + description: "The user agent string of the web browser used to submit the comment", |
| 27 | + optional: true, |
| 28 | + }, |
| 29 | + referrer: { |
| 30 | + type: "string", |
| 31 | + label: "Referrer URL", |
| 32 | + description: "The URL of the page that submitted the comment", |
| 33 | + optional: true, |
| 34 | + }, |
| 35 | + commentAuthor: { |
| 36 | + type: "string", |
| 37 | + label: "Comment Author Name", |
| 38 | + description: "The name submitted with the comment", |
| 39 | + optional: true, |
| 40 | + }, |
| 41 | + commentAuthorEmail: { |
| 42 | + type: "string", |
| 43 | + label: "Comment Author Email", |
| 44 | + description: "The email address submitted with the comment", |
| 45 | + optional: true, |
| 46 | + }, |
| 47 | + commentAuthorUrl: { |
| 48 | + type: "string", |
| 49 | + label: "Comment Author URL", |
| 50 | + description: "The URL submitted with the comment", |
| 51 | + optional: true, |
| 52 | + }, |
| 53 | + commentContent: { |
| 54 | + type: "string", |
| 55 | + label: "Comment Content", |
| 56 | + description: "The content of the comment itself", |
| 57 | + optional: true, |
| 58 | + }, |
| 59 | + commentType: { |
| 60 | + type: "string", |
| 61 | + label: "Comment Type", |
| 62 | + description: "The type of comment", |
| 63 | + optional: true, |
| 64 | + options: constants.COMMENT_TYPES, |
| 65 | + }, |
| 66 | + }, |
5 | 67 | methods: { |
6 | | - // this.$auth contains connected account data |
7 | | - authKeys() { |
8 | | - console.log(Object.keys(this.$auth)); |
| 68 | + _baseUrl() { |
| 69 | + return "https://rest.akismet.com/1.1"; |
| 70 | + }, |
| 71 | + async _makeRequest(opts = {}) { |
| 72 | + const { |
| 73 | + $ = this, |
| 74 | + path, |
| 75 | + headers, |
| 76 | + data, |
| 77 | + ...otherOpts |
| 78 | + } = opts; |
| 79 | + |
| 80 | + return axios($, { |
| 81 | + ...otherOpts, |
| 82 | + url: this._baseUrl() + path, |
| 83 | + headers: { |
| 84 | + ...headers, |
| 85 | + "Content-Type": "application/x-www-form-urlencoded", |
| 86 | + "Accept": "application/json", |
| 87 | + }, |
| 88 | + data: { |
| 89 | + api_key: `${this.$auth.api_key}`, |
| 90 | + ...data, |
| 91 | + }, |
| 92 | + }); |
| 93 | + }, |
| 94 | + async submitSpam(args = {}) { |
| 95 | + return this._makeRequest({ |
| 96 | + path: "/submit-spam", |
| 97 | + method: "post", |
| 98 | + ...args, |
| 99 | + }); |
| 100 | + }, |
| 101 | + async submitHam(args = {}) { |
| 102 | + return this._makeRequest({ |
| 103 | + path: "/submit-ham", |
| 104 | + method: "post", |
| 105 | + ...args, |
| 106 | + }); |
| 107 | + }, |
| 108 | + async checkComment(args = {}) { |
| 109 | + return this._makeRequest({ |
| 110 | + path: "/comment-check", |
| 111 | + method: "post", |
| 112 | + ...args, |
| 113 | + }); |
9 | 114 | }, |
10 | 115 | }, |
11 | 116 | }; |
0 commit comments