[{"data":1,"prerenderedAt":77},["Reactive",2],{"/samples/ruby/typhoeus":3,"related:LzJbwevAr8":59},{"_path":4,"_dir":5,"_draft":6,"_partial":6,"_locale":7,"title":8,"description":9,"language":10,"library":8,"link":11,"body":12,"_type":54,"_id":55,"_source":56,"_file":57,"_extension":58},"/samples/ruby/typhoeus","ruby",false,"","Typhoeus","Typhoeus is a parallel HTTP client library for Ruby that provides high-performance and asynchronous HTTP requests. It allows developers to make multiple HTTP requests simultaneously and handle responses asynchronously. Typhoeus is commonly used for making concurrent HTTP requests and improving the performance of web applications.","Ruby","https://github.com/typhoeus/typhoeus",{"type":13,"children":14,"toc":51},"root",[15,30,42],{"type":16,"tag":17,"props":18,"children":19},"element","p",{},[20,28],{"type":16,"tag":21,"props":22,"children":25},"a",{"href":11,"rel":23},[24],"nofollow",[26],{"type":27,"value":8},"text",{"type":27,"value":29}," is a parallel HTTP client library for Ruby that provides high-performance and asynchronous HTTP requests. It allows developers to make multiple HTTP requests simultaneously and handle responses asynchronously. Typhoeus is commonly used for making concurrent HTTP requests and improving the performance of web applications.",{"type":16,"tag":31,"props":32,"children":36},"pre",{"className":33,"code":35,"language":5,"meta":7},[34],"language-ruby","require 'typhoeus'\nrequire 'json'\n\ndef convert(api_key, params, endpoint = 'pdf')\n  # Ensure the endpoint is valid\n  unless %w[pdf png jpg webp].include?(endpoint)\n    raise ArgumentError, 'Invalid endpoint specified'\n  end\n\n  # Set the API URL\n  url = \"https://api.pdfshift.io/v3/convert/#{endpoint}\"\n\n  # Make the POST request\n  response = Typhoeus.post(url, body: params.to_json, headers: {\n    'Content-Type' => 'application/json',\n    'X-API-Key' => api_key\n  })\n\n  # Check for successful response\n  unless response.success?\n    raise \"Request failed with status code #{response.code}: #{response.body}\"\n  end\n\n  # Return the response based on the presence of filename or webhook\n  response_body.key?('filename') || response_body.key?('webhook') ? JSON.parse(response.body) : response.body\nend\n",[37],{"type":16,"tag":38,"props":39,"children":40},"code",{"__ignoreMap":7},[41],{"type":27,"value":35},{"type":16,"tag":31,"props":43,"children":46},{"className":44,"code":45,"language":5,"meta":7},[34],"begin\n  result = convert('sk_XXXXXXXXXXXXXX', {'source' => 'https://en.wikipedia.org/wiki/REST'})\n  puts result\nrescue StandardError => e\n  puts \"Error: #{e.message}\"\nend\n",[47],{"type":16,"tag":38,"props":48,"children":49},{"__ignoreMap":7},[50],{"type":27,"value":45},{"title":7,"searchDepth":52,"depth":52,"links":53},2,[],"markdown","content:samples:ruby:typhoeus.md","content","samples/ruby/typhoeus.md","md",[60,64,68,72,76],{"_path":61,"language":10,"library":62,"_id":63},"/samples/ruby/faraday","Faraday","content:samples:ruby:faraday.md",{"_path":65,"language":10,"library":66,"_id":67},"/samples/ruby/httpparty","HttpParty","content:samples:ruby:httpparty.md",{"_path":69,"language":10,"library":70,"_id":71},"/samples/ruby/nethttp","Net::HTTP","content:samples:ruby:nethttp.md",{"_path":73,"language":10,"library":74,"_id":75},"/samples/ruby/restclient","RestClient","content:samples:ruby:restclient.md",{"_path":4,"language":10,"library":8,"_id":55},1785426823518]