Examples of Using Curl for API Testing
Examples of Using Curl to call the APIs for Scenario and Tips
/controllers/v1/scenarios#index - EXAMPLE FOR NFL
The index action is called by a get. The param game_id is required because all scenarios require a game. The league is assumed to be nfl:
Curl Statement
curl -H “Content-Type: application/json” -H “Accept: application/json” -H “X-User-Token: 4-kK2ByR73RhQqRiKjUu” -H “X-User-Email: sjohnson@esb.com” -X GET http://localhost:3000/v1/scenarios/\?game_id=2022121500
JSON Response
Since this is an index action, a collection of scenario data comes back even though it is generally only 1 scenario for a game.
[{“id”:250,”deprecated_game_id”:null,”gameable_id”:2022121500,”gameable_type”:”NflGame”,”name”:”Scenario A”,”title”:”"Brock" Show Hits The Road In Niners Win (49ers Win + Cover)”,”show_opening_paragraph”:false,”opening_paragraph”:”The San Francisco 49ers will pick up their seventh straight win this week, beating the Seattle Seahawks on the road. To do that, they will rely on the solid quarterback play of Brock Purdy, who has filled in admirably for the injured Jimmy Garoppolo. In his first NFL start last week, Purdy completed 16 of his 21 passes, threw two touchdown passes and added another on the ground. He will play well again here against a Seahawks team that ranks 30th in the NFL in points allowed.”,”outcome”:”pending”,”user_selected”:false,”published”:false,”show_tips”:false,”automation_type”:”bar”,”tips”:[]}]
/controllers/v1/scenarios#index - EXAMPLE FOR NBA
The index action is called by a get. The param game_id is required because all scenarios require a game. Since league is required, it is passed in as a string.
Curl Statement
curl -H “Content-Type: application/json” -H “Accept: application/json” -H “X-User-Token: 4-kK2ByR73RhQqRiKjUu” -H “X-User-Email: sjohnson@esb.com” -X GET http://localhost:3000/v1/scenarios/\?game_id=2022121500&league=nba
JSON Response
I don’t have an example here since I don’t have matching data but I verified the url in a browser where I saw [] return correctly.
/controllers/v1/scenarios#show
The show action is called by a get.
Curl Statement
curl -H “Content-Type: application/json” -H “Accept: application/json” -H “X-User-Token: 4-kK2ByR73RhQqRiKjUu” -H “X-User-Email: sjohnson@esb.com” -X GET http://localhost:3000/v1/scenarios/1\n
JSON Response
{“id”:1,”deprecated_game_id”:2022021300,”gameable_id”:null,”gameable_type”:null,”name”:”Test”,”title”:null,”show_opening_paragraph”:false,”opening_paragraph”:”Blah Blah Blah”,”outcome”:”pending”,”user_selected”:true,”published”:false,”show_tips”:false,”automation_type”:”foo”,”tips”:[]}%
Notes
Since scenarios have unique ids there is no need to specify the league.