Sha256: 083f62828f3c480e7b0d26e2371638adb74e4bfbf02c84cf66269dd594647848
Contents?: true
Size: 1.34 KB
Versions: 1
Compression:
Stored size: 1.34 KB
Contents
module FootStats # Class responsible to make the request to the FootStats API # # @example # # Request.new('ListaCampeonatos') # class Request attr_reader :response_body, :resource_name, :resource_key, :logger def initialize(resource, options={}) @resource_name = resource.resource_name @resource_key = resource.resource_key @response_body = post(options) @logger = Setup.logger end # Return the request uri based on the resource. # # @return [String] # def request_url "#{Setup.base_url}/#{resource_name}" end # Make the post request to the request url. # # @return [String] # def post(options) log "POST #{request_url}" response = RestClient.post(request_url, setup_params.merge(options)) log "RESPONSE BODY:\n#{response}" response end # Parse the "XML"/ "JSON". # # @return [Response] # def parse(options = {}) Response.new({resource_key: @resource_key, body: @response_body}.merge options) end # Passing the setup params configured in your app. # # @return [Hash] # def setup_params { :Usuario => Setup.username, :Senha => Setup.password } end protected def log(message) logger.info(message + "\n") if logger end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
foot_stats-0.1.0 | lib/foot_stats/request.rb |