def process_request(request, client):
        # type: (Dict, ConnectClient) -> Dict
        """  This method processes the Fulfillment Requests in Pending status for change subscription action.
            If vendor system does not support the change in the subscription check the request details
            to reject the request with proper message. """

        # Get the existing subscription Id saved as fulfilment parameter to Prepare the body/payload for the Vendor API
        # to update the subscription
        # Saving the Subscription ID from Vendor system is encouraged to be able to map the subscription in Connect with
        # the subscription in Vendor system
        # The Subscription ID can be saved in a fulfillment parameter
        # This external_subscription_id from Vendor platform might be required to call the Vendor API to change
        # the subscription
        external_subscription_id = Utils.get_param_value(
            request, 'fulfillment', 'subscription_id')

        # TODO: Add code to Update/Change the subscription in vendor system by calling the Vendor API
        # to update/change subscription
        # api_client = APIClient(api_url='',
        #                        api_key='')
        # change_payload = {}
        # api_client.change_subscription(change_payload, external_subscription_id)

        # When successful, approve the fulfillment request with the following code:
        return Utils.approve_fulfillment_request(request, client)
示例#2
0
def do_validate():
    json_data = request.json
    # Customize: replace 'param_id_to_validate' with Id of the parameter that requires to be validated
    value = Utils.get_param_value(json_data, 'ordering',
                                  'param_id_to_validate')
    # Customize: Implement the desired logic to validate the value provided as the parameter
    # api_client = APIClient(api_url='',
    #                        api_key='')
    # error_message = api_client.validate_param(value)

    # Customize: Provide proper error message
    error_message = "Param param_id_to_validate not valid "
    if len(error_message) > 0:
        params = json_data['asset']['params']
        validated_param = Utils.get_item_by_id(params, 'param_id_to_validate')
        validated_param['value_error'] = error_message
        set_parameter(params, validated_param)
    return json_data
    def process_request(request, client):
        # type: (Dict, ConnectClient) -> Dict
        """ This method processes the Fulfillment Requests in Pending status for resume subscription action """

        # Get the subscription Id from the request that needs to be resumed
        # Saving the Subscription ID from Vendor system is encouraged to be able to map the subscription in Connect
        # with the subscription in Vendor system
        # The Subscription ID can be saved in a fulfillment parameter
        # This external_subscription_id from Vendor platform might be required to call the Vendor API
        # to resume the suspended subscription
        external_subscription_id = Utils.get_param_value(request, 'fulfillment', 'subscription_id')

        # TODO: Add code to Resume the subscription in vendor system by calling the Vendor API
        # to resume subscription
        # api_client = APIClient(api_url='',
        #                        api_key='')
        # resume_payload = {}
        # api_client.resume_subscription(resume_payload, external_subscription_id)

        # When successful, approve the fulfillment request with the following code:
        return Utils.approve_fulfillment_request(request, client)
示例#4
0
    def process_request(request, client):
        # type: (Dict, ConnectClient) -> Dict
        """ This method approves or rejects the Fulfillment Requests in Pending status
        for cancel subscription action. """

        # Get the fulfillment parameter values from the subscription that needs to be cancelled
        # Saving the Subscription ID from Vendor system is encouraged to be able to map the Connect subscription
        # with the subscription in Vendor system. The Subscription ID can be saved in a fulfillment parameter.
        # Here 'subscription_id' is an example of Connect product fulfillment parameter id.
        # This external_subscription_id from Vendor platform might be required to call the Vendor API
        # to cancel the subscription
        external_subscription_id = Utils.get_param_value(
            request, 'fulfillment', 'subscription_id')

        # TODO: Add your code to Cancel the subscription in vendor system by calling the Vendor API
        # api_client = APIClient(api_url='',
        #                        api_key='')
        # cancel_payload = {}
        # api_client.cancel_subscription(cancel_payload, external_subscription_id)

        # When successful, approve the fulfillment request with the following code:
        return Utils.approve_fulfillment_request(request, client)