Class: SMSAPI::Method::HTTP

Inherits:
Base
  • Object
show all
Defined in:
lib/smsapi/method/http.rb

Constant Summary

HTTP_URL =
'http://api.smsapi.pl/sms.do'
HTTPS_URL =
'https://ssl.smsapi.pl/sms.do'

Instance Attribute Summary

Attributes inherited from Base

#request, #response

Instance Method Summary collapse

Instance Method Details

#build_request(params) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/smsapi/method/http.rb', line 9

def build_request(params)
  if params[:to].is_a? Array
    params[:to] = params[:to].join ','
  else
    params[:to] = params[:to].to_s
  end
  
  @request = URI(self.url)
  @request.query = URI.encode_www_form(params)
  
  return @request
end

#send_requestObject



22
23
24
25
26
27
28
# File 'lib/smsapi/method/http.rb', line 22

def send_request()
  case ::SMSAPI::Config.http_method
    when :get then @response = Net::HTTP.get_response(@request)
    when :post then @response = Net::HTTP.post_form(@request)
    else raise ::SMSAPI::Exception::UnknownHTTPMethod
  end
end