warframe 0.4.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (61) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +32 -13
  3. data/README.md +39 -34
  4. data/lib/warframe/api/alerts.rb +14 -0
  5. data/lib/warframe/api/cambion_drift.rb +16 -0
  6. data/lib/warframe/api/cetus.rb +16 -0
  7. data/lib/warframe/api/conclave_challenges.rb +16 -0
  8. data/lib/warframe/api/global_upgrades.rb +16 -0
  9. data/lib/warframe/api/invasions.rb +16 -0
  10. data/lib/warframe/api/news.rb +16 -0
  11. data/lib/warframe/api/nightwave.rb +16 -0
  12. data/lib/warframe/api/sortie.rb +16 -0
  13. data/lib/warframe/api/steel_path.rb +16 -0
  14. data/lib/warframe/api/syndicate_missions.rb +16 -0
  15. data/lib/warframe/api/vallis_cycle.rb +16 -0
  16. data/lib/warframe/api.rb +24 -0
  17. data/lib/warframe/cache.rb +3 -3
  18. data/lib/warframe/client.rb +98 -0
  19. data/lib/warframe/models/alert.rb +16 -23
  20. data/lib/warframe/models/attributes/description.rb +12 -16
  21. data/lib/warframe/models/attributes/eta.rb +6 -10
  22. data/lib/warframe/models/attributes/expiry.rb +20 -24
  23. data/lib/warframe/models/attributes/id.rb +6 -10
  24. data/lib/warframe/models/attributes/reward_types.rb +6 -10
  25. data/lib/warframe/models/attributes/start_string.rb +6 -10
  26. data/lib/warframe/models/attributes/translations.rb +9 -13
  27. data/lib/warframe/models/base.rb +5 -30
  28. data/lib/warframe/models/cambion_drift.rb +14 -19
  29. data/lib/warframe/models/cetus.rb +25 -30
  30. data/lib/warframe/models/conclave_challenge.rb +43 -50
  31. data/lib/warframe/models/global_upgrade.rb +33 -37
  32. data/lib/warframe/models/invasion.rb +58 -67
  33. data/lib/warframe/models/news.rb +45 -50
  34. data/lib/warframe/models/nightwave.rb +24 -30
  35. data/lib/warframe/models/objectified_hash.rb +74 -0
  36. data/lib/warframe/models/sortie.rb +21 -27
  37. data/lib/warframe/models/steel_path.rb +22 -24
  38. data/lib/warframe/models/syndicate_mission.rb +18 -24
  39. data/lib/warframe/models/vallis_cycle.rb +21 -26
  40. data/lib/warframe/models.rb +6 -0
  41. data/lib/warframe/version.rb +1 -1
  42. data/lib/warframe.rb +4 -2
  43. data/warframe.gemspec +9 -13
  44. metadata +37 -94
  45. data/lib/warframe/client_wrapper.rb +0 -39
  46. data/lib/warframe/rest/api/alerts.rb +0 -23
  47. data/lib/warframe/rest/api/cambion_drift.rb +0 -23
  48. data/lib/warframe/rest/api/cetus.rb +0 -23
  49. data/lib/warframe/rest/api/conclave_challenges.rb +0 -23
  50. data/lib/warframe/rest/api/global_upgrades.rb +0 -23
  51. data/lib/warframe/rest/api/invasions.rb +0 -23
  52. data/lib/warframe/rest/api/news.rb +0 -23
  53. data/lib/warframe/rest/api/nightwave.rb +0 -23
  54. data/lib/warframe/rest/api/sortie.rb +0 -23
  55. data/lib/warframe/rest/api/steel_path.rb +0 -23
  56. data/lib/warframe/rest/api/syndicate_missions.rb +0 -23
  57. data/lib/warframe/rest/api/vallis_cycle.rb +0 -23
  58. data/lib/warframe/rest/api.rb +0 -39
  59. data/lib/warframe/rest/client.rb +0 -42
  60. data/lib/warframe/rest/request.rb +0 -61
  61. data/lib/warframe/rest/utils.rb +0 -23
@@ -1,61 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'net/http'
4
- require 'json'
5
-
6
- module Warframe
7
- module REST
8
- # A request to send to the Warframe Stat API.
9
- class Request
10
- # @return [Warframe::REST::Client]
11
- attr_reader :client
12
-
13
- # @return [String]
14
- attr_reader :path
15
-
16
- # Instantiate a Request
17
- #
18
- # @param client [Warframe::REST::Client]
19
- # @param path [String]
20
- # @param klass [Warframe::Models]
21
- # @return [Warframe:REST:Request]
22
- def initialize(client, path, klass)
23
- @client = client
24
- @route = path
25
- @path = client.base_url + path + "?language=#{@client.language}"
26
- @klass = klass
27
- end
28
-
29
- # Sends an HTTP request with the attached parameters and headers.
30
- # Will either return the Model, or collection of Models.
31
- # @return [Warframe::Models, Array<[Warframe::Models]>]
32
- def send
33
- uri = URI(path)
34
- req = Net::HTTP::Get.new(uri)
35
- resp = get_response uri, req
36
- return_parsed resp
37
- end
38
-
39
- private
40
-
41
- # Returns the parsed JSON response in the form of a [Warframe::Models] or an array of [Warframe::Models]
42
- # @param resp [Net::HTTP.get]
43
- # @return [Warframe::Models, Array<[Warframe::Models]>]
44
- def return_parsed(resp)
45
- parsed = JSON.parse(resp)
46
-
47
- # Return Empty array if no data found.
48
- return [] if parsed.is_a?(Array) && parsed.empty?
49
-
50
- @klass.new parsed
51
- end
52
-
53
- def get_response(uri, req)
54
- Net::HTTP.get(uri) do |http|
55
- http.use_ssl = true
56
- http.request req
57
- end
58
- end
59
- end
60
- end
61
- end
@@ -1,23 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative './request'
4
-
5
- module Warframe
6
- module REST
7
- # Private REST Utilities
8
- module Utils
9
- private
10
-
11
- # Performs a get operation on the requested path, and returns a mapped response of the requested model.
12
- # @param path [String]
13
- # @param klass [Warframe::Models]
14
- def get(path, klass)
15
- inst = @client || self
16
- return inst.get_from_cache(path) if inst.find_in_cache(path)
17
-
18
- result = Warframe::REST::Request.new(inst, path, klass).send
19
- inst.add_to_cache(path, result)
20
- end
21
- end
22
- end
23
- end