Sha256: e75a3bc059aa7e230aa7ee0ce18533486597790a2ec18a753c3045d4f84dbed5
Contents?: true
Size: 1.56 KB
Versions: 2
Compression:
Stored size: 1.56 KB
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:"https://api.clashofclans.com" , headers: { 'Content-Type' => 'application/json', 'Authorization' => "Bearer #{CocRb.configuration.token}" } ) rescue => e raise "Oops Unexpected error Caught!" puts e end end class Label < Settings # This method gets Labels for the Player Profile. def self.get_LabelPlayer(_limit:false, status: false) get res = @conn.get("v1/labels/players") do |req| req.params[:limit] = _limit if _limit end if status res.status else val = res.body convert = JSON.parse(val) end end # This method gets Labels for the Clan Profile. def self.get_LabelClan(_limit:false, status: false) get res = @conn.get("v1/labels/clans") do |req| req.params[:limit] = _limit if _limit end if status res.status else val = res.body convert = JSON.parse(val) end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
cocRb-1.1.5 | lib/cocRb/labels.rb |
cocRb-0.1.5 | lib/cocRb/labels.rb |