Sha256: 849cb08827384cb2dc956ca8c7d487e7a2a89c34441c61c1a6508c21c6167d54
Contents?: true
Size: 956 Bytes
Versions: 3
Compression:
Stored size: 956 Bytes
Contents
require 'faraday' require "json" module CocRb class << self attr_accessor :configuration end def self.configure @configuration ||= Configuration.new yield(configuration) end class Configuration attr_accessor :token, :url def initialize @token = nil @url = nil end end class Settings def self.get @conn = Faraday.new( url: CocRb.configuration.url, headers: { 'Content-Type' => 'application/json', 'Authorization' => "Bearer #{CocRb.configuration.token}" } ) rescue => e raise "Oops Unexpected error Caught!" puts e end end class ClashApi < Settings def self.call_api(status: false) get res = @conn.get(CocRb.configuration.url) if status res.status else val = res.body convert = JSON.parse(val) end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
cocRb-0.1.3 | lib/cocRb/api.rb |
cocRb-0.1.2 | lib/cocRb/api.rb |
cocRb-0.1.0 | lib/cocRb/api.rb |