fortniteapi 0.0.4 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/fortniteapi/api.rb +21 -9
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9356d56bb89faa1c7b3c786ba9ca46ec20bdd6e018b6cbc6a85aa31e68aad532
4
- data.tar.gz: 3db50bb8c90b4e6807fe742f808f3c1baf0d5c25b8705cbc92abf0b29c3674d0
3
+ metadata.gz: 2e3e2f27e86720658fc956271dcb50897c5eb48570c8cdc9717b6d20cde7aceb
4
+ data.tar.gz: b9ac72d9c98b6d2d5636136cf9939327206dacbd0a3c398557be7a3626979bd1
5
5
  SHA512:
6
- metadata.gz: e07b7de916d4898889c2de430289901010a5fefd9b73daf0ff509c523a521cf3f228f61b258fc988c4eaa48481ad28deb3a36afd4f288c930e49d4a749a09261
7
- data.tar.gz: 81c63bed578fd95a5aae101406c7f207826f0182e2a0a54456a112d9b51c2fdde7cbe5c7f354af18c7056aefed4a24996b7d64ea8b873c09695aba4fb256b567
6
+ metadata.gz: bed51c5ae277e4df54e275df02a27fd13f1b09b09621434d3210f537b7f72c9b4e91e3084c8d5afb5b298172305f48c8a9f482270b47f8302b8b42aafc5c780e
7
+ data.tar.gz: c8677772acd71a067e17fe47bb8153ca4f17c2058a091d56c66eea73f8b77290ddd1502d0373feea610fd5cfc85ea6fbbee175ae54bb421da37652707107c312
@@ -7,14 +7,19 @@ class FortniteAPI
7
7
  CreativeNews = Struct.new(:image, :hidden, :messageType, :type, :adspace, :spotlight, :title, :body)
8
8
  ShopItem = Struct.new(:regularPrice, :finalPrice, :isBundle, :giftable, :refundable, :panel, :sortPriority, :banner, :items)
9
9
  CreatorCode = Struct.new(:id, :slug, :displayName, :status, :verified)
10
+ AES = Struct.new(:aes, :build, :lastUpdate)
10
11
 
11
12
  def initialize(apikey=nil)
12
13
  @apikey = apikey
13
14
  @headers = {"x-api-key" => @apikey}
15
+
16
+ if apikey == nil
17
+ raise 'Not API key provided, this is now required. You can get one at: fortnite-api.com.'
18
+ end
14
19
  end
15
20
 
16
21
  def search_cosmetic(searchQuery, tag='name', language='en', searchLanguage='en')
17
- response = HTTParty.get("https://fortnite-api.com/cosmetics/br/search?#{tag}=#{searchQuery}&language=#{language}&searchLanguage=#{searchLanguage}", :headers => headers)
22
+ response = HTTParty.get("https://fortnite-api.com/cosmetics/br/search?#{tag}=#{searchQuery}&language=#{language}&searchLanguage=#{searchLanguage}", :headers => @headers)
18
23
  body = JSON.parse(response.body)['data']
19
24
  if response.code == 200
20
25
  searchResult = BRCosmetic.new(body['id'], body['type'], body['backendType'], body['rarity'], body['displayRarity'], body['backendRarity'], body['name'], body['shortDescription'], body['description'], body['set'], body['setText'], body['backendSeries'], body['images'], body['variants'], body['gameplayTags'], body['displayAssetPath'], body['definition'], body['requiredItemId'], body['builtInEmoteId'], body['path'], body['lastUpdate'], body['added'])
@@ -35,14 +40,14 @@ class FortniteAPI
35
40
  end
36
41
 
37
42
  def get_creator_code(slug)
38
- response = HTTParty.get("https://fortnite-api.com/creatorcode/search?slug=#{slug}", :headers => headers)
43
+ response = HTTParty.get("https://fortnite-api.com/creatorcode/search?slug=#{slug}", :headers => @headers)
39
44
  body = JSON.parse(response.body)['data']
40
45
  supportACreator = CreatorCode.new(body['id'], body['slug'], body['displayName'], body['status'], body['verified'])
41
46
  supportACreator
42
47
  end
43
48
 
44
49
  def search_cosmetic_id(searchQuery, language='en')
45
- response = HTTParty.get("https://fortnite-api.com/cosmetics/br/#{searchQuery}&language=#{language}", :headers => headers)
50
+ response = HTTParty.get("https://fortnite-api.com/cosmetics/br/#{searchQuery}&language=#{language}", :headers => @headers)
46
51
  body = JSON.parse(response.body)['data']
47
52
  if response.code == 200
48
53
  searchResult = BRCosmetic.new(body['id'], body['type'], body['backendType'], body['rarity'], body['displayRarity'], body['backendRarity'], body['name'], body['shortDescription'], body['description'], body['set'], body['setText'], body['backendSeries'], body['images'], body['variants'], body['gameplayTags'], body['displayAssetPath'], body['definition'], body['requiredItemId'], body['builtInEmoteId'], body['path'], body['lastUpdate'], body['added'])
@@ -64,7 +69,7 @@ class FortniteAPI
64
69
 
65
70
  def search_cosmetics(searchQuery, tag='name', language='en', searchLanguage='en')
66
71
  cosmetics = []
67
- response = HTTParty.get("https://fortnite-api.com/cosmetics/br/search/all?#{tag}=#{searchQuery}&language=#{language}&searchLanguage=#{searchLanguage}", :headers => headers)
72
+ response = HTTParty.get("https://fortnite-api.com/cosmetics/br/search/all?#{tag}=#{searchQuery}&language=#{language}&searchLanguage=#{searchLanguage}", :headers => @headers)
68
73
  body = JSON.parse(response.body)['data']
69
74
  if response.code == 200
70
75
  for x in body
@@ -88,13 +93,13 @@ class FortniteAPI
88
93
  end
89
94
 
90
95
  def all_cosmetics()
91
- response = HTTParty.get("https://fortnite-api.com/cosmetics/br", :headers => headers)
96
+ response = HTTParty.get("https://fortnite-api.com/cosmetics/br", :headers => @headers)
92
97
  JSON.parse(response.body)
93
98
  end
94
99
 
95
100
  def get_br_news(language='en')
96
101
  br_news_list = []
97
- response = HTTParty.get("https://fortnite-api.com/news/br?language=#{language}", :headers => headers)
102
+ response = HTTParty.get("https://fortnite-api.com/news/br?language=#{language}", :headers => @headers)
98
103
  messages = JSON.parse(response.body)['data']['messages']
99
104
  for x in messages
100
105
  newsResult = BRNews.new(x['image'], x['hidden'], x['messageType'], x['type'], x['adspace'], x['spotlight'], x['title'], x['body'])
@@ -105,7 +110,7 @@ class FortniteAPI
105
110
 
106
111
  def get_stw_news(language='en')
107
112
  stw_news_list = []
108
- response = HTTParty.get("https://fortnite-api.com/news/stw?language=#{language}", :headers => headers)
113
+ response = HTTParty.get("https://fortnite-api.com/news/stw?language=#{language}", :headers => @headers)
109
114
  messages = JSON.parse(response.body)['data']['messages']
110
115
  for x in messages
111
116
  newsResult = STWNews.new(x['image'], x['hidden'], x['messageType'], x['type'], x['adspace'], x['spotlight'], x['title'], x['body'])
@@ -116,7 +121,7 @@ class FortniteAPI
116
121
 
117
122
  def get_creative_news(language='en')
118
123
  creative_news_list = []
119
- response = HTTParty.get("https://fortnite-api.com/news/creative?language=#{language}", :headers => headers)
124
+ response = HTTParty.get("https://fortnite-api.com/news/creative?language=#{language}", :headers => @headers)
120
125
  messages = JSON.parse(response.body)['data']['messages']
121
126
  for x in messages
122
127
  newsResult = CreativeNews.new(x['image'], x['hidden'], x['messageType'], x['type'], x['adspace'], x['spotlight'], x['title'], x['body'])
@@ -128,7 +133,7 @@ class FortniteAPI
128
133
  def get_br_store(language='en')
129
134
  featured_items = []
130
135
  daily_items = []
131
- response = HTTParty.get("https://fortnite-api.com/shop/br?language=#{language}", :headers => headers)
136
+ response = HTTParty.get("https://fortnite-api.com/shop/br?language=#{language}", :headers => @headers)
132
137
  featured = JSON.parse(response.body)['data']['featured']
133
138
  for x in featured
134
139
  featuredItem = ShopItem.new(x['regularPrice'], x['finalPrice'], x['isBundle'], x['giftable'], x['refundable'], x['panel'], x['sortPriority'], x['banner'], x['items'])
@@ -142,4 +147,11 @@ class FortniteAPI
142
147
  br_store = [featured_items, daily_items]
143
148
  br_store
144
149
  end
150
+
151
+ def get_aes()
152
+ response = HTTParty.get("https://fortnite-api.com/aes", :headers => @headers)
153
+ data = JSON.parse(response.body)['data']
154
+ aes = AES.new(data['aes'], data['build'], x['lastUpdate'])
155
+ aes
156
+ end
145
157
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fortniteapi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - xMistt
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-12-06 00:00:00.000000000 Z
11
+ date: 2020-01-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty