Class: RateCenter::DataSource::LocalCallingGuide::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/rate_center/data_source/local_calling_guide.rb

Constant Summary collapse

HOST =
"https://localcallingguide.com/".freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(**options) ⇒ Client

Returns a new instance of Client.



55
56
57
58
59
# File 'lib/rate_center/data_source/local_calling_guide.rb', line 55

def initialize(**options)
  @host = options.fetch(:host, HOST)
  @http_client = options.fetch(:http_client) { default_http_client }
  @response_parser = options.fetch(:response_parser) { ResponseParser.new }
end

Instance Attribute Details

#hostObject (readonly)

Returns the value of attribute host.



53
54
55
# File 'lib/rate_center/data_source/local_calling_guide.rb', line 53

def host
  @host
end

#http_clientObject (readonly)

Returns the value of attribute http_client.



53
54
55
# File 'lib/rate_center/data_source/local_calling_guide.rb', line 53

def http_client
  @http_client
end

#response_parserObject (readonly)

Returns the value of attribute response_parser.



53
54
55
# File 'lib/rate_center/data_source/local_calling_guide.rb', line 53

def response_parser
  @response_parser
end

Instance Method Details

#fetch_rate_center_data(params) ⇒ Object



61
62
63
64
# File 'lib/rate_center/data_source/local_calling_guide.rb', line 61

def fetch_rate_center_data(params)
  response = fetch_xml(url: "/xmlrc.php", params:)
  response_parser.parse(response.body, keys: "rcdata")
end