Sha256: e880d52bc728e56542151b5d481e38e654e68a4cce9d4f52430b3a425d2ef19e

Contents?: true

Size: 643 Bytes

Versions: 1

Compression:

Stored size: 643 Bytes

Contents

require 'faraday'

module Snowreports
  class Fetcher
    BASE_PATH = "https://www.snowhq.com/"

    class << self
      attr_accessor :user, :pass
    end

    def self.fetch(snowhq_id:)
      snowhq_path = "/feeds/xml?reportid=#{snowhq_id}"
      conn.get(snowhq_path)
    end

    def self.conn
      @conn ||= begin
        conn = Faraday.new(url: BASE_PATH)
        snow_user = user || ENV["SNOW_USER"]
        snow_pass = pass || ENV["SNOW_PASS"]

        raise "You must supply a username and password for API access" unless snow_user && snow_pass

        conn.basic_auth(snow_user, snow_pass)
        conn
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
snowreports-0.4.0 lib/snowreports/fetcher.rb