class BROpenData::ParentService

Attributes

domain[RW]
params[RW]

API attrs

path[RW]

Base URL builder Attributes

Public Class Methods

new() click to toggle source

init/new

# File lib/br_open_data/parent_service.rb, line 15
def initialize
end

Private Instance Methods

get_request(hash=true) click to toggle source

send GET HTTP request

# File lib/br_open_data/parent_service.rb, line 30
def get_request(hash=true)
  resp = RestClient.get get_url
  hash ? Hash.from_xml(resp).it_keys_to_sym : resp
end
get_url() click to toggle source

Build an GET URL base on the end_point & it path

# File lib/br_open_data/parent_service.rb, line 25
def get_url
  "http://#{self.domain}/#{self.path}#{self.params.it_keys_to_get_param}"
end
perform_get_request() click to toggle source

Validate & perform the request

# File lib/br_open_data/parent_service.rb, line 36
def perform_get_request
  # Validate preventing request error

  # setup params, like API Key if needed

  # Perform the request
  get_request
end
url() click to toggle source

Build an URL base on the end_point & it path

# File lib/br_open_data/parent_service.rb, line 20
def url
  "http://#{self.domain}/#{self.path}"
end