BP_REST_Notifications_Endpoint::get_collection_params()

Get the query params for the notifications collections.

Description

Return

(array)

Source

File: bp-notifications/classes/class-bp-rest-notifications-endpoint.php

1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
public function get_collection_params() {
    $params                       = parent::get_collection_params();
    $params['context']['default'] = 'view';
 
    // Remove the search argument.
    unset( $params['search'] );
 
    $params['order_by'] = array(
        'description'       => __( 'Name of the field to order according to.', 'buddyboss' ),
        'default'           => 'id',
        'type'              => 'string',
        'enum'              => array(
            'id',
            'date_notified',
            'item_id',
            'secondary_item_id',
            'component_name',
            'component_action',
        ),
        'sanitize_callback' => 'sanitize_key',
        'validate_callback' => 'rest_validate_request_arg',
    );
 
    $params['sort_order'] = array(
        'description'       => __( 'Order sort attribute ascending or descending.', 'buddyboss' ),
        'default'           => 'ASC',
        'type'              => 'string',
        'enum'              => array( 'ASC', 'DESC' ),
        'sanitize_callback' => 'sanitize_key',
        'validate_callback' => 'rest_validate_request_arg',
    );
 
    $params['component_name'] = array(
        'description'       => __( 'Limit result set to notifications associated with a specific component', 'buddyboss' ),
        'default'           => '',
        'type'              => 'string',
        'sanitize_callback' => 'sanitize_text_field',
        'validate_callback' => 'rest_validate_request_arg',
    );
 
    $params['component_action'] = array(
        'description'       => __( 'Limit result set to notifications associated with a specific component\'s action name.', 'buddyboss' ),
        'default'           => '',
        'type'              => 'string',
        'sanitize_callback' => 'sanitize_text_field',
        'validate_callback' => 'rest_validate_request_arg',
    );
 
    $params['user_id'] = array(
        'description'       => __( 'Limit result set to notifications addressed to a specific user.', 'buddyboss' ),
        'default'           => bp_loggedin_user_id(),
        'type'              => 'integer',
        'sanitize_callback' => 'absint',
        'validate_callback' => 'rest_validate_request_arg',
    );
 
    $params['item_id'] = array(
        'description'       => __( 'Limit result set to notifications associated with a specific item ID.', 'buddyboss' ),
        'default'           => 0,
        'type'              => 'integer',
        'sanitize_callback' => 'absint',
        'validate_callback' => 'rest_validate_request_arg',
    );
 
    $params['secondary_item_id'] = array(
        'description'       => __( 'Limit result set to notifications associated with a specific secondary item ID.', 'buddyboss' ),
        'default'           => 0,
        'type'              => 'integer',
        'sanitize_callback' => 'absint',
        'validate_callback' => 'rest_validate_request_arg',
    );
 
    $params['is_new'] = array(
        'description'       => __( 'Limit result set to items from specific states.', 'buddyboss' ),
        'default'           => true,
        'type'              => 'boolean',
        'sanitize_callback' => 'rest_sanitize_boolean',
        'validate_callback' => 'rest_validate_request_arg',
    );
 
    /**
     * Filters the collection query params.
     *
     * @param array $params Query params.
     */
    return apply_filters( 'bp_rest_notifications_collection_params', $params );
}

Changelog

Changelog
Version Description
0.1.0 Introduced.

Questions?

We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.