ruby-on-railsformsruby-on-rails-4.2

Generate form post from local log to test a webhook?


I'm trying to resolve a complicated form post in json format from the shopify CreateOrder webhook

To simplify testing and coding I wanted to recreate the post from the parameters = in the server. Output so that I don't have to create a cart each test cycle

This is an example from my log file:

Started POST "/shopify?id=123456&shopifyaction=OC&incomingpipe=6" for xxx.xxx.xxx.xxx at 2021-03-09 14:24:22 +0000
Processing by ShopifyWebhooksController#shopify_webhook as TEXT
  Parameters: {"A1984"=>"1", "A9873"=>"5", "A1674"=>"2", "A8724"=>"1", "A3574"=>"3", "A1165"=>"5", "wbid"=>"162", "shopifyaction"=>"OC", "incomingpipe"=>"6"}
 [WB] Shopify Post Verified 

I wanted to grab the parameters hash in this and post it from an ajax or controller but I'm going round and round in circles as I try to convert this to coffee script / or a json or anything to parse it into a form, manly because the actually real post from shopify is a horrendous confusion of madness. and even with a good text editor find replace I'm throwing errors everywhere just to get jQuery to read it

Is there a simple obvious process for doing this in the controller that I'm missing?


Solution

  • For anybody looking for a good solution to this,

    Yaro's fab Gem REPOST solves all the hassles

    https://github.com/vergilet/repost