Sha256: 8906ae58629c413f4fef8434a812eaeb2cb7cf53ed1fcf04bf4caceada943efa

Contents?: true

Size: 560 Bytes

Versions: 1

Compression:

Stored size: 560 Bytes

Contents

# frozen_string_literal: true

require 'rails/all'
require 'net/http'
require 'uri'
require 'json'
require 'dotenv/load'

module OneApiSdk
  module Requests
    BASE_URL="https://the-one-api.dev/v2/"

    def get(path)
      uri = URI(BASE_URL + (path || ''))

      http = Net::HTTP.new(uri.host, uri.port)
      http.use_ssl = true

      request = Net::HTTP::Get.new(uri)
      request['Authorization'] = "Bearer " + (ENV['THE_ONE_API_KEY'] || Rails.application&.credentials&.the_one_api_key)

      JSON.parse(http.request(request).body)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
one_api_sdk-alex-0.1.1 lib/one_api_sdk/requests.rb