Update to bls tls

This commit is contained in:
Dan Buch 2016-12-20 17:58:39 -05:00
parent 28841035af
commit 3a56880720
No known key found for this signature in database
GPG Key ID: FAEF12936DD3E3EC
2 changed files with 11 additions and 9 deletions

View File

@ -1,14 +1,14 @@
# cpi-feed
Transforms [this](http://api.bls.gov/publicAPI/v2/timeseries/data/CUUSA210SA0)
into [this](http://s3.amazonaws.com/meatballhat/cpi/current.csv) :tada:.
Transforms [this](https://api.bls.gov/publicAPI/v2/timeseries/data/CUUSA210SA0)
into [this](https://s3.amazonaws.com/meatballhat/cpi/current.csv) :tada:.
## usage
This is intended for use with Google Sheets via:
```
=IMPORTDATA("http://s3.amazonaws.com/meatballhat/cpi/current.csv")
=IMPORTDATA("https://s3.amazonaws.com/meatballhat/cpi/current.csv")
```
## deployment

View File

@ -1,11 +1,12 @@
#!/usr/bin/env ruby
require 'uri'
require 'net/http'
require 'json'
require 'net/http'
require 'net/https'
require 'uri'
class CPIFetcher
DEFAULT_CPI_SERIES_URL = 'http://api.bls.gov/publicAPI/v2/timeseries/data/CUUSA210SA0'.freeze
DEFAULT_CPI_SERIES_URL = 'https://api.bls.gov/publicAPI/v2/timeseries/data/CUUSA210SA0'.freeze
attr_reader :url, :bls_token
def initialize
@ -26,9 +27,10 @@ class CPIFetcher
private
def fetch_raw_response
res = Net::HTTP.start(url.hostname, url.port) do |http|
http.request(build_request)
end
http = Net::HTTP.new(url.hostname, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_PEER
res = http.request(build_request)
JSON.parse(res.body)
end