Guest User

Untitled

a guest
Jun 4th, 2017
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 1.02 KB | None | 0 0
  1. class AlbumRequest
  2.  
  3.   REQUEST_HEADERS = {
  4.       'Content-Type' => 'application/x-www-form-urlencoded',
  5.       'User-Agent' => '...',
  6.       'Connection' => 'keep-alive',
  7.       'Accept' => 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8'
  8.   }
  9.  
  10.   OPTIONS = {
  11.     timeout: 15,
  12.     method: :post,
  13.     headers: REQUEST_HEADERS
  14.   }
  15.  
  16.   attr_reader :url
  17.  
  18.   def initailize(url)
  19.     @url = url
  20.   end
  21.  
  22.   def perform
  23.      Typhoeus::Request.new(url, OPTIONS).run
  24.   end
  25.  
  26. end
  27.  
  28. class SingleRequest
  29.  
  30.   REQUEST_HEADERS = {
  31.       'Content-Type' => 'application/x-www-form-urlencoded',
  32.       'User-Agent' => '...',
  33.       'Connection' => 'keep-alive',
  34.       'Accept' => 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8'
  35.   }
  36.  
  37.   OPTIONS = {
  38.     timeout: 10,
  39.     method: :get,
  40.     headers: REQUEST_HEADERS
  41.   }
  42.  
  43.   attr_reader :url
  44.  
  45.   def initialize(url)
  46.     @url = url
  47.   end
  48.  
  49.   def perform
  50.      Typhoeus::Request.new(url, OPTIONS).run
  51.   end
  52.  
  53. end
Add Comment
Please, Sign In to add comment