[{"data":1,"prerenderedAt":215},["Reactive",2],{"/samples/ruby":3},[4,60,99,138,177],{"_path":5,"_dir":6,"_draft":7,"_partial":7,"_locale":8,"title":9,"description":10,"language":11,"library":9,"link":12,"body":13,"_type":55,"_id":56,"_source":57,"_file":58,"_extension":59},"/samples/ruby/faraday","ruby",false,"","Faraday","Faraday is an HTTP client library for Ruby that provides a flexible and modular API for making HTTP requests and handling responses. It supports middleware, which allows developers to customize the behavior of requests and responses. Faraday is commonly used for interacting with web services and consuming APIs in Ruby applications.","Ruby","https://lostisland.github.io/faraday/",{"type":14,"children":15,"toc":52},"root",[16,31,43],{"type":17,"tag":18,"props":19,"children":20},"element","p",{},[21,29],{"type":17,"tag":22,"props":23,"children":26},"a",{"href":12,"rel":24},[25],"nofollow",[27],{"type":28,"value":9},"text",{"type":28,"value":30}," is an HTTP client library for Ruby that provides a flexible and modular API for making HTTP requests and handling responses. It supports middleware, which allows developers to customize the behavior of requests and responses. Faraday is commonly used for interacting with web services and consuming APIs in Ruby applications.",{"type":17,"tag":32,"props":33,"children":37},"pre",{"className":34,"code":36,"language":6,"meta":8},[35],"language-ruby","require 'faraday'\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  # Create a Faraday connection\n  conn = Faraday.new(url: url) do |faraday|\n    faraday.request :url_encoded\n    faraday.adapter Faraday.default_adapter\n  end\n\n  # Make the POST request\n  response = conn.post do |req|\n    req.headers['Content-Type'] = 'application/json'\n    req.headers['X-API-Key'] = api_key\n    req.body = params.to_json\n  end\n\n  # Check for successful response\n  unless response.success?\n    raise \"Request failed with status code #{response.status}: #{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",[38],{"type":17,"tag":39,"props":40,"children":41},"code",{"__ignoreMap":8},[42],{"type":28,"value":36},{"type":17,"tag":32,"props":44,"children":47},{"className":45,"code":46,"language":6,"meta":8},[35],"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",[48],{"type":17,"tag":39,"props":49,"children":50},{"__ignoreMap":8},[51],{"type":28,"value":46},{"title":8,"searchDepth":53,"depth":53,"links":54},2,[],"markdown","content:samples:ruby:faraday.md","content","samples/ruby/faraday.md","md",{"_path":61,"_dir":6,"_draft":7,"_partial":7,"_locale":8,"title":62,"description":63,"language":11,"library":64,"link":12,"body":65,"_type":55,"_id":97,"_source":57,"_file":98,"_extension":59},"/samples/ruby/httpparty","Httpparty","HTTParty is a Ruby HTTP client library that provides a simple and intuitive API for making HTTP requests and handling responses. It abstracts away the complexities of HTTP communication and provides features like automatic parsing of JSON and XML responses, request timeouts, and response caching.","HttpParty",{"type":14,"children":66,"toc":95},[67,78,87],{"type":17,"tag":18,"props":68,"children":69},{},[70,76],{"type":17,"tag":22,"props":71,"children":73},{"href":12,"rel":72},[25],[74],{"type":28,"value":75},"HTTParty",{"type":28,"value":77}," is a Ruby HTTP client library that provides a simple and intuitive API for making HTTP requests and handling responses. It abstracts away the complexities of HTTP communication and provides features like automatic parsing of JSON and XML responses, request timeouts, and response caching.",{"type":17,"tag":32,"props":79,"children":82},{"className":80,"code":81,"language":6,"meta":8},[35],"require 'httparty'\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  # Set headers\n  headers = {\n    'Content-Type' => 'application/json',\n    'X-API-Key' => api_key\n  }\n\n  # Make the POST request\n  response = HTTParty.post(url, body: params.to_json, headers: headers)\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",[83],{"type":17,"tag":39,"props":84,"children":85},{"__ignoreMap":8},[86],{"type":28,"value":81},{"type":17,"tag":32,"props":88,"children":90},{"className":89,"code":46,"language":6,"meta":8},[35],[91],{"type":17,"tag":39,"props":92,"children":93},{"__ignoreMap":8},[94],{"type":28,"value":46},{"title":8,"searchDepth":53,"depth":53,"links":96},[],"content:samples:ruby:httpparty.md","samples/ruby/httpparty.md",{"_path":100,"_dir":6,"_draft":7,"_partial":7,"_locale":8,"title":101,"description":102,"language":11,"library":103,"link":104,"body":105,"_type":55,"_id":136,"_source":57,"_file":137,"_extension":59},"/samples/ruby/nethttp","Nethttp","Net::HTTP is a built-in HTTP client library for Ruby that provides basic functionality for making HTTP requests and handling responses. It is part of the Ruby standard library and offers a simple API for sending requests and receiving responses from web servers.","Net::HTTP","https://ruby-doc.org/stdlib-2.7.0/libdoc/net/http/rdoc/Net/HTTP.html",{"type":14,"children":106,"toc":134},[107,117,126],{"type":17,"tag":18,"props":108,"children":109},{},[110,115],{"type":17,"tag":22,"props":111,"children":113},{"href":104,"rel":112},[25],[114],{"type":28,"value":103},{"type":28,"value":116}," is a built-in HTTP client library for Ruby that provides basic functionality for making HTTP requests and handling responses. It is part of the Ruby standard library and offers a simple API for sending requests and receiving responses from web servers.",{"type":17,"tag":32,"props":118,"children":121},{"className":119,"code":120,"language":6,"meta":8},[35],"require 'net/http'\nrequire 'uri'\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 = URI(\"https://api.pdfshift.io/v3/convert/#{endpoint}\")\n\n  # Create a Net::HTTP instance\n  http = Net::HTTP.new(url.host, url.port)\n  http.use_ssl = true\n\n  # Create the request\n  request = Net::HTTP::Post.new(url)\n  request['Content-Type'] = 'application/json'\n  request['X-API-Key'] = api_key\n  request.body = params.to_json\n\n  # Send the request and handle the response\n  response = http.request(request)\n\n  # Check for successful response\n  unless response.is_a?(Net::HTTPSuccess)\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",[122],{"type":17,"tag":39,"props":123,"children":124},{"__ignoreMap":8},[125],{"type":28,"value":120},{"type":17,"tag":32,"props":127,"children":129},{"className":128,"code":46,"language":6,"meta":8},[35],[130],{"type":17,"tag":39,"props":131,"children":132},{"__ignoreMap":8},[133],{"type":28,"value":46},{"title":8,"searchDepth":53,"depth":53,"links":135},[],"content:samples:ruby:nethttp.md","samples/ruby/nethttp.md",{"_path":139,"_dir":6,"_draft":7,"_partial":7,"_locale":8,"title":140,"description":141,"language":11,"library":142,"link":143,"body":144,"_type":55,"_id":175,"_source":57,"_file":176,"_extension":59},"/samples/ruby/restclient","Restclient","RestClient is a simple and lightweight HTTP client library for Ruby. It provides a user-friendly API for making HTTP requests and handling responses. RestClient abstracts away the complexities of HTTP communication and provides features like automatic URL encoding, response handling, and exception handling.","RestClient","https://github.com/rest-client/rest-client",{"type":14,"children":145,"toc":173},[146,156,165],{"type":17,"tag":18,"props":147,"children":148},{},[149,154],{"type":17,"tag":22,"props":150,"children":152},{"href":143,"rel":151},[25],[153],{"type":28,"value":142},{"type":28,"value":155}," is a simple and lightweight HTTP client library for Ruby. It provides a user-friendly API for making HTTP requests and handling responses. RestClient abstracts away the complexities of HTTP communication and provides features like automatic URL encoding, response handling, and exception handling.",{"type":17,"tag":32,"props":157,"children":160},{"className":158,"code":159,"language":6,"meta":8},[35],"require 'rest-client'\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 = RestClient.post(url, params.to_json, {\n    'Content-Type' => 'application/json',\n    'X-API-Key' => api_key\n  })\n\n  # Check for successful response\n  unless response.code == 200\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",[161],{"type":17,"tag":39,"props":162,"children":163},{"__ignoreMap":8},[164],{"type":28,"value":159},{"type":17,"tag":32,"props":166,"children":168},{"className":167,"code":46,"language":6,"meta":8},[35],[169],{"type":17,"tag":39,"props":170,"children":171},{"__ignoreMap":8},[172],{"type":28,"value":46},{"title":8,"searchDepth":53,"depth":53,"links":174},[],"content:samples:ruby:restclient.md","samples/ruby/restclient.md",{"_path":178,"_dir":6,"_draft":7,"_partial":7,"_locale":8,"title":179,"description":180,"language":11,"library":179,"link":181,"body":182,"_type":55,"_id":213,"_source":57,"_file":214,"_extension":59},"/samples/ruby/typhoeus","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.","https://github.com/typhoeus/typhoeus",{"type":14,"children":183,"toc":211},[184,194,203],{"type":17,"tag":18,"props":185,"children":186},{},[187,192],{"type":17,"tag":22,"props":188,"children":190},{"href":181,"rel":189},[25],[191],{"type":28,"value":179},{"type":28,"value":193}," 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":17,"tag":32,"props":195,"children":198},{"className":196,"code":197,"language":6,"meta":8},[35],"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",[199],{"type":17,"tag":39,"props":200,"children":201},{"__ignoreMap":8},[202],{"type":28,"value":197},{"type":17,"tag":32,"props":204,"children":206},{"className":205,"code":46,"language":6,"meta":8},[35],[207],{"type":17,"tag":39,"props":208,"children":209},{"__ignoreMap":8},[210],{"type":28,"value":46},{"title":8,"searchDepth":53,"depth":53,"links":212},[],"content:samples:ruby:typhoeus.md","samples/ruby/typhoeus.md",1785426823022]