Class: NwsOpenapiSdk::HttpClient

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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

#openapiObject (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_agentObject (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