-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Start Auction by sending to Auctioneer #116
Conversation
This PR IS super exciting!!! 🎉 🎉 🎉 Super cool that you and @nick-telsan worked through revisions to the endpoints together today. Go team! |
'local' => 'GOODBIDS_AUCTIONEER_URL_LOCAL', | ||
'develop' => 'GOODBIDS_AUCTIONEER_URL_DEVELOP', | ||
'production' => 'GOODBIDS_AUCTIONEER_URL_PRODUCTION', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it also work to have a single env var GOODBIDS_AUCTIONEER_URL
and just have the value be different across each environment?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, the environments relate to the Auctioneer specifically, and The Auctioneer Environment does not have to match the GoodBids Site Environment. The idea is if I'm on Develop (or local) and I want to primarily use the Production Auctioneer, however, there's a new feature on the develop
Auctioneer URL that hasn't been tested yet, I can easily switch to that environment without updating the ENV vars. It's super easy to do locally, but on Develop or Production, you have to re-deploy if you update environment variables. So did this just to make things consistent across all environments.
// TODO: Refactor using individual Response classes. | ||
$payload = [ | ||
'id' => $guid, | ||
'startTime' => goodbids()->auctions->get_start_date_time( $auction_id, 'c' ), | ||
'endTime' => goodbids()->auctions->get_end_date_time( $auction_id, 'c' ), | ||
'currentBid' => floatval( $bid_product?->get_price( 'edit' ) ), | ||
'requestTime' => current_datetime()->format( 'c' ), | ||
]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this works great.
In this case, the two biggest benefit of classes & named arguments are:
- automated refactors. But... if you're only building up this payload in one spot... you don't really benefit much from it.
- Type hints / warnings. Not sure if that's super valuable here either.
Might as well not add complexity until you need it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Those were my thoughts as well. I don't know if we'll ever be building these payloads differently, so we can cross that bridge if/when we get there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks awesome!
Summary
This PR is super exciting! It uses the Auction Start Cron action to signal to Auctioneer (our Node.js server) that an Auction is starting. We are pulling Auctions that start 1 minute from the current day/time.
Changes to Ticket
There are a few changes that go against the requirements in the ticket, mostly outlined in this Issue.
POST /auction/{guid}/start
)Environment Variables
I have gone ahead and update the WP VIP Development Environment variable for
GOODBIDS_AUCTIONEER_URL_DEVELOP
. That command is:vip @goodbids.develop config envvar set GOODBIDS_AUCTIONEER_URL_DEVELOP
Then follow the prompts. The value should be:
https://goodbids-node-develop.go-vip.net
.We have 2 others we could set up (
GOODBIDS_AUCTIONEER_URL_LOCAL
andGOODBIDS_AUCTIONEER_URL_PRODUCTION
), however, for the purpose of this PR, they have not been set up. And the "Develop" Environment variable has only been set up on the VIP Development Environment.Issues
Testing Instructions-ish
Local Environment
Since we don't have access to the remote VIP Environment variables, we have to use a PHP file. Create a new file in
client-mu-plugins
calledvip-env-vars.local.php
. The contents should be:(although we're only currently using the 2nd one)
Local and Development Environments
Dev Notes
I have a feeling a good bit of this code will change once we start adding more endpoints, seeing code duplication, and adding more logging. I'm definitely open to suggestions on other approaches. @joshuapease and I discussed using Named Arguments to define the Request Objects, but didn't add it this round.