facebook / facebook-ruby-business-sdk

Ruby SDK for Meta Marketing API
https://developers.facebook.com/docs/business-sdk
Other
204 stars 161 forks source link

Make summary results accessible to edges #116

Closed jeffse closed 2 years ago

jeffse commented 3 years ago

What's the issue?

When fetching an edge, there is no way to get at any summary data that might be returned.

Steps/Sample code to reproduce the issue

fb_session = FacebookAds::Session.new(access_token: 'token', app_secret: 'secret')
fb_post = FacebookAds::PagePost.get('xxxxxxxxxxxxxxx_xxxxxxxxxxxxxxxx', 'message', fb_session)
fb_comments = fb_post.comments(summary: 'total_count')

Observed Results:

Turning on logs, I can see that the total_count for the number of comments here is returned, but the SDK just ignores it and it remains inaccessible. Example JSON returned:

{
  "data": [
    {
      "created_time": ...,
      "message": ...,
      "id": ...
    },
    ...
  ],
  "paging": {
    "cursors": {
      "before": ...,
      "after": ...
    },
    "next": ...
  },
  "summary": {
    "total_count": 110
  }
}

Fix:

Store any summary results into the summary property on the Edge object. Now,

2.6.5 :006 > fb_comments.summary
 => {"total_count"=>110}