Include custom API relation to Customer Rest API

mk00559179
mk00559179 Posts: 18 🧑🏻‍🚀 - Cadet

We're working on headless approach and create custom API to subscribe/unsubscribe to newsletter, API is working fine, now we want to include newsletter status to customer Rest API, for that we've added to relationship dependency $resourceRelationshipCollection->addRelationship( CustomersRestApiConfig::RESOURCE_CUSTOMERS, new NewslettersRestApiResourceRelationshipPlugin(),);

To Retrieve newsletter status we're using newsletter's checkSubscriptionfunction, when we include newsletter in customer API I am getting data in my function

Array(    [type] => newsletters    [id] =>     [attributes] => Array        (            [isSubscribe] =>         )
    [links] => Array        (            [self] => customers/DE--14        )
    [relationships] => Array        (            [newsletters] => Array                (                    [data] => Array                        (                            [0] => Array                                (                                    [type] => newsletters                                    [id] =>                                 )
                        )
                )
        )
)

But it is not included in final output of customer API, let me know what we're doing wrong here

Answers