Class: YACCL::Services::Internal::BrowserBindingService::Basement

Inherits:
Object
  • Object
show all
Defined in:
lib/yaccl/services/internal/browser_binding_service.rb

Instance Method Summary collapse

Constructor Details

#initialize(user, pass) ⇒ Basement

Returns a new instance of Basement.



130
131
132
133
# File 'lib/yaccl/services/internal/browser_binding_service.rb', line 130

def initialize(user, pass)
  @username = user
  @password = pass
end

Instance Method Details

#get(params) ⇒ Object



135
136
137
138
139
140
141
142
143
144
145
# File 'lib/yaccl/services/internal/browser_binding_service.rb', line 135

def get(params)
  Typhoeus::Request.new(
    params[:url],
    userpwd: "#{@username}:#{@password}",
    method: :get,
    body: params[:body],
    params: params[:query],
    headers: params[:headers],
    followlocation: true
  ).run
end

#multipart_post(url, options, headers) ⇒ Object



158
159
160
161
162
163
164
165
# File 'lib/yaccl/services/internal/browser_binding_service.rb', line 158

def multipart_post(url, options, headers)
  url = URI.parse(url)
  req = Net::HTTP::Post::Multipart.new(url.path, options)
  headers.each {|key, value| req[key] = value }
  req.basic_auth @username, @password unless @username.nil?
  opts = url.scheme == 'https' ? { use_ssl: true , verify_mode: OpenSSL::SSL::VERIFY_NONE } : {}
  Net::HTTP.start(url.host, url.port, opts) { |http| http.request(req) }
end

#post(params) ⇒ Object



147
148
149
150
151
152
153
154
155
156
# File 'lib/yaccl/services/internal/browser_binding_service.rb', line 147

def post(params)            
  Typhoeus::Request.new(
    params[:url],
    userpwd: "#{@username}:#{@password}",
    method: :post,
    body: params[:body],
    params: params[:query],
    headers: params[:headers]
  ).run
end