API Conversion

Log in to ChatGPT with these credentials

Use this only for this project

This is a test for this project alone So I may unsubscribe after this project. If it goes well, we may do something similar in the future, in which case, I will think about setting up a team subscription

Use ChatGPT 03-Mini-High

Paste in the prompt to prime ChatGPT for what we’re about to do

Create a branch based off of v21-replica

Check out the spreadsheet

  • Find an unassigned file
  • Assign it to yourself
  • Begin conversion

Convert the file

  • Split the file into 2 files:
    • For files in endpoints:
      • If the file’s name is x.php, then create:
      • x.model.ts
      • x.routes.ts
    • For files in integrations:
      • all the files are names as class-x.php
      • create a duplicate file called x.php

Use Teams and Endpoint as reference

Endpoint Skeleton

Every file in /endpoints is a class that extends Endpoint from /Endpoint.ts

import Endpoint, { WhereCondition } from "@/legacy/endpoints/Endpoint"
import CodedError from "@/utils/CodedError"
import { db } from "@/utils/database"
import { DB } from "@/utils/db"
import { ExpressionOrFactory, sql } from "kysely"

class Example extends Endpoint {
	TABLE: string = "Property_Rules"
	pkField: string = ""
}

export default Example

Integrations Skeleton

Every file in /integrations is a class that won’t extend anything

import CodedError from "@/utils/CodedError"
import { db } from "@/utils/database"
import { DB } from "@/utils/db"
import { ExpressionOrFactory, sql } from "kysely"

class Example {
}

export default Example

Lib Skeleton

Lib skeleton is the same as integrations skeleton

1. Copy the skeleton file content into the newly created file

Rename the class to match the name of the table in the database. For example, if the file name is property_offerapis, rename it to Property_OfferAPIs

List of table names:

AgentBox_Rules AgentBox_Rules_Dash AgentBox_Users AgentBoxes AgentBoxes_Dash Audits BuyBox_Rules BuyBox_Rules_Dash BuyBoxes BuyBoxes_Dash FieldOptions FieldSettings Insights Integrations InvitedInvestors LogEntries Notification_Events Notifications Notifications_Dash OfferAPIs Products Properties Properties_Dash Properties_Dash_Ranking Properties_Joined Properties_Metadata Properties_Quick Properties_SubmitForOffers Property_BuyBoxes Property_BuyBoxes_Dash Property_Files Property_Messages Property_Messages_Dash Property_OfferAPIs Property_OfferAPIs_Dash Property_Offers Property_Offers_Dash Property_Queue Property_Rules Property_Rules_Queue Property_Users Property_Users_Dash Roles Rules Single_Property_Offers_Dash Subscriptions Teams Teams_Dash Transactions User_Cards User_Files User_Integrations User_Settings Users Users_Dash Users_Self Webhooks Websites Websites_Dash Whitelabels

2. Copy as much of the php file into ChatGPT as it will allow

To save on number of prompts, paste in as much as you can, all the way up to the entire file if possible

3. Copy and paste the functions it gives back into the new class

  • Ignore the function called process. In the old API, this is how we handled processing an endpoint. In the new system, all that logic will be moved to x.routes.ts and handled via express
  • Copy each function one at a time

4. Look over each function and identify any mistakes or errors

If you don’t like the way something is set up, then fix it, and then tell ChatGPT to change how it handles that specific thing.

  • change this.db to just db
  • change calling a class directly to instantiating the class, then calling it