Skip to content

[$40] Populate "winners" array during payments #236

Closed
@maxceem

Description

@maxceem

When we create a WorkPeriodPayment record using POST /work-period-payments for the payment purpose we are creating a challenge here, which was implemented in this challenge.

Creating challenge payment has next steps:

  1. create a challenge
  2. add resource (member) to the challenge
  3. activate challenge
  4. close challenge

We have to update the last step "close challenge". Apart from setting { status: 'Completed' } it also has to set winners array like this:

{
    "status": "Completed",
    "winners": [
        {
            "userId": 88773930,
            "handle": "jcori30",
            "placement": 1
        }
    ]
}

Where:

  • placement is always 1
  • handle is the same handle which we add as a resource on step 2, it comes from the Work Period userHandle
  • userId is numeric user from V3. Note, that in TaaS API we usually use UUID V5 user ids which are not compatible with V3 user ids.

To get V3 userId we can use endpoint GET /v3/members/{handle}:

image

So we can implement a new helper method for this like getV3MemberDetailsByHandle. Please, don't use existent getMemberDetailsByHandles method, as it has some issues for some users. We are still using it when we have to get multiple users at once, but in this case we need to get only one user, and endpoint GET /v3/members/{handle} should be more reliable.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions