Reputation: 15
I'm working with an API that allow me to check if a user is connected to any account (Amazon, Ebay, Prestashop, etc).
When a connection is made, I receive a webhook in JSON
that looks like this :
Parameters: {"connection"=>{"informations"=>{}, "connector_uuid"=>"3180ba23-2b75-5abe-b14d-69a42835474d", "id_user"=>626, "created"=>"2019-12-26 10:03:41", "id_provider"=>940, "error_message"=>nil, "last_push"=>nil, "last_update"=>"2019-12-26 10:03:45", "connector"=>{"sync_frequency"=>nil, "code"=>nil, "uuid"=>"3180ba23-2b75-5abe-b14d-69a42835474d", "documents_type"=>["bill"], "color"=>"c8ee20", "auth_mechanism"=>"credentials", "capabilities"=>["document"], "id"=>470, "available_auth_mechanisms"=>["credentials"], "beta"=>true, "months_to_fetch"=>nil, "urls"=>["https://addons.prestashop.com"], "siret"=>nil, "hidden"=>false, "charged"=>true, "slug"=>"PRE", "categories"=>[], "name"=>"PrestaShop"}, "active"=>true, "state"=>nil, "expire"=>nil, "accounts"=>[], "error"=>nil, "subscriptions"=>[{"id_source"=>604, "documents"=>[], "id_user"=>696, "deleted"=>nil, "id_connection"=>708, "number"=>"[email protected]", "validity"=>nil, "label"=>"[email protected]", "subscriber"=>"John Doe", "currency"=>nil, "disabled"=>nil, "error"=>"bug", "id"=>550, "formatted_balance"=>nil, "renewdate"=>nil, "balance"=>nil, "last_update"=>nil}], "next_try"=>"2019-12-27 14:03:45", "id_connector"=>440, "id"=>608}, "push_type"=>"partial_history", "user"=>{"signin"=>"2019-12-26 10:03:08", "platform"=>"sharedAccess", "id"=>626}, "invoice"=>{"connection"=>{"informations"=>{}, "connector_uuid"=>"3180ba23-2b75-5abe-b14d-69a42835474d", "id_user"=>926, "created"=>"2019-12-26 10:03:41", "id_provider"=>480, "error_message"=>nil, "last_push"=>nil, "last_update"=>"2019-12-26 10:03:45", "connector"=>{"sync_frequency"=>nil, "code"=>nil, "uuid"=>"3180ba23-2b75-5abe-b14d-69a42835474d", "documents_type"=>["bill"], "color"=>"c8ee20", "auth_mechanism"=>"credentials", "capabilities"=>["document"], "id"=>440, "available_auth_mechanisms"=>["credentials"], "beta"=>true, "months_to_fetch"=>nil, "urls"=>["https://addons.prestashop.com"], "siret"=>nil, "hidden"=>false, "charged"=>true, "slug"=>"PRE", "categories"=>[], "name"=>"PrestaShop"}, "active"=>true, "state"=>nil, "expire"=>nil, "accounts"=>[], "error"=>nil, "subscriptions"=>[{"id_source"=>699, "documents"=>[], "id_user"=>926, "deleted"=>nil, "id_connection"=>608, "number"=>"[email protected]", "validity"=>nil, "label"=>"[email protected]", "subscriber"=>"John Doe", "currency"=>nil, "disabled"=>nil, "error"=>"bug", "id"=>550, "formatted_balance"=>nil, "renewdate"=>nil, "balance"=>nil, "last_update"=>nil}], "next_try"=>"2019-12-27 14:03:45", "id_connector"=>490, "id"=>908}, "push_type"=>"partial_history", "user"=>{"signin"=>"2019-12-26 10:03:08", "platform"=>"sharedAccess", "id"=>626}}}
Do you know how to display this JSON
in my view ?
I tried, in my controller :
def webhooks
render json: response.body, status: 200
puts response.body.inspect
end
But nothing happens in my view, I have the JSON in my console BUT my puts render an empty string.
Upvotes: 1
Views: 281
Reputation: 26
params instead of response.body
def webhooks
render json: params, status: 200
puts params
end
Upvotes: 1