fortniteapi 0.0.2 → 0.0.3

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 +14 -9
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dfbfc95576667a4829786b5abf7644f9f4ab46d7c6e8cdb10b55e4f8599bc0d7
4
- data.tar.gz: fd6dd6c60e471b3ab039e7d0a7d59720a0a3c6f5c9f7d9638b1ce7641a5cb31a
3
+ metadata.gz: 59d2fb1dca5d42e6340ad687295207914f93dd54f30de7300b3b4603afde5328
4
+ data.tar.gz: 8cefdc3c3d3e7b40345883df4ee5641563284e380f2fab1fdfe3fb1844f79b42
5
5
  SHA512:
6
- metadata.gz: bd9caaddc73a25e9df8eb51b9742060345d18484d1fa12f86d75eebb14098179a7f702fe0ff865e2d56330e8f8d43bde24d1e83ceb297d2d4004d1f4dcd2013e
7
- data.tar.gz: 64fd27d6d83b77efd31bf3c11b806ccddd12971ba55061fff49a0ec495fce2e34eb0b79c5ea3840c15b5262ae390cba32853d8ec0f691839a751f5f901efc4ef
6
+ metadata.gz: e93fb1a769d1694bde6dac5deed63bfc572757d45a1e5ebcf00f7dce61335bc65cabbe492fcec448b062d3c4726dde717de132810257a8dac2f97992b196dce4
7
+ data.tar.gz: dca7900b2afbe5c87dc5df956bd52696a4b7b62cdb0610aba6de3828dc10481bc1ebbafd1af09e43beec46c6dc542def016841ba49ba738ffed42875fc25ade4
@@ -8,8 +8,13 @@ class FortniteAPI
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
10
 
11
+ def initialize(apikey=nil)
12
+ @apikey = apikey
13
+ @headers = {"x-api-key" => @apikey}
14
+ end
15
+
11
16
  def search_cosmetic(searchQuery, tag='name', language='en', searchLanguage='en')
12
- response = HTTParty.get("https://fortnite-api.com/cosmetics/br/search?#{tag}=#{searchQuery}&language=#{language}&searchLanguage=#{searchLanguage}")
17
+ response = HTTParty.get("https://fortnite-api.com/cosmetics/br/search?#{tag}=#{searchQuery}&language=#{language}&searchLanguage=#{searchLanguage}", :headers => headers)
13
18
  body = JSON.parse(response.body)['data']
14
19
  if response.code == 200
15
20
  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'])
@@ -30,12 +35,12 @@ class FortniteAPI
30
35
  end
31
36
 
32
37
  def get_creator_code(slug)
33
- repsonse = HTTParty.get("https://fortnite-api.com/creatorcode/search?slug=#{slug}")
38
+ repsonse = HTTParty.get("https://fortnite-api.com/creatorcode/search?slug=#{slug}", :headers => headers)
34
39
  body = JSON.parse(response.body)['data']
35
40
  supportACreator = CreatorCode.new(body['id'], body['slug'], body['displayName'], body['status'], body['verified'])
36
41
 
37
42
  def search_cosmetic_id(searchQuery, language='en')
38
- response = HTTParty.get("https://fortnite-api.com/cosmetics/br/#{searchQuery}&language=#{language}")
43
+ response = HTTParty.get("https://fortnite-api.com/cosmetics/br/#{searchQuery}&language=#{language}", :headers => headers)
39
44
  body = JSON.parse(response.body)['data']
40
45
  if response.code == 200
41
46
  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'])
@@ -57,7 +62,7 @@ class FortniteAPI
57
62
 
58
63
  def search_cosmetics(searchQuery, tag='name', language='en', searchLanguage='en')
59
64
  cosmetics = []
60
- response = HTTParty.get("https://fortnite-api.com/cosmetics/br/search/all?#{tag}=#{searchQuery}&language=#{language}&searchLanguage=#{searchLanguage}")
65
+ response = HTTParty.get("https://fortnite-api.com/cosmetics/br/search/all?#{tag}=#{searchQuery}&language=#{language}&searchLanguage=#{searchLanguage}", :headers => headers)
61
66
  body = JSON.parse(response.body)['data']
62
67
  if response.code == 200
63
68
  for x in body
@@ -81,13 +86,13 @@ class FortniteAPI
81
86
  end
82
87
 
83
88
  def all_cosmetics()
84
- response = HTTParty.get("https://fortnite-api.com/cosmetics/br")
89
+ response = HTTParty.get("https://fortnite-api.com/cosmetics/br", :headers => headers)
85
90
  JSON.parse(response.body)
86
91
  end
87
92
 
88
93
  def get_br_news(language='en')
89
94
  br_news_list = []
90
- response = HTTParty.get("https://fortnite-api.com/news/br?language=#{language}")
95
+ response = HTTParty.get("https://fortnite-api.com/news/br?language=#{language}", :headers => headers)
91
96
  messages = JSON.parse(response.body)['data']['messages']
92
97
  for x in messages
93
98
  newsResult = BRNews.new(x['image'], x['hidden'], x['messageType'], x['type'], x['adspace'], x['spotlight'], x['title'], x['body'])
@@ -98,7 +103,7 @@ class FortniteAPI
98
103
 
99
104
  def get_stw_news(language='en')
100
105
  stw_news_list = []
101
- response = HTTParty.get("https://fortnite-api.com/news/stw?language=#{language}")
106
+ response = HTTParty.get("https://fortnite-api.com/news/stw?language=#{language}", :headers => headers)
102
107
  messages = JSON.parse(response.body)['data']['messages']
103
108
  for x in messages
104
109
  newsResult = STWNews.new(x['image'], x['hidden'], x['messageType'], x['type'], x['adspace'], x['spotlight'], x['title'], x['body'])
@@ -109,7 +114,7 @@ class FortniteAPI
109
114
 
110
115
  def get_creative_news(language='en')
111
116
  creative_news_list = []
112
- response = HTTParty.get("https://fortnite-api.com/news/creative?language=#{language}")
117
+ response = HTTParty.get("https://fortnite-api.com/news/creative?language=#{language}", :headers => headers)
113
118
  messages = JSON.parse(response.body)['data']['messages']
114
119
  for x in messages
115
120
  newsResult = CreativeNews.new(x['image'], x['hidden'], x['messageType'], x['type'], x['adspace'], x['spotlight'], x['title'], x['body'])
@@ -121,7 +126,7 @@ class FortniteAPI
121
126
  def get_br_store(language='en')
122
127
  featured_items = []
123
128
  daily_items = []
124
- response = HTTParty.get("https://fortnite-api.com/shop/br?language=#{language}")
129
+ response = HTTParty.get("https://fortnite-api.com/shop/br?language=#{language}", :headers => headers)
125
130
  featured = JSON.parse(response.body)['data']['featured']
126
131
  for x in featured
127
132
  featuredItem = ShopItem.new(x['regularPrice'], x['finalPrice'], x['isBundle'], x['giftable'], x['refundable'], x['panel'], x['sortPriority'], x['banner'], x['items'])
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.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - xMistt
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-11-25 00:00:00.000000000 Z
11
+ date: 2019-12-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty