Sha256: a8e98a4b48cd45a1721e8ac1a0dde1488bb198ca140cc635567b2a1c2b9e815a

Contents?: true

Size: 737 Bytes

Versions: 1

Compression:

Stored size: 737 Bytes

Contents

module Bnet
  class WOW < Bnet::API
    def url
      super + "wow/"
    end

    def scoped(scope, args ={})
      api_key = args[:api_key] || Bnet.configuration.api_key
      locale = args[:locale] || 'en_US'
      realm = args[:realm]
      name = args[:name]

      call_url = url + "character/#{realm}/#{name}?fields=#{scope}&locale=#{locale}&apikey=#{api_key}"

      begin
        data = open(call_url)
        raw_response = JSON.parse(data.read)

        if data.status == ['200', 'OK'] && raw_response["code"] != 'NOTFOUND'
          raw_response
        else
          raw_response = {}
        end

      rescue OpenURI::HTTPError => e
        raw_response = {}
      end

      return raw_response[scope]
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
bnet-0.0.10 lib/bnet/wow.rb