BP_REST_Notifications_Endpoint::get_item_schema()

Get the notification schema, conforming to JSON Schema.

Description

Return

(array)

Source

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

876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
public function get_item_schema() {
    $schema = array(
        '$schema'    => 'http://json-schema.org/draft-04/schema#',
        'title'      => 'bp_notifications',
        'type'       => 'object',
        'properties' => array(
            'id'                => array(
                'context'     => array( 'embed', 'view', 'edit' ),
                'description' => __( 'A unique numeric ID for the notification.', 'buddyboss' ),
                'readonly'    => true,
                'type'        => 'integer',
            ),
            'user_id'           => array(
                'context'     => array( 'embed', 'view', 'edit' ),
                'description' => __( 'The ID of the user the notification is addressed to.', 'buddyboss' ),
                'type'        => 'integer',
                'default'     => bp_loggedin_user_id(),
            ),
            'item_id'           => array(
                'context'     => array( 'embed', 'view', 'edit' ),
                'description' => __( 'The ID of the item associated with the notification.', 'buddyboss' ),
                'type'        => 'integer',
            ),
            'secondary_item_id' => array(
                'context'     => array( 'embed', 'view', 'edit' ),
                'description' => __( 'The ID of the secondary item associated with the notification.', 'buddyboss' ),
                'type'        => 'integer',
            ),
            'component'         => array(
                'context'     => array( 'embed', 'view', 'edit' ),
                'description' => __( 'The name of the BuddyPress component the notification relates to.', 'buddyboss' ),
                'type'        => 'string',
            ),
            'action'            => array(
                'context'     => array( 'embed', 'view', 'edit' ),
                'description' => __( 'The name of the component\'s action the notification is about.', 'buddyboss' ),
                'type'        => 'string',
            ),
            'date'              => array(
                'description' => __( 'The date the notification was created, in the site\'s timezone.', 'buddyboss' ),
                'type'        => 'string',
                'format'      => 'date-time',
                'context'     => array( 'embed', 'view', 'edit' ),
            ),
            'is_new'            => array(
                'context'     => array( 'embed', 'view', 'edit' ),
                'description' => __( 'Whether it\'s a new notification or not.', 'buddyboss' ),
                'type'        => 'integer',
                'default'     => 1,
            ),
            'object'            => array(
                'context'     => array( 'embed', 'view', 'edit' ),
                'description' => __( 'The name of the notification object.', 'buddyboss' ),
                'type'        => 'string',
            ),
            'object_id'         => array(
                'context'     => array( 'embed', 'view', 'edit' ),
                'description' => __( 'The ID of the notification object.', 'buddyboss' ),
                'type'        => 'integer',
            ),
            'description'       => array(
                'context'     => array( 'embed', 'view', 'edit' ),
                'description' => __( 'Description of notification.', 'buddyboss' ),
                'type'        => 'object',
                'readonly'    => true,
                'properties'  => array(
                    'rendered' => array(
                        'description' => __( 'HTML description for the object, transformed for display.', 'buddyboss' ),
                        'type'        => 'string',
                        'context'     => array( 'embed', 'view', 'edit' ),
                        'readonly'    => true,
                    ),
                ),
            ),
            'link_url'          => array(
                'context'     => array( 'embed', 'view', 'edit' ),
                'description' => __( 'Link URL for the notification.', 'buddyboss' ),
                'type'        => 'string',
            ),
            'rest_actions'      => array(
                'context'     => array( 'embed', 'view', 'edit' ),
                'description' => __( 'Rest Actions which perform accept/reject based on the status.', 'buddyboss' ),
                'type'        => 'object',
            ),
        ),
    );
 
    $avatar_properties = array();
 
    $avatar_properties['full'] = array(
        /* translators: Full image size for the member Avatar */
        'description' => sprintf( __( 'Avatar URL with full image size (%1$d x %2$d pixels).', 'buddyboss' ), number_format_i18n( bp_core_avatar_full_width() ), number_format_i18n( bp_core_avatar_full_height() ) ),
        'type'        => 'string',
        'format'      => 'uri',
        'context'     => array( 'embed', 'view', 'edit' ),
    );
 
    $avatar_properties['thumb'] = array(
        /* translators: Thumb image size for the member Avatar */
        'description' => sprintf( __( 'Avatar URL with thumb image size (%1$d x %2$d pixels).', 'buddyboss' ), number_format_i18n( bp_core_avatar_thumb_width() ), number_format_i18n( bp_core_avatar_thumb_height() ) ),
        'type'        => 'string',
        'format'      => 'uri',
        'context'     => array( 'embed', 'view', 'edit' ),
    );
 
    $schema['properties']['avatar_urls'] = array(
        'description' => __( 'Avatar URLs for the notification.', 'buddyboss' ),
        'type'        => 'object',
        'context'     => array( 'embed', 'view', 'edit' ),
        'readonly'    => true,
        'properties'  => $avatar_properties,
    );
 
    /**
     * Filters the notifications schema.
     *
     * @param array $schema The endpoint schema.
     */
    return apply_filters( 'bp_rest_notification_schema', $this->add_additional_fields_schema( $schema ) );
}

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.