allisonking / wacks-by-warby

etsy discord integration for a highly specific purpose
0 stars 0 forks source link

Spike out what we need to do to integrate with shift4shop #4

Closed allisonking closed 1 year ago

allisonking commented 1 year ago

Shift4Shop has a pretty well documented developer portal. We need to experiment with their API and figure out the flow to replicate the functionality of https://github.com/allisonking/wacks-by-warby

https://apirest.3dcart.com/swagger/ui/index

allisonking commented 1 year ago

Some questions to answer:

rchhay commented 1 year ago

List of sales (with timestamp?)

What was sold and how many

Current inventory?

What scopes do we need (read only, probably)?

What kind of app does Wacks need to be, i.e. long running webserver, or cron job?

allisonking commented 1 year ago

The etsy flow was:

  1. Get current inventory (across all products)
  2. Compare with the previous saved inventory
  3. Announce the diffs to discord
  4. Save the current inventory to the previous inventory file
  5. Create a lit of embeds from the diff
  6. Repeat

It sounds like shift4shop might be more like

  1. Get the current order status (first time, get them all, after that, send a timestamp)
  2. For each order returned, query the Products/{CatalogID} endpoint to get more data about it
  3. Create a list of embeds from the diff
  4. Store the timestamp and repeat

In other words, shift4shop may naturally do the diff for us as long as we keep track of the timestamp

rchhay commented 1 year ago

A few things to keep in mind.

  1. If we get all orders, we might get orders that are in the Not Completed status (7). This is when someone just put things in their cart but haven't actually checked out yet so it's not a real order. I think we should just focus on New status (1) for now. If we want to get all orders, we would need to filter out status on our end.
  2. It seems like if we do not specify a limit, the default is 10 so we probably should set a high limit.

If we just get new orders then we probably can just build the list of embeds directly from what is returned by the API.

https://miro.com/app/board/uXjVP_FGQG8=/ I stared a high level diagram but it needs some adjustments from you.

allisonking commented 1 year ago

looks great!! it seems like there's an orderstatus query param, so maybe we can use that to filter? or it'd be easy enough to filter on our end too.

rchhay commented 1 year ago

Yep orderstatus=1 will give us new orders only so let's use that so we don't have to do the filtering ourselves haha

allisonking commented 1 year ago

Endpoint to use https://apirest.3dcart.com/3dCartWebAPI/v1/Orders?orderstatus=1&offset=1&datestart=X where x is the last run time. This will give us the list of new orders since last run.

@rchhay what's the offset=1 for?