Sha256: d20925be0932fd31913126d93dcc0e19b1b3865da42c5b421fbd6c45da47faca

Contents?: true

Size: 546 Bytes

Versions: 1

Compression:

Stored size: 546 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'] = 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.0 lib/one_api_sdk/requests.rb