Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Batch api does not return responses #66

Closed
osdakira opened this issue Mar 18, 2019 · 4 comments
Closed

Batch api does not return responses #66

osdakira opened this issue Mar 18, 2019 · 4 comments
Labels

Comments

@osdakira
Copy link
Contributor

osdakira commented Mar 18, 2019

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.

def execute
return [] if operations.empty?
operations.each_slice(50) do |slice|
api_response = APIRequest.new(:post, '', session: session, params: batch_args(slice)).execute_now
self.last_api_response = api_response
slice.zip(api_response.result).map do |req, res|
next unless res
begin
req.create_response(
res['code'],
convert_headers_to_hash(res['headers']),
res['body'])
rescue APIError => e
e
end
end
end
end

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
Copy link

stale bot commented Jan 14, 2020

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 stale bot added the Stale label Jan 14, 2020
@stale
Copy link

stale bot commented Jan 21, 2020

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.

@stale stale bot closed this as completed Jan 21, 2020
@kurko
Copy link

kurko commented Feb 8, 2020

I have this same issue.

@raszi
Copy link

raszi commented Dec 1, 2022

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants