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

EventRequest Does Not Work if Using OJ.mimic_json #139

Open
fiestacasey opened this issue Apr 13, 2021 · 1 comment
Open

EventRequest Does Not Work if Using OJ.mimic_json #139

fiestacasey opened this issue Apr 13, 2021 · 1 comment
Labels

Comments

@fiestacasey
Copy link

Which SDK version are you using?

What's the issue?

When using oj.mimic_json an FacebookAds::ServerSide::EventRequest raises an exception. The standard JSON library supports object_class and array_class when parsing JSON but OJ does not. Given the popularity of OJ I think that this gem should avoid using object_class. Here's the source that is raising the issue:

json_response_object = JSON.parse(JSON.generate(response), object_class: OpenStruct)

Steps/Sample code to reproduce the issue

require 'facebookbusiness'
require 'oj_mimic_json'

# TODO: REPLACE WITH VALID ACCESS TOKEN AND PIXEL ID
access_token = 'TODO'
pixel_id = 'TODO'

FacebookAds.configure do |config|
  config.access_token = access_token
end

user_data = FacebookAds::ServerSide::UserData.new(
  email: '[email protected]'
)

custom_data = FacebookAds::ServerSide::CustomData.new(
  value: 100,
  currency: 'USD',
  content_name: 'Style Edit',
  content_ids: 'style-edit',
  content_type: 'product',
  order_id: '123456'
)

event = FacebookAds::ServerSide::Event.new(
  event_name: 'Purchase',
  action_source: 'website',
  event_id: '123456',
  event_time: Time.now.to_i,
  user_data: user_data,
  custom_data: custom_data
)

request = FacebookAds::ServerSide::EventRequest.new(
  pixel_id: pixel_id,
  events: [event]
)

print request.execute # where the exception is raised.

Observed Results:

This is raised:

ruby/gems/2.6.0/gems/facebookbusiness-0.10.0.0/lib/facebook_ads/ad_objects/server_side/event_request.rb:160:in `execute': undefined method `events_received' for #<Hash:0x00007fc1dc1dbc08> (NoMethodError)

Expected Results:

Execution without an exception

@stale
Copy link

stale bot commented Jan 8, 2022

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 8, 2022
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

1 participant