Skip to content
This repository has been archived by the owner on Apr 9, 2024. It is now read-only.

Commit

Permalink
Made api keys required and added support for the news aes endpoint.
Browse files Browse the repository at this point in the history
  • Loading branch information
xMistt committed Jan 24, 2020
1 parent 06f7941 commit f19aeba
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion lib/fortniteapi/api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@ class FortniteAPI
CreativeNews = Struct.new(:image, :hidden, :messageType, :type, :adspace, :spotlight, :title, :body)
ShopItem = Struct.new(:regularPrice, :finalPrice, :isBundle, :giftable, :refundable, :panel, :sortPriority, :banner, :items)
CreatorCode = Struct.new(:id, :slug, :displayName, :status, :verified)
AES = Struct.new(:aes, :build, :lastUpdate)

def initialize(apikey=nil)
@apikey = apikey
@headers = {"x-api-key" => @apikey}

if apikey == nil
puts 'Warning: Next monday (Dec. 9th) at 8 PM (UTC) every endpoint will require an API-Key, you can get one at: fortnite-api.com.'
raise 'Not API key provided, this is now required. You can get one at: fortnite-api.com.'
end
end

Expand Down Expand Up @@ -146,4 +147,11 @@ def get_br_store(language='en')
br_store = [featured_items, daily_items]
br_store
end

def get_aes()
response = HTTParty.get("https://fortnite-api.com/aes", :headers => @headers)
data = JSON.parse(response.body)['data']
aes = AES.new(data['aes'], data['build'], x['lastUpdate'])
aes
end
end

0 comments on commit f19aeba

Please sign in to comment.