Description
Background
We need to support updating billing account for multiple payments at once to implement this task topcoder-archive/topcoder-platform-micro-frontends-taas-admin-app#81
Task
Update Create Endpoint
We already have POST /work-period-payments
endpoint which support creating a single payment or a batch of payments by sending it one object {}
in the body or list of objects [{}, {}, {}...]
.
Though such functionality is hard to notice, for example it's not visible in the the swagger that such endpoint accepts array of objects https://topcoder-platform.github.io/taas-apis/#/WorkPeriodPayments/post_work_period_payments.
To make it clear we would like to split this endpoint into 2:
POST /work-period-payments
- would only accept 1 object.POST /work-period-payments/bulk
- would only accept a list of objects [{}, {}, {}]
This way it would be clear what each endpoint does.
Support bulk payments update
At the moment we only have endpoint PATCH /work-period-payments/:id
which can update one payment by id.
Similar to create endpoint, create a second endpoint PATCH /work-period-payments/bulk
which would accept an array of payments to update like this:
[
{
id: "12312-123-123-123-21",
memberRate: 100.00,
customerRate: 110.00,
billingAccountId: 1231231,
amount: 12.0,
days: 1,
status: 'cancelled'
}, {
id: "asdfasd0f-asdf-sdf-asd-",
status: 'cancelled'
}, {
id: "12312-123-123-123-21",
amount: 12.0,
days: 1,
}
]
id
is required to provide in each object- all other fields should be validated the same like in
PATCH /work-period-payments/:id
endpoint, see [$100] Edit payments fields #431 - this endpoint should return a list of updated payments, similar to how
POST /work-period-payments/bulk
returns a list of created payments - If some of payment update fails, than for that record instead of updated payment return object from request with "error" field like
'[..., { "id": "003", "amount": 200, "error": { message: "...error message...", code: 429 }]'
. "error" should have "message" and "code" fields, where "code" is HTTP code of error.
[
// for successfully updated payment return the whole update payment object
{
id: "12312-123-123-123-21",
memberRate: 100.00,
customerRate: 110.00,
billingAccountId: 1231231,
amount: 12.0,
days: 1,
status: 'cancelled',
workPeriodId: "123-123-1231-23-123",
udpatedAt: "2021-02-02",
createdAt: "2021-02-02",
},
// when update failed, return the same object which we sent to the server with `error` field:
{
id: "asdfasd0f-asdf-sdf-asd-",
status: 'cancelled',
"error": { message: "Payment is not found", code: 404 }
},
// when update failed, return the same object which we sent to the server with `error` field:
{
id: "12312-123-123-123-21",
amount: 12.0,
days: 1,
"error": { message: "cannot update Days to more than possible", code: 429 }
}
]
General Requirements
Please, follow general requirements which are applicable for this task https://github.com/topcoder-platform/taas-apis#documentation-and-utils
In particular update Swagger.
References
- Endpoint to edit a single payment was implemented here [$100] Edit payments fields #431