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.



135
136
137
138
# File 'lib/yaccl/services/internal/browser_binding_service.rb', line 135

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

Instance Method Details

#get(params) ⇒ Object



140
141
142
143
144
145
146
147
148
149
150
# File 'lib/yaccl/services/internal/browser_binding_service.rb', line 140

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



163
164
165
166
167
168
169
170
# File 'lib/yaccl/services/internal/browser_binding_service.rb', line 163

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



152
153
154
155
156
157
158
159
160
161
# File 'lib/yaccl/services/internal/browser_binding_service.rb', line 152

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