Class: ServiceCall
- Inherits:
-
Object
- Object
- ServiceCall
- Defined in:
- lib/etvnet_seek/core/service_call.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Instance Method Summary collapse
- #get ⇒ Object
-
#initialize(url) ⇒ ServiceCall
constructor
A new instance of ServiceCall.
- #post(params, headers, url = @url) ⇒ Object
Constructor Details
#initialize(url) ⇒ ServiceCall
Returns a new instance of ServiceCall.
20 21 22 |
# File 'lib/etvnet_seek/core/service_call.rb', line 20 def initialize(url) @url = url end |
Instance Attribute Details
#url ⇒ Object (readonly)
Returns the value of attribute url.
18 19 20 |
# File 'lib/etvnet_seek/core/service_call.rb', line 18 def url @url end |
Instance Method Details
#get ⇒ Object
24 25 26 |
# File 'lib/etvnet_seek/core/service_call.rb', line 24 def get open(url, "User-Agent" => "Ruby/#{RUBY_VERSION}") end |
#post(params, headers, url = @url) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/etvnet_seek/core/service_call.rb', line 28 def post params, headers, url = @url request = Net::HTTP::Post.new(url, headers.merge({"User-Agent" => "Ruby/#{RUBY_VERSION}"})) request.set_form_data(params) #request.basic_auth(un, pw) #"Content-Type"=>"application/x-www-form-urlencoded", #"Authorization" => "Basic " + Base64::encode64("account:password") response = request(request, url) if response.class == Net::HTTPMovedPermanently response = handle_redirect response['location'], params, headers end response end |