import { REDDIT_PROFILE_SCHEMA, REDDIT_PROVIDER_PROFILE_SCHEMA, toRedditProfile, } from "@automate.ax/integration-contracts/reddit" import { z } from "zod" import { defineAction } from "../../automation/actions" import { getRedditApi, REDDIT_ACCOUNT, redditAccountRequirement } from "./lib" /** Returns the connected Reddit user's public identity and karma totals. */ export const getRedditProfile = defineAction("Get Reddit profile") .account(REDDIT_ACCOUNT, redditAccountRequirement("identity")) .input(z.object({})) .output(REDDIT_PROFILE_SCHEMA) .retry({ replaySafety: "safe" }) .handler(async ({ account }) => toRedditProfile( await getRedditApi(account.secret).request("api/v1/me", { responseSchema: REDDIT_PROVIDER_PROFILE_SCHEMA, }), ), )