Module: Purtea::FFLogs

Defined in:
lib/purtea/fflogs.rb,
lib/purtea/fflogs/api.rb,
lib/purtea/fflogs/fight.rb

Defined Under Namespace

Classes: API, Fight

Constant Summary collapse

BASE_URL =
'https://www.fflogs.com'
API_URL =
"#{BASE_URL}/api/v2/client"
SCHEMA_FILE =
File.expand_path('../../fflogs_schema.json', __dir__)
HTTP =
GraphQL::Client::HTTP.new(API_URL) do
  def headers(context)
    unless (token = context[:access_token])
      raise 'Missing FF Logs access token'
    end

    {
      'Authorization' => "Bearer #{token}"
    }
  end
end
CLIENT =
GraphQL::Client.new(
  schema: SCHEMA_FILE,
  execute: HTTP
)
GET_FIGHTS_QUERY =
CLIENT.parse "  query($code: String) {\n    reportData {\n      report(code: $code) {\n        startTime\n        endTime\n        fights {\n          id\n          encounterID\n          gameZone {\n            id\n            name\n          }\n          name\n          difficulty\n          bossPercentage\n          fightPercentage\n          startTime\n          endTime\n          kill\n        }\n      }\n    }\n    rateLimitData {\n      limitPerHour\n      pointsResetIn\n      pointsSpentThisHour\n    }\n  }\n"
TOKEN_FILE =
Purtea::Config.resolve_file(
  'fflogs_token.json',
  create_dir: true
)
EXPIRATION_THRESHOLD =
30