class PlusAPI
Attributes
bilgi[RW]
token[RW]
Public Class Methods
new(token)
click to toggle source
# File lib/plusapi.rb, line 9 def initialize(token) @token = token @bilgi = "PlusAPI | Piyasa Verileri Sınıfı" end
Public Instance Methods
hisse_sepet()
click to toggle source
# File lib/plusapi.rb, line 39 def hisse_sepet() istek = istek_at("/hisse/sepet") return istek end
hisse_ver(sembol = "")
click to toggle source
# File lib/plusapi.rb, line 34 def hisse_ver(sembol = "") istek = istek_at("/hisse", sembol) return istek end
istek_at(endpoint, sembol = "")
click to toggle source
# File lib/plusapi.rb, line 14 def istek_at(endpoint, sembol = "") begin api = "http://plusapi.org/api" + endpoint + "?token=" + @token + ("&sembol=#{sembol}" if sembol != "").to_s uri = URI(api) res = Net::HTTP.get_response(uri) if res.is_a?(Net::HTTPSuccess) return JSON.parse(res.body) else return { error => "Bir hata oluştu sayfa boş döndü" } end rescue Errno::ECONNREFUSED return { error => "Sembol bulunamadı ya da bir hata oluştu", code => 500 } end end
kripto_haber()
click to toggle source
# File lib/plusapi.rb, line 49 def kripto_haber() istek = istek_at("/kripto/haber") return istek end
kripto_sepet()
click to toggle source
# File lib/plusapi.rb, line 54 def kripto_sepet() istek = istek_at("/kripto/sepet") return istek end
kripto_ver(sembol = "")
click to toggle source
# File lib/plusapi.rb, line 44 def kripto_ver(sembol = "") istek = istek_at("/kripto", sembol) return istek end