Sha256: b73f07412cf6234731699e01c998fa517526e957dd1778eeaf4fb715f362f358

Contents?: true

Size: 964 Bytes

Versions: 1

Compression:

Stored size: 964 Bytes

Contents

# stdlib
require "date"
require "json"
require "net/http"
require "time"

# modules
require_relative "trend/client"
require_relative "trend/version"

module Trend
  class Error < StandardError; end

  def self.anomalies(*args)
    client.anomalies(*args)
  end

  def self.forecast(*args)
    client.forecast(*args)
  end

  def self.correlation(*args)
    client.correlation(*args)
  end

  def self.url
    @url ||= ENV["TREND_URL"] || hosted_url
  end

  def self.url=(url)
    @url = url
    @client = nil
  end

  def self.api_key
    @api_key ||= ENV["TREND_API_KEY"]
  end

  def self.api_key=(api_key)
    @api_key = api_key
    @client = nil
  end

  # private
  def self.client
    @client ||= Client.new
  end

  # private
  def self.hosted_url
    warn "[trend] WARNING: The hosted version is shutting down on May 1, 2024. See https://github.com/ankane/trend-api for how to run the API on your own infrastructure."
    "https://trendapi.org"
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
trend-0.2.1 lib/trend.rb