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

fix: AdReportRun can't retain id with post insights #151

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

mktktmr
Copy link
Contributor

@mktktmr mktktmr commented Aug 13, 2021

I'd like to use AdReportRun like below.

ad_account = FacebookAds::AdAccount.get(some_params)

# Generating a job to create report
ad_report_run = ad_account.insights.create(some_params)

# Waiting until the job completed
until ad_report_run.reload! && ad_report_run.async_status == "Job Completed"
  sleep 1
end

# Fetching the report
ad_report_run.insights.all

Unfortunately AdReportRun causes an error with api request in reality, because AdReportRun has report_run_id instead of id. As you know AdObject (and its sub class) try to get data by id.

ad_account = FacebookAds::AdAccount.get(some_params)

ad_report_run = ad_account.insights.create(some_params)

ad_report_run.async_status # error occurred
# => NoMethodError: undefined method `gsub' for nil:NilClass
#    from /usr/src/tmp/facebook-ruby-business-sdk/lib/facebook_ads/session.rb:41:in `request'

That's why I added a process to replace attributes report_run_id to id on AdObject#initialize.

@mktktmr mktktmr force-pushed the feature/asynchronous_insights branch from 18fbad6 to 78db8c0 Compare August 13, 2021 12:45
@mktktmr mktktmr marked this pull request as ready for review August 13, 2021 13:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants