DoSomething / gladiator

:guardsman: The DoSomething.org competitions platform.
2 stars 0 forks source link

Updating /get user endpoint to return either a competition or a waitingRoom #401

Closed ScottPaillant closed 7 years ago

ScottPaillant commented 7 years ago

What's this PR do?

Created /get user api endpoint that can be passed an id, campaign_id, and a campaign_run_id and returns a user with either the waiting room they are in or the competition

Example response when user is in waiting room:

  "data": {
    "id": "5894e9437f43c217dd158b49",
    "first_name": null,
    "last_name": null,
    "email": null,
    "mobile": null,
    "signup": null,
    "reportback": null,
    "created_at": "2017-03-16T18:34:50+00:00",
    "updated_at": "2017-04-27T14:30:41+00:00",
    "waitingRoom": {
      "data": {
        "id": 33,
        "competition_start_date": {
          "date": "2016-04-25 00:00:00.000000",
          "timezone_type": 3,
          "timezone": "UTC"
        },
        "competition_end_date": {
          "date": "2016-05-30 00:00:00.000000",
          "timezone_type": 3,
          "timezone": "UTC"
        }
      }
    }
  }
} 

Example response when user is in a competition:

  "data": {
    "id": "5722361ba59dbfb8528b4595",
    "first_name": null,
    "last_name": null,
    "email": null,
    "mobile": null,
    "signup": null,
    "reportback": null,
    "created_at": "2016-04-28T16:11:06+00:00",
    "updated_at": "2016-04-28T16:11:06+00:00",
    "competition": {
      "data": {
        "id": 13,
        "competition_start_date": {
          "date": "2016-04-28 00:00:00.000000",
          "timezone_type": 3,
          "timezone": "UTC"
        },
        "competition_end_date": {
          "date": "2016-05-30 23:59:59.000000",
          "timezone_type": 3,
          "timezone": "UTC"
        }
      }
    }
  }

How should this be manually tested?

Issue a GET request to api/v1/users with the parameters id, campaign_id, and campaign_run_id and you should receive a user in JSON format with appropriate data.

Any background context you want to provide?

See issue #399

What are the relevant tickets?

Fixes #399

sbsmith86 commented 7 years ago

@weerd we can talk tomorrow morning if the response format makes sense for you, or what you were thinking. You will either get back a waitingRoom or Competition property on the response and that will indicate that the user has already been assigned something. I am going to approve this for now. If you need updates tomorrow morning. I am on it!

weerd commented 7 years ago

Sure thing, sounds good :) We can chat further tomorrow if needed. I left an additional comment but it's not a merge blocker by any means. More of a recommendation and not necessarily something needed for now.