Make some params optional for add-on purchase update endpoint
What does this MR do and why?
Part of https://gitlab.com/gitlab-org/customers-gitlab-com/-/issues/6299+
The update endpoint for a subscription add-on purchase required the quantity
, expires_on
and purchase_xid
params. For the deprovisioning of a subscription add-on purchase, only the expires_on
will be synced. The other two params are therefore made optional for the update endpoint.
note: This change is behind a feature flag and therefore doesn't need a changelog entry.
How to set up and validate locally
- Enable the feature flag
purchase_code_suggestions
:Feature.enable(:purchase_code_suggestions)
. - You'll need a namespace ID and a private token for the API requests in the next steps.
- Create a subscription add-on purchase:
curl --request POST \ --url http://gdk.test:3000/api/v4/namespaces/<NAMESPACE_ID>/subscription_add_on_purchase/code_suggestions \ --header 'Content-Type: application/json' \ --header 'PRIVATE-TOKEN: <PRIVATE_TOKEN>' \ --data '{ "quantity": 1, "expires_on": "2023-08-01", "purchase_xid": "1a2b3c" }'
- Verify a request to the PUT add-on purchase endpoint without the
expires_on
in the params is unsuccessful:curl --request PUT \ --url http://gdk.test:3000/api/v4/namespaces/<NAMESPACE_ID>/subscription_add_on_purchase/code_suggestions \ --header 'Content-Type: application/json' \ --header 'PRIVATE-TOKEN: <PRIVATE_TOKEN>' \ --data '{ "quantity": 3, "purchase_xid": "1a2b3c" }'
- Verify a request to the PUT add-on purchase endpoint with all params is successful:
curl --request PUT \ --url http://gdk.test:3000/api/v4/namespaces/<NAMESPACE_ID>/subscription_add_on_purchase/code_suggestions \ --header 'Content-Type: application/json' \ --header 'PRIVATE-TOKEN: <PRIVATE_TOKEN>' \ --data '{ "quantity": 5, "expires_on": "2023-08-15", "purchase_xid": "1a2b3c" }'
- Verify a request to the PUT add-on purchase endpoint with only the
expires_on
in the params is successful:curl --request PUT \ --url http://gdk.test:3000/api/v4/namespaces/<NAMESPACE_ID>/subscription_add_on_purchase/code_suggestions \ --header 'Content-Type: application/json' \ --header 'PRIVATE-TOKEN: <PRIVATE_TOKEN>' \ --data '{ "expires_on": "2023-06-19" }'
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.