I'm attempting to send a NewSubmission to a CRM called LionDesk. The sample NewSubmission code is written in PHP and I need to convert this into Ruby code since I will be integrating this into an existing Rails application.
Here is the code they provide via their docs:
$url = 'https://api-v1.liondesk.com//';
$data = array(
'action' => 'NewSubmission',
'firstname' => 'Joe',
'lastname' => 'Smith',
'comments' => 'API Test',
'phone' => '555-1212',
'email' => '[email protected]',
'street_address' => '5937 Darwin Court',
'city' => 'San Diego',
'state' => 'CA',
'zip' => '92025',
'assigned_user_name' => 'Joe Smith',
'assigned_user_email' => '[email protected]',
'assigned_user_phone' => '760-123-1234',
'tag' => 'Buyer,92025,Listings Landing Page',
'sourcename' => 'Facebook Ad 1',
'contactid' => '12345',
'siteid' => '1'
);
$content = json_encode($data);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, TRUE);
curl_setopt($ch, CURLOPT_POSTFIELDS, $content);
curl_setopt($ch, CURLOPT_USERPWD, $APIKEY . ":" . "" );
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'X-LionDesk-Id: '.$USERKEY
));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
$result = curl_exec($ch);
$res = json_decode($result);
print_r($res);
curl_close($ch);
Link to their docs: https://api.liondesk.com/docs.html
Any help would be greatly appreciated.
I've attempted this with gems like 'rest-client' and 'rack', but am really having difficulties interpreting the php code from $ch = curl_init(); on downward.
curl_set_optare just setting options on the request, withrest_clientyou'd be doing same thing like setting the type of request, post body etc...