Class: NwsOpenapiSdk::HttpClient
- Inherits:
-
Object
- Object
- NwsOpenapiSdk::HttpClient
- Defined in:
- lib/nws_openapi_sdk/http_client.rb
Overview
A meta-programmed class that calls the API. After being instantiated, the instance will possess a method for every operationId in the API. The method will accept keyword arguments that corresponed to the {} placeholder values in the path.
Constant Summary collapse
- BASE_URL =
'https://api.weather.gov'
Instance Attribute Summary collapse
-
#openapi ⇒ Object
readonly
Returns the value of attribute openapi.
-
#user_agent ⇒ Object
readonly
Returns the value of attribute user_agent.
Instance Method Summary collapse
-
#initialize(user_agent) ⇒ HttpClient
constructor
A new instance of HttpClient.
Constructor Details
#initialize(user_agent) ⇒ HttpClient
Returns a new instance of HttpClient.
13 14 15 16 17 18 |
# File 'lib/nws_openapi_sdk/http_client.rb', line 13 def initialize(user_agent) @user_agent = user_agent @openapi = Openapi3Parser.load_url("#{BASE_URL}/openapi.json") create_methods! end |
Instance Attribute Details
#openapi ⇒ Object (readonly)
Returns the value of attribute openapi.
9 10 11 |
# File 'lib/nws_openapi_sdk/http_client.rb', line 9 def openapi @openapi end |
#user_agent ⇒ Object (readonly)
Returns the value of attribute user_agent.
9 10 11 |
# File 'lib/nws_openapi_sdk/http_client.rb', line 9 def user_agent @user_agent end |