lib/gov_kit-ca/represent.rb in govkit-ca-0.0.11 vs lib/gov_kit-ca/represent.rb in govkit-ca-0.0.12
- old
+ new
@@ -1,9 +1,9 @@
module GovKit
module CA
# A Ruby wrapper for the Represent API.
- # @see http://represent.opennorth.ca/api/
+ # @see https://represent.opennorth.ca/api/
class Represent
# @param [Faraday::Connection] connection a Faraday connection
def initialize(connection = nil)
@client = connection || Faraday
end
@@ -12,11 +12,11 @@
#
# @param [Hash] opts optional arguments
# @option opts [String] :boundary_set a boundary set
# @option opts [Integer] :limit
# @option opts [Integer] :offset
- # @see http://represent.opennorth.ca/api/#boundaryset
+ # @see https://represent.opennorth.ca/api/#boundaryset
def boundary_sets(opts = {})
request(['boundary-sets', opts.delete(:boundary_set)], opts)
end
# Get boundaries.
@@ -29,11 +29,11 @@
# @option opts [Array<Float>,String] :contains comma-separated latitude and longitude
# @option opts [String] :touches a boundary
# @option opts [String] :intersects a boundary
# @option opts [Integer] :limit
# @option opts [Integer] :offset
- # @see http://represent.opennorth.ca/api/#boundary
+ # @see https://represent.opennorth.ca/api/#boundary
def boundaries(opts = {})
if Array === opts[:sets]
opts[:sets] = opts[:sets].join(',')
end
if Array === opts[:contains]
@@ -52,11 +52,11 @@
#
# @param [Hash] opts optional arguments
# @option opts [Array<String>,String] :sets comma-separated list of boundary sets
# @option opts [Integer] :limit
# @option opts [Integer] :offset
- # @see http://represent.opennorth.ca/api/#postcode
+ # @see https://represent.opennorth.ca/api/#postcode
def postcodes(postcode, opts = {})
if Array === opts[:sets]
opts[:sets] = opts[:sets].join(',')
end
request(['postcodes', PostalCode.format_postal_code(postcode)], opts)
@@ -66,11 +66,11 @@
#
# @param [Hash] opts optional arguments
# @option opts [String] :representative_set a representative set
# @option opts [Integer] :limit
# @option opts [Integer] :offset
- # @see http://represent.opennorth.ca/api/#representativeset
+ # @see https://represent.opennorth.ca/api/#representativeset
def representative_sets(opts = {})
request ['representative-sets', opts.delete(:representative_set)], opts
end
# Get representatives.
@@ -79,11 +79,11 @@
# @option opts [String] :representative_set a representative set
# @option opts [Array<Float>,String] :point a comma-separated latitude and longitude
# @option opts [Array<Strong>,String] :districts a comma-separated list of boundaries
# @option opts [Integer] :limit
# @option opts [Integer] :offset
- # @see http://represent.opennorth.ca/api/#representative
+ # @see https://represent.opennorth.ca/api/#representative
def representatives(opts = {})
if Array === opts[:point]
opts[:point] = opts[:point].join(',')
end
if Array === opts[:districts]
@@ -94,10 +94,10 @@
private
def request(parts, opts)
begin
- url = "http://represent.opennorth.ca/#{parts.compact.join('/')}/"
+ url = "https://represent.opennorth.ca/#{parts.compact.join('/')}/"
response = @client.get(url, opts)
case response.status
when 200
JSON.parse(response.body)
when 404