Class: RateCenter::DataSource::LocalCallingGuide::Client
- Inherits:
-
Object
- Object
- RateCenter::DataSource::LocalCallingGuide::Client
- Defined in:
- lib/rate_center/data_source/local_calling_guide.rb
Constant Summary collapse
- HOST =
"https://localcallingguide.com/".freeze
Instance Attribute Summary collapse
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#http_client ⇒ Object
readonly
Returns the value of attribute http_client.
-
#response_parser ⇒ Object
readonly
Returns the value of attribute response_parser.
Instance Method Summary collapse
- #fetch_rate_center_data(params) ⇒ Object
-
#initialize(**options) ⇒ Client
constructor
A new instance of Client.
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(**) @host = .fetch(:host, HOST) @http_client = .fetch(:http_client) { default_http_client } @response_parser = .fetch(:response_parser) { ResponseParser.new } end |
Instance Attribute Details
#host ⇒ Object (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_client ⇒ Object (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_parser ⇒ Object (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 |