facebook / facebook-ruby-business-sdk

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

Batch api does not return responses #66

Closed osdakira closed 4 years ago

osdakira commented 5 years ago

Which SDK version are you using?

[7] pry(main)> FacebookAds::VERSION
=> "0.3.2.9"
[11] pry(main)> RUBY_VERSION
=> "2.5.0"

What's the issue?

Batch API has the logic to return the response. However, there is no return value because each_slice has been added.

https://github.com/facebook/facebook-ruby-business-sdk/blob/bd80d59ef8a1f53422d74bb49a917e2a77bebcab/lib/facebook_ads/batch_api/batch.rb#L33-L51

Steps/Sample code to reproduce the issue

[4] pry(main)> require "facebookbusiness"
=> true
[5] pry(main)> session = FacebookAds::Session.new(access_token: access_token, app_secret: app_secret)
[6] pry(main)> batch = FacebookAds::Batch.with_batch do
  FacebookAds::AdAccount.get("act_#{ad_account_id}", session).name
[6] pry(main)* end 
[7] pry(main)> batch.execute
=> nil

Observed Results:

Enumerable#each_slice return nil.

https://ruby-doc.org/core-2.5.0/Enumerable.html#method-i-each_slice

Expected Results:

I added the map method. It will be the expected result.

File: vendor/bundle/ruby/2.5.0/gems/facebookbusiness-0.3.2.9/lib/facebook_ads/batch_api/batch.rb
- 35:       operations.each_slice(50) do |slice|
+ 35:       operations.each_slice(50).map do |slice|
[6] pry(main)> batch.execute
=> [[#<FacebookAds::AdAccount {:id=>"act_****", :account_id=>"****"}>]]
stale[bot] commented 4 years ago

Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. Thank you for your contributions.

stale[bot] commented 4 years ago

Closing this issue after a prolonged period of inactivity. If this issue is still present in the latest release, please feel free to create a new issue with up-to-date information.

kurko commented 4 years ago

I have this same issue.

raszi commented 1 year ago

This is still an issue, more than three years later! 😞