pokeapi_client 0.9.1 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (121) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +28 -26
  3. data/README.md +7 -5
  4. data/bin/bundle +5 -10
  5. data/bin/byebug +1 -1
  6. data/bin/coderay +1 -1
  7. data/bin/htmldiff +1 -1
  8. data/bin/ldiff +1 -1
  9. data/bin/pry +1 -1
  10. data/bin/racc +27 -0
  11. data/bin/rake +1 -1
  12. data/bin/rspec +1 -1
  13. data/bin/rubocop +1 -1
  14. data/bin/ruby-parse +1 -1
  15. data/bin/ruby-rewrite +1 -1
  16. data/lib/pokeapi_client/api/ability_api.rb +4 -2
  17. data/lib/pokeapi_client/api/berry_api.rb +4 -2
  18. data/lib/pokeapi_client/api/berry_firmness_api.rb +4 -2
  19. data/lib/pokeapi_client/api/berry_flavor_api.rb +4 -2
  20. data/lib/pokeapi_client/api/characteristic_api.rb +4 -2
  21. data/lib/pokeapi_client/api/contest_effect_api.rb +4 -2
  22. data/lib/pokeapi_client/api/contest_type_api.rb +4 -2
  23. data/lib/pokeapi_client/api/egg_group_api.rb +4 -2
  24. data/lib/pokeapi_client/api/encounter_condition_api.rb +4 -2
  25. data/lib/pokeapi_client/api/encounter_condition_value_api.rb +4 -2
  26. data/lib/pokeapi_client/api/encounter_method_api.rb +4 -2
  27. data/lib/pokeapi_client/api/evolution_chain_api.rb +4 -2
  28. data/lib/pokeapi_client/api/evolution_trigger_api.rb +4 -2
  29. data/lib/pokeapi_client/api/gender_api.rb +4 -2
  30. data/lib/pokeapi_client/api/generation_api.rb +4 -2
  31. data/lib/pokeapi_client/api/growth_rate_api.rb +4 -2
  32. data/lib/pokeapi_client/api/item_api.rb +4 -2
  33. data/lib/pokeapi_client/api/item_attribute_api.rb +4 -2
  34. data/lib/pokeapi_client/api/item_category_api.rb +4 -2
  35. data/lib/pokeapi_client/api/item_fling_effect_api.rb +4 -2
  36. data/lib/pokeapi_client/api/item_pocket_api.rb +4 -2
  37. data/lib/pokeapi_client/api/language_api.rb +4 -2
  38. data/lib/pokeapi_client/api/location_api.rb +4 -2
  39. data/lib/pokeapi_client/api/location_area_api.rb +4 -2
  40. data/lib/pokeapi_client/api/machine_api.rb +4 -2
  41. data/lib/pokeapi_client/api/move_ailment_api.rb +4 -2
  42. data/lib/pokeapi_client/api/move_api.rb +4 -2
  43. data/lib/pokeapi_client/api/move_battle_style_api.rb +4 -2
  44. data/lib/pokeapi_client/api/move_category_api.rb +4 -2
  45. data/lib/pokeapi_client/api/move_damage_class_api.rb +4 -2
  46. data/lib/pokeapi_client/api/move_learn_method_api.rb +4 -2
  47. data/lib/pokeapi_client/api/move_target_api.rb +4 -2
  48. data/lib/pokeapi_client/api/nature_api.rb +4 -2
  49. data/lib/pokeapi_client/api/pal_park_area_api.rb +4 -2
  50. data/lib/pokeapi_client/api/pokeathlon_stat_api.rb +4 -2
  51. data/lib/pokeapi_client/api/pokedex_api.rb +4 -2
  52. data/lib/pokeapi_client/api/pokemon_api.rb +4 -2
  53. data/lib/pokeapi_client/api/pokemon_color_api.rb +4 -2
  54. data/lib/pokeapi_client/api/pokemon_form_api.rb +4 -2
  55. data/lib/pokeapi_client/api/pokemon_habitat_api.rb +4 -2
  56. data/lib/pokeapi_client/api/pokemon_shape_api.rb +4 -2
  57. data/lib/pokeapi_client/api/pokemon_species_api.rb +4 -2
  58. data/lib/pokeapi_client/api/region_api.rb +4 -2
  59. data/lib/pokeapi_client/api/stat_api.rb +4 -2
  60. data/lib/pokeapi_client/api/super_contest_effect_api.rb +4 -2
  61. data/lib/pokeapi_client/api/type_api.rb +4 -2
  62. data/lib/pokeapi_client/api/version_api.rb +4 -2
  63. data/lib/pokeapi_client/api/version_group_api.rb +4 -2
  64. data/lib/pokeapi_client/api_client.rb +29 -23
  65. data/lib/pokeapi_client/api_error.rb +5 -2
  66. data/lib/pokeapi_client/configuration.rb +32 -10
  67. data/lib/pokeapi_client/version.rb +5 -3
  68. data/lib/pokeapi_client.rb +4 -2
  69. data/pokeapi_client.gemspec +8 -5
  70. data/spec/api/ability_api_spec.rb +6 -4
  71. data/spec/api/berry_api_spec.rb +6 -4
  72. data/spec/api/berry_firmness_api_spec.rb +6 -4
  73. data/spec/api/berry_flavor_api_spec.rb +6 -4
  74. data/spec/api/characteristic_api_spec.rb +6 -4
  75. data/spec/api/contest_effect_api_spec.rb +6 -4
  76. data/spec/api/contest_type_api_spec.rb +6 -4
  77. data/spec/api/egg_group_api_spec.rb +6 -4
  78. data/spec/api/encounter_condition_api_spec.rb +6 -4
  79. data/spec/api/encounter_condition_value_api_spec.rb +6 -4
  80. data/spec/api/encounter_method_api_spec.rb +6 -4
  81. data/spec/api/evolution_chain_api_spec.rb +6 -4
  82. data/spec/api/evolution_trigger_api_spec.rb +6 -4
  83. data/spec/api/gender_api_spec.rb +6 -4
  84. data/spec/api/generation_api_spec.rb +6 -4
  85. data/spec/api/growth_rate_api_spec.rb +6 -4
  86. data/spec/api/item_api_spec.rb +6 -4
  87. data/spec/api/item_attribute_api_spec.rb +6 -4
  88. data/spec/api/item_category_api_spec.rb +6 -4
  89. data/spec/api/item_fling_effect_api_spec.rb +6 -4
  90. data/spec/api/item_pocket_api_spec.rb +6 -4
  91. data/spec/api/language_api_spec.rb +6 -4
  92. data/spec/api/location_api_spec.rb +6 -4
  93. data/spec/api/location_area_api_spec.rb +6 -4
  94. data/spec/api/machine_api_spec.rb +6 -4
  95. data/spec/api/move_ailment_api_spec.rb +6 -4
  96. data/spec/api/move_api_spec.rb +6 -4
  97. data/spec/api/move_battle_style_api_spec.rb +6 -4
  98. data/spec/api/move_category_api_spec.rb +6 -4
  99. data/spec/api/move_damage_class_api_spec.rb +6 -4
  100. data/spec/api/move_learn_method_api_spec.rb +6 -4
  101. data/spec/api/move_target_api_spec.rb +6 -4
  102. data/spec/api/nature_api_spec.rb +6 -4
  103. data/spec/api/pal_park_area_api_spec.rb +6 -4
  104. data/spec/api/pokeathlon_stat_api_spec.rb +6 -4
  105. data/spec/api/pokedex_api_spec.rb +6 -4
  106. data/spec/api/pokemon_api_spec.rb +6 -4
  107. data/spec/api/pokemon_color_api_spec.rb +6 -4
  108. data/spec/api/pokemon_form_api_spec.rb +6 -4
  109. data/spec/api/pokemon_habitat_api_spec.rb +6 -4
  110. data/spec/api/pokemon_shape_api_spec.rb +6 -4
  111. data/spec/api/pokemon_species_api_spec.rb +6 -4
  112. data/spec/api/region_api_spec.rb +6 -4
  113. data/spec/api/stat_api_spec.rb +6 -4
  114. data/spec/api/super_contest_effect_api_spec.rb +6 -4
  115. data/spec/api/type_api_spec.rb +6 -4
  116. data/spec/api/version_api_spec.rb +6 -4
  117. data/spec/api/version_group_api_spec.rb +6 -4
  118. data/spec/spec_helper.rb +4 -2
  119. metadata +46 -49
  120. data/spec/api_client_spec.rb +0 -224
  121. data/spec/configuration_spec.rb +0 -40
@@ -1,10 +1,12 @@
1
1
  =begin
2
+ #
3
+
2
4
  #No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
3
5
 
4
6
  The version of the OpenAPI document: 20220523
5
-
7
+ Contact: blah+oapicf@cliffano.com
6
8
  Generated by: https://openapi-generator.tech
7
- OpenAPI Generator version: 5.4.0
9
+ Generator version: 7.4.0
8
10
 
9
11
  =end
10
12
 
@@ -1,10 +1,12 @@
1
1
  =begin
2
+ #
3
+
2
4
  #No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
3
5
 
4
6
  The version of the OpenAPI document: 20220523
5
-
7
+ Contact: blah+oapicf@cliffano.com
6
8
  Generated by: https://openapi-generator.tech
7
- OpenAPI Generator version: 5.4.0
9
+ Generator version: 7.4.0
8
10
 
9
11
  =end
10
12
 
@@ -1,10 +1,12 @@
1
1
  =begin
2
+ #
3
+
2
4
  #No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
3
5
 
4
6
  The version of the OpenAPI document: 20220523
5
-
7
+ Contact: blah+oapicf@cliffano.com
6
8
  Generated by: https://openapi-generator.tech
7
- OpenAPI Generator version: 5.4.0
9
+ Generator version: 7.4.0
8
10
 
9
11
  =end
10
12
 
@@ -1,10 +1,12 @@
1
1
  =begin
2
+ #
3
+
2
4
  #No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
3
5
 
4
6
  The version of the OpenAPI document: 20220523
5
-
7
+ Contact: blah+oapicf@cliffano.com
6
8
  Generated by: https://openapi-generator.tech
7
- OpenAPI Generator version: 5.4.0
9
+ Generator version: 7.4.0
8
10
 
9
11
  =end
10
12
 
@@ -1,10 +1,12 @@
1
1
  =begin
2
+ #
3
+
2
4
  #No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
3
5
 
4
6
  The version of the OpenAPI document: 20220523
5
-
7
+ Contact: blah+oapicf@cliffano.com
6
8
  Generated by: https://openapi-generator.tech
7
- OpenAPI Generator version: 5.4.0
9
+ Generator version: 7.4.0
8
10
 
9
11
  =end
10
12
 
@@ -1,10 +1,12 @@
1
1
  =begin
2
+ #
3
+
2
4
  #No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
3
5
 
4
6
  The version of the OpenAPI document: 20220523
5
-
7
+ Contact: blah+oapicf@cliffano.com
6
8
  Generated by: https://openapi-generator.tech
7
- OpenAPI Generator version: 5.4.0
9
+ Generator version: 7.4.0
8
10
 
9
11
  =end
10
12
 
@@ -1,10 +1,12 @@
1
1
  =begin
2
+ #
3
+
2
4
  #No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
3
5
 
4
6
  The version of the OpenAPI document: 20220523
5
-
7
+ Contact: blah+oapicf@cliffano.com
6
8
  Generated by: https://openapi-generator.tech
7
- OpenAPI Generator version: 5.4.0
9
+ Generator version: 7.4.0
8
10
 
9
11
  =end
10
12
 
@@ -1,10 +1,12 @@
1
1
  =begin
2
+ #
3
+
2
4
  #No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
3
5
 
4
6
  The version of the OpenAPI document: 20220523
5
-
7
+ Contact: blah+oapicf@cliffano.com
6
8
  Generated by: https://openapi-generator.tech
7
- OpenAPI Generator version: 5.4.0
9
+ Generator version: 7.4.0
8
10
 
9
11
  =end
10
12
 
@@ -1,10 +1,12 @@
1
1
  =begin
2
+ #
3
+
2
4
  #No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
3
5
 
4
6
  The version of the OpenAPI document: 20220523
5
-
7
+ Contact: blah+oapicf@cliffano.com
6
8
  Generated by: https://openapi-generator.tech
7
- OpenAPI Generator version: 5.4.0
9
+ Generator version: 7.4.0
8
10
 
9
11
  =end
10
12
 
@@ -1,10 +1,12 @@
1
1
  =begin
2
+ #
3
+
2
4
  #No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
3
5
 
4
6
  The version of the OpenAPI document: 20220523
5
-
7
+ Contact: blah+oapicf@cliffano.com
6
8
  Generated by: https://openapi-generator.tech
7
- OpenAPI Generator version: 5.4.0
9
+ Generator version: 7.4.0
8
10
 
9
11
  =end
10
12
 
@@ -1,10 +1,12 @@
1
1
  =begin
2
+ #
3
+
2
4
  #No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
3
5
 
4
6
  The version of the OpenAPI document: 20220523
5
-
7
+ Contact: blah+oapicf@cliffano.com
6
8
  Generated by: https://openapi-generator.tech
7
- OpenAPI Generator version: 5.4.0
9
+ Generator version: 7.4.0
8
10
 
9
11
  =end
10
12
 
@@ -1,10 +1,12 @@
1
1
  =begin
2
+ #
3
+
2
4
  #No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
3
5
 
4
6
  The version of the OpenAPI document: 20220523
5
-
7
+ Contact: blah+oapicf@cliffano.com
6
8
  Generated by: https://openapi-generator.tech
7
- OpenAPI Generator version: 5.4.0
9
+ Generator version: 7.4.0
8
10
 
9
11
  =end
10
12
 
@@ -1,10 +1,12 @@
1
1
  =begin
2
+ #
3
+
2
4
  #No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
3
5
 
4
6
  The version of the OpenAPI document: 20220523
5
-
7
+ Contact: blah+oapicf@cliffano.com
6
8
  Generated by: https://openapi-generator.tech
7
- OpenAPI Generator version: 5.4.0
9
+ Generator version: 7.4.0
8
10
 
9
11
  =end
10
12
 
@@ -1,10 +1,12 @@
1
1
  =begin
2
+ #
3
+
2
4
  #No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
3
5
 
4
6
  The version of the OpenAPI document: 20220523
5
-
7
+ Contact: blah+oapicf@cliffano.com
6
8
  Generated by: https://openapi-generator.tech
7
- OpenAPI Generator version: 5.4.0
9
+ Generator version: 7.4.0
8
10
 
9
11
  =end
10
12
 
@@ -1,10 +1,12 @@
1
1
  =begin
2
+ #
3
+
2
4
  #No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
3
5
 
4
6
  The version of the OpenAPI document: 20220523
5
-
7
+ Contact: blah+oapicf@cliffano.com
6
8
  Generated by: https://openapi-generator.tech
7
- OpenAPI Generator version: 5.4.0
9
+ Generator version: 7.4.0
8
10
 
9
11
  =end
10
12
 
@@ -1,10 +1,12 @@
1
1
  =begin
2
+ #
3
+
2
4
  #No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
3
5
 
4
6
  The version of the OpenAPI document: 20220523
5
-
7
+ Contact: blah+oapicf@cliffano.com
6
8
  Generated by: https://openapi-generator.tech
7
- OpenAPI Generator version: 5.4.0
9
+ Generator version: 7.4.0
8
10
 
9
11
  =end
10
12
 
@@ -1,10 +1,12 @@
1
1
  =begin
2
+ #
3
+
2
4
  #No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
3
5
 
4
6
  The version of the OpenAPI document: 20220523
5
-
7
+ Contact: blah+oapicf@cliffano.com
6
8
  Generated by: https://openapi-generator.tech
7
- OpenAPI Generator version: 5.4.0
9
+ Generator version: 7.4.0
8
10
 
9
11
  =end
10
12
 
@@ -1,10 +1,12 @@
1
1
  =begin
2
+ #
3
+
2
4
  #No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
3
5
 
4
6
  The version of the OpenAPI document: 20220523
5
-
7
+ Contact: blah+oapicf@cliffano.com
6
8
  Generated by: https://openapi-generator.tech
7
- OpenAPI Generator version: 5.4.0
9
+ Generator version: 7.4.0
8
10
 
9
11
  =end
10
12
 
@@ -1,10 +1,12 @@
1
1
  =begin
2
+ #
3
+
2
4
  #No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
3
5
 
4
6
  The version of the OpenAPI document: 20220523
5
-
7
+ Contact: blah+oapicf@cliffano.com
6
8
  Generated by: https://openapi-generator.tech
7
- OpenAPI Generator version: 5.4.0
9
+ Generator version: 7.4.0
8
10
 
9
11
  =end
10
12
 
@@ -1,10 +1,12 @@
1
1
  =begin
2
+ #
3
+
2
4
  #No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
3
5
 
4
6
  The version of the OpenAPI document: 20220523
5
-
7
+ Contact: blah+oapicf@cliffano.com
6
8
  Generated by: https://openapi-generator.tech
7
- OpenAPI Generator version: 5.4.0
9
+ Generator version: 7.4.0
8
10
 
9
11
  =end
10
12
 
@@ -1,10 +1,12 @@
1
1
  =begin
2
+ #
3
+
2
4
  #No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
3
5
 
4
6
  The version of the OpenAPI document: 20220523
5
-
7
+ Contact: blah+oapicf@cliffano.com
6
8
  Generated by: https://openapi-generator.tech
7
- OpenAPI Generator version: 5.4.0
9
+ Generator version: 7.4.0
8
10
 
9
11
  =end
10
12
 
@@ -1,10 +1,12 @@
1
1
  =begin
2
+ #
3
+
2
4
  #No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
3
5
 
4
6
  The version of the OpenAPI document: 20220523
5
-
7
+ Contact: blah+oapicf@cliffano.com
6
8
  Generated by: https://openapi-generator.tech
7
- OpenAPI Generator version: 5.4.0
9
+ Generator version: 7.4.0
8
10
 
9
11
  =end
10
12
 
@@ -1,10 +1,12 @@
1
1
  =begin
2
+ #
3
+
2
4
  #No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
3
5
 
4
6
  The version of the OpenAPI document: 20220523
5
-
7
+ Contact: blah+oapicf@cliffano.com
6
8
  Generated by: https://openapi-generator.tech
7
- OpenAPI Generator version: 5.4.0
9
+ Generator version: 7.4.0
8
10
 
9
11
  =end
10
12
 
@@ -1,10 +1,12 @@
1
1
  =begin
2
+ #
3
+
2
4
  #No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
3
5
 
4
6
  The version of the OpenAPI document: 20220523
5
-
7
+ Contact: blah+oapicf@cliffano.com
6
8
  Generated by: https://openapi-generator.tech
7
- OpenAPI Generator version: 5.4.0
9
+ Generator version: 7.4.0
8
10
 
9
11
  =end
10
12
 
@@ -1,10 +1,12 @@
1
1
  =begin
2
+ #
3
+
2
4
  #No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
3
5
 
4
6
  The version of the OpenAPI document: 20220523
5
-
7
+ Contact: blah+oapicf@cliffano.com
6
8
  Generated by: https://openapi-generator.tech
7
- OpenAPI Generator version: 5.4.0
9
+ Generator version: 7.4.0
8
10
 
9
11
  =end
10
12
 
@@ -1,10 +1,12 @@
1
1
  =begin
2
+ #
3
+
2
4
  #No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
3
5
 
4
6
  The version of the OpenAPI document: 20220523
5
-
7
+ Contact: blah+oapicf@cliffano.com
6
8
  Generated by: https://openapi-generator.tech
7
- OpenAPI Generator version: 5.4.0
9
+ Generator version: 7.4.0
8
10
 
9
11
  =end
10
12
 
@@ -1,10 +1,12 @@
1
1
  =begin
2
+ #
3
+
2
4
  #No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
3
5
 
4
6
  The version of the OpenAPI document: 20220523
5
-
7
+ Contact: blah+oapicf@cliffano.com
6
8
  Generated by: https://openapi-generator.tech
7
- OpenAPI Generator version: 5.4.0
9
+ Generator version: 7.4.0
8
10
 
9
11
  =end
10
12
 
@@ -15,6 +17,7 @@ require 'tempfile'
15
17
  require 'time'
16
18
  require 'typhoeus'
17
19
 
20
+
18
21
  module PokeApiClient
19
22
  class ApiClient
20
23
  # The Configuration object holding settings to be used in the API client.
@@ -43,9 +46,10 @@ module PokeApiClient
43
46
  # Call an API with given options.
44
47
  #
45
48
  # @return [Array<(Object, Integer, Hash)>] an array of 3 elements:
46
- # the data deserialized from response body (could be nil), response status code and response headers.
49
+ # the data deserialized from response body (may be a Tempfile or nil), response status code and response headers.
47
50
  def call_api(http_method, path, opts = {})
48
51
  request = build_request(http_method, path, opts)
52
+ tempfile = download_file(request) if opts[:return_type] == 'File'
49
53
  response = request.run
50
54
 
51
55
  if @config.debugging
@@ -67,7 +71,9 @@ module PokeApiClient
67
71
  end
68
72
  end
69
73
 
70
- if opts[:return_type]
74
+ if opts[:return_type] == 'File'
75
+ data = tempfile
76
+ elsif opts[:return_type]
71
77
  data = deserialize(response, opts[:return_type])
72
78
  else
73
79
  data = nil
@@ -91,6 +97,7 @@ module PokeApiClient
91
97
  header_params = @default_headers.merge(opts[:header_params] || {})
92
98
  query_params = opts[:query_params] || {}
93
99
  form_params = opts[:form_params] || {}
100
+ follow_location = opts[:follow_location] || true
94
101
 
95
102
 
96
103
  # set ssl_verifyhosts option based on @config.verify_ssl_host (true/false)
@@ -106,7 +113,8 @@ module PokeApiClient
106
113
  :ssl_verifyhost => _verify_ssl_host,
107
114
  :sslcert => @config.cert_file,
108
115
  :sslkey => @config.key_file,
109
- :verbose => @config.debugging
116
+ :verbose => @config.debugging,
117
+ :followlocation => follow_location
110
118
  }
111
119
 
112
120
  # set custom cert, if provided
@@ -120,9 +128,7 @@ module PokeApiClient
120
128
  end
121
129
  end
122
130
 
123
- request = Typhoeus::Request.new(url, req_opts)
124
- download_file(request) if opts[:return_type] == 'File'
125
- request
131
+ Typhoeus::Request.new(url, req_opts)
126
132
  end
127
133
 
128
134
  # Builds the HTTP request body
@@ -160,6 +166,8 @@ module PokeApiClient
160
166
  # process can use.
161
167
  #
162
168
  # @see Configuration#temp_folder_path
169
+ #
170
+ # @return [Tempfile] the tempfile generated
163
171
  def download_file(request)
164
172
  tempfile = nil
165
173
  encoding = nil
@@ -174,21 +182,24 @@ module PokeApiClient
174
182
  prefix = prefix + '-' unless prefix.end_with?('-')
175
183
  encoding = response.body.encoding
176
184
  tempfile = Tempfile.open(prefix, @config.temp_folder_path, encoding: encoding)
177
- @tempfile = tempfile
178
185
  end
179
186
  request.on_body do |chunk|
180
187
  chunk.force_encoding(encoding)
181
188
  tempfile.write(chunk)
182
189
  end
183
- request.on_complete do |response|
184
- if tempfile
185
- tempfile.close
186
- @config.logger.info "Temp file written to #{tempfile.path}, please copy the file to a proper folder "\
187
- "with e.g. `FileUtils.cp(tempfile.path, '/new/file/path')` otherwise the temp file "\
188
- "will be deleted automatically with GC. It's also recommended to delete the temp file "\
189
- "explicitly with `tempfile.delete`"
190
- end
190
+ # run the request to ensure the tempfile is created successfully before returning it
191
+ request.run
192
+ if tempfile
193
+ tempfile.close
194
+ @config.logger.info "Temp file written to #{tempfile.path}, please copy the file to a proper folder "\
195
+ "with e.g. `FileUtils.cp(tempfile.path, '/new/file/path')` otherwise the temp file "\
196
+ "will be deleted automatically with GC. It's also recommended to delete the temp file "\
197
+ "explicitly with `tempfile.delete`"
198
+ else
199
+ fail ApiError.new("Failed to create the tempfile based on the HTTP response from the server: #{request.inspect}")
191
200
  end
201
+
202
+ tempfile
192
203
  end
193
204
 
194
205
  # Check if the given MIME is a JSON MIME.
@@ -209,15 +220,10 @@ module PokeApiClient
209
220
  # @param [String] return_type some examples: "User", "Array<User>", "Hash<String, Integer>"
210
221
  def deserialize(response, return_type)
211
222
  body = response.body
212
-
213
- # handle file downloading - return the File instance processed in request callbacks
214
- # note that response body is empty when the file is written in chunks in request on_body callback
215
- return @tempfile if return_type == 'File'
216
-
217
223
  return nil if body.nil? || body.empty?
218
224
 
219
225
  # return response body directly for String return type
220
- return body if return_type == 'String'
226
+ return body.to_s if return_type == 'String'
221
227
 
222
228
  # ensuring a default content type
223
229
  content_type = response.headers['Content-Type'] || 'application/json'
@@ -1,10 +1,12 @@
1
1
  =begin
2
+ #
3
+
2
4
  #No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
3
5
 
4
6
  The version of the OpenAPI document: 20220523
5
-
7
+ Contact: blah+oapicf@cliffano.com
6
8
  Generated by: https://openapi-generator.tech
7
- OpenAPI Generator version: 5.4.0
9
+ Generator version: 7.4.0
8
10
 
9
11
  =end
10
12
 
@@ -30,6 +32,7 @@ module PokeApiClient
30
32
  end
31
33
  else
32
34
  super arg
35
+ @message = arg
33
36
  end
34
37
  end
35
38