pokeapi_client 0.10.0 → 1.1.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 +27 -25
  3. data/README.md +7 -6
  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 +2 -2
  17. data/lib/pokeapi_client/api/berry_api.rb +2 -2
  18. data/lib/pokeapi_client/api/berry_firmness_api.rb +2 -2
  19. data/lib/pokeapi_client/api/berry_flavor_api.rb +2 -2
  20. data/lib/pokeapi_client/api/characteristic_api.rb +2 -2
  21. data/lib/pokeapi_client/api/contest_effect_api.rb +2 -2
  22. data/lib/pokeapi_client/api/contest_type_api.rb +2 -2
  23. data/lib/pokeapi_client/api/egg_group_api.rb +2 -2
  24. data/lib/pokeapi_client/api/encounter_condition_api.rb +2 -2
  25. data/lib/pokeapi_client/api/encounter_condition_value_api.rb +2 -2
  26. data/lib/pokeapi_client/api/encounter_method_api.rb +2 -2
  27. data/lib/pokeapi_client/api/evolution_chain_api.rb +2 -2
  28. data/lib/pokeapi_client/api/evolution_trigger_api.rb +2 -2
  29. data/lib/pokeapi_client/api/gender_api.rb +2 -2
  30. data/lib/pokeapi_client/api/generation_api.rb +2 -2
  31. data/lib/pokeapi_client/api/growth_rate_api.rb +2 -2
  32. data/lib/pokeapi_client/api/item_api.rb +2 -2
  33. data/lib/pokeapi_client/api/item_attribute_api.rb +2 -2
  34. data/lib/pokeapi_client/api/item_category_api.rb +2 -2
  35. data/lib/pokeapi_client/api/item_fling_effect_api.rb +2 -2
  36. data/lib/pokeapi_client/api/item_pocket_api.rb +2 -2
  37. data/lib/pokeapi_client/api/language_api.rb +2 -2
  38. data/lib/pokeapi_client/api/location_api.rb +2 -2
  39. data/lib/pokeapi_client/api/location_area_api.rb +2 -2
  40. data/lib/pokeapi_client/api/machine_api.rb +2 -2
  41. data/lib/pokeapi_client/api/move_ailment_api.rb +2 -2
  42. data/lib/pokeapi_client/api/move_api.rb +2 -2
  43. data/lib/pokeapi_client/api/move_battle_style_api.rb +2 -2
  44. data/lib/pokeapi_client/api/move_category_api.rb +2 -2
  45. data/lib/pokeapi_client/api/move_damage_class_api.rb +2 -2
  46. data/lib/pokeapi_client/api/move_learn_method_api.rb +2 -2
  47. data/lib/pokeapi_client/api/move_target_api.rb +2 -2
  48. data/lib/pokeapi_client/api/nature_api.rb +2 -2
  49. data/lib/pokeapi_client/api/pal_park_area_api.rb +2 -2
  50. data/lib/pokeapi_client/api/pokeathlon_stat_api.rb +2 -2
  51. data/lib/pokeapi_client/api/pokedex_api.rb +2 -2
  52. data/lib/pokeapi_client/api/pokemon_api.rb +2 -2
  53. data/lib/pokeapi_client/api/pokemon_color_api.rb +2 -2
  54. data/lib/pokeapi_client/api/pokemon_form_api.rb +2 -2
  55. data/lib/pokeapi_client/api/pokemon_habitat_api.rb +2 -2
  56. data/lib/pokeapi_client/api/pokemon_shape_api.rb +2 -2
  57. data/lib/pokeapi_client/api/pokemon_species_api.rb +2 -2
  58. data/lib/pokeapi_client/api/region_api.rb +2 -2
  59. data/lib/pokeapi_client/api/stat_api.rb +2 -2
  60. data/lib/pokeapi_client/api/super_contest_effect_api.rb +2 -2
  61. data/lib/pokeapi_client/api/type_api.rb +2 -2
  62. data/lib/pokeapi_client/api/version_api.rb +2 -2
  63. data/lib/pokeapi_client/api/version_group_api.rb +2 -2
  64. data/lib/pokeapi_client/api_client.rb +26 -24
  65. data/lib/pokeapi_client/api_error.rb +3 -2
  66. data/lib/pokeapi_client/configuration.rb +28 -9
  67. data/lib/pokeapi_client/version.rb +3 -3
  68. data/lib/pokeapi_client.rb +2 -2
  69. data/pokeapi_client.gemspec +6 -5
  70. data/spec/api/ability_api_spec.rb +4 -4
  71. data/spec/api/berry_api_spec.rb +4 -4
  72. data/spec/api/berry_firmness_api_spec.rb +4 -4
  73. data/spec/api/berry_flavor_api_spec.rb +4 -4
  74. data/spec/api/characteristic_api_spec.rb +4 -4
  75. data/spec/api/contest_effect_api_spec.rb +4 -4
  76. data/spec/api/contest_type_api_spec.rb +4 -4
  77. data/spec/api/egg_group_api_spec.rb +4 -4
  78. data/spec/api/encounter_condition_api_spec.rb +4 -4
  79. data/spec/api/encounter_condition_value_api_spec.rb +4 -4
  80. data/spec/api/encounter_method_api_spec.rb +4 -4
  81. data/spec/api/evolution_chain_api_spec.rb +4 -4
  82. data/spec/api/evolution_trigger_api_spec.rb +4 -4
  83. data/spec/api/gender_api_spec.rb +4 -4
  84. data/spec/api/generation_api_spec.rb +4 -4
  85. data/spec/api/growth_rate_api_spec.rb +4 -4
  86. data/spec/api/item_api_spec.rb +4 -4
  87. data/spec/api/item_attribute_api_spec.rb +4 -4
  88. data/spec/api/item_category_api_spec.rb +4 -4
  89. data/spec/api/item_fling_effect_api_spec.rb +4 -4
  90. data/spec/api/item_pocket_api_spec.rb +4 -4
  91. data/spec/api/language_api_spec.rb +4 -4
  92. data/spec/api/location_api_spec.rb +4 -4
  93. data/spec/api/location_area_api_spec.rb +4 -4
  94. data/spec/api/machine_api_spec.rb +4 -4
  95. data/spec/api/move_ailment_api_spec.rb +4 -4
  96. data/spec/api/move_api_spec.rb +4 -4
  97. data/spec/api/move_battle_style_api_spec.rb +4 -4
  98. data/spec/api/move_category_api_spec.rb +4 -4
  99. data/spec/api/move_damage_class_api_spec.rb +4 -4
  100. data/spec/api/move_learn_method_api_spec.rb +4 -4
  101. data/spec/api/move_target_api_spec.rb +4 -4
  102. data/spec/api/nature_api_spec.rb +4 -4
  103. data/spec/api/pal_park_area_api_spec.rb +4 -4
  104. data/spec/api/pokeathlon_stat_api_spec.rb +4 -4
  105. data/spec/api/pokedex_api_spec.rb +4 -4
  106. data/spec/api/pokemon_api_spec.rb +4 -4
  107. data/spec/api/pokemon_color_api_spec.rb +4 -4
  108. data/spec/api/pokemon_form_api_spec.rb +4 -4
  109. data/spec/api/pokemon_habitat_api_spec.rb +4 -4
  110. data/spec/api/pokemon_shape_api_spec.rb +4 -4
  111. data/spec/api/pokemon_species_api_spec.rb +4 -4
  112. data/spec/api/region_api_spec.rb +4 -4
  113. data/spec/api/stat_api_spec.rb +4 -4
  114. data/spec/api/super_contest_effect_api_spec.rb +4 -4
  115. data/spec/api/type_api_spec.rb +4 -4
  116. data/spec/api/version_api_spec.rb +4 -4
  117. data/spec/api/version_group_api_spec.rb +4 -4
  118. data/spec/spec_helper.rb +2 -2
  119. metadata +46 -49
  120. data/spec/api_client_spec.rb +0 -226
  121. data/spec/configuration_spec.rb +0 -42
@@ -4,9 +4,9 @@
4
4
  #No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5
5
 
6
6
  The version of the OpenAPI document: 20220523
7
- Contact: blah@cliffano.com
7
+ Contact: blah+oapicf@cliffano.com
8
8
  Generated by: https://openapi-generator.tech
9
- OpenAPI Generator version: 6.1.0-SNAPSHOT
9
+ Generator version: 7.6.0
10
10
 
11
11
  =end
12
12
 
@@ -4,9 +4,9 @@
4
4
  #No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5
5
 
6
6
  The version of the OpenAPI document: 20220523
7
- Contact: blah@cliffano.com
7
+ Contact: blah+oapicf@cliffano.com
8
8
  Generated by: https://openapi-generator.tech
9
- OpenAPI Generator version: 6.1.0-SNAPSHOT
9
+ Generator version: 7.6.0
10
10
 
11
11
  =end
12
12
 
@@ -4,9 +4,9 @@
4
4
  #No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5
5
 
6
6
  The version of the OpenAPI document: 20220523
7
- Contact: blah@cliffano.com
7
+ Contact: blah+oapicf@cliffano.com
8
8
  Generated by: https://openapi-generator.tech
9
- OpenAPI Generator version: 6.1.0-SNAPSHOT
9
+ Generator version: 7.6.0
10
10
 
11
11
  =end
12
12
 
@@ -4,9 +4,9 @@
4
4
  #No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5
5
 
6
6
  The version of the OpenAPI document: 20220523
7
- Contact: blah@cliffano.com
7
+ Contact: blah+oapicf@cliffano.com
8
8
  Generated by: https://openapi-generator.tech
9
- OpenAPI Generator version: 6.1.0-SNAPSHOT
9
+ Generator version: 7.6.0
10
10
 
11
11
  =end
12
12
 
@@ -4,9 +4,9 @@
4
4
  #No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5
5
 
6
6
  The version of the OpenAPI document: 20220523
7
- Contact: blah@cliffano.com
7
+ Contact: blah+oapicf@cliffano.com
8
8
  Generated by: https://openapi-generator.tech
9
- OpenAPI Generator version: 6.1.0-SNAPSHOT
9
+ Generator version: 7.6.0
10
10
 
11
11
  =end
12
12
 
@@ -4,9 +4,9 @@
4
4
  #No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5
5
 
6
6
  The version of the OpenAPI document: 20220523
7
- Contact: blah@cliffano.com
7
+ Contact: blah+oapicf@cliffano.com
8
8
  Generated by: https://openapi-generator.tech
9
- OpenAPI Generator version: 6.1.0-SNAPSHOT
9
+ Generator version: 7.6.0
10
10
 
11
11
  =end
12
12
 
@@ -4,9 +4,9 @@
4
4
  #No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5
5
 
6
6
  The version of the OpenAPI document: 20220523
7
- Contact: blah@cliffano.com
7
+ Contact: blah+oapicf@cliffano.com
8
8
  Generated by: https://openapi-generator.tech
9
- OpenAPI Generator version: 6.1.0-SNAPSHOT
9
+ Generator version: 7.6.0
10
10
 
11
11
  =end
12
12
 
@@ -4,9 +4,9 @@
4
4
  #No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5
5
 
6
6
  The version of the OpenAPI document: 20220523
7
- Contact: blah@cliffano.com
7
+ Contact: blah+oapicf@cliffano.com
8
8
  Generated by: https://openapi-generator.tech
9
- OpenAPI Generator version: 6.1.0-SNAPSHOT
9
+ Generator version: 7.6.0
10
10
 
11
11
  =end
12
12
 
@@ -4,9 +4,9 @@
4
4
  #No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5
5
 
6
6
  The version of the OpenAPI document: 20220523
7
- Contact: blah@cliffano.com
7
+ Contact: blah+oapicf@cliffano.com
8
8
  Generated by: https://openapi-generator.tech
9
- OpenAPI Generator version: 6.1.0-SNAPSHOT
9
+ Generator version: 7.6.0
10
10
 
11
11
  =end
12
12
 
@@ -4,9 +4,9 @@
4
4
  #No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5
5
 
6
6
  The version of the OpenAPI document: 20220523
7
- Contact: blah@cliffano.com
7
+ Contact: blah+oapicf@cliffano.com
8
8
  Generated by: https://openapi-generator.tech
9
- OpenAPI Generator version: 6.1.0-SNAPSHOT
9
+ Generator version: 7.6.0
10
10
 
11
11
  =end
12
12
 
@@ -4,9 +4,9 @@
4
4
  #No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5
5
 
6
6
  The version of the OpenAPI document: 20220523
7
- Contact: blah@cliffano.com
7
+ Contact: blah+oapicf@cliffano.com
8
8
  Generated by: https://openapi-generator.tech
9
- OpenAPI Generator version: 6.1.0-SNAPSHOT
9
+ Generator version: 7.6.0
10
10
 
11
11
  =end
12
12
 
@@ -4,9 +4,9 @@
4
4
  #No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5
5
 
6
6
  The version of the OpenAPI document: 20220523
7
- Contact: blah@cliffano.com
7
+ Contact: blah+oapicf@cliffano.com
8
8
  Generated by: https://openapi-generator.tech
9
- OpenAPI Generator version: 6.1.0-SNAPSHOT
9
+ Generator version: 7.6.0
10
10
 
11
11
  =end
12
12
 
@@ -4,9 +4,9 @@
4
4
  #No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5
5
 
6
6
  The version of the OpenAPI document: 20220523
7
- Contact: blah@cliffano.com
7
+ Contact: blah+oapicf@cliffano.com
8
8
  Generated by: https://openapi-generator.tech
9
- OpenAPI Generator version: 6.1.0-SNAPSHOT
9
+ Generator version: 7.6.0
10
10
 
11
11
  =end
12
12
 
@@ -4,9 +4,9 @@
4
4
  #No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5
5
 
6
6
  The version of the OpenAPI document: 20220523
7
- Contact: blah@cliffano.com
7
+ Contact: blah+oapicf@cliffano.com
8
8
  Generated by: https://openapi-generator.tech
9
- OpenAPI Generator version: 6.1.0-SNAPSHOT
9
+ Generator version: 7.6.0
10
10
 
11
11
  =end
12
12
 
@@ -4,9 +4,9 @@
4
4
  #No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5
5
 
6
6
  The version of the OpenAPI document: 20220523
7
- Contact: blah@cliffano.com
7
+ Contact: blah+oapicf@cliffano.com
8
8
  Generated by: https://openapi-generator.tech
9
- OpenAPI Generator version: 6.1.0-SNAPSHOT
9
+ Generator version: 7.6.0
10
10
 
11
11
  =end
12
12
 
@@ -4,9 +4,9 @@
4
4
  #No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5
5
 
6
6
  The version of the OpenAPI document: 20220523
7
- Contact: blah@cliffano.com
7
+ Contact: blah+oapicf@cliffano.com
8
8
  Generated by: https://openapi-generator.tech
9
- OpenAPI Generator version: 6.1.0-SNAPSHOT
9
+ Generator version: 7.6.0
10
10
 
11
11
  =end
12
12
 
@@ -4,9 +4,9 @@
4
4
  #No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5
5
 
6
6
  The version of the OpenAPI document: 20220523
7
- Contact: blah@cliffano.com
7
+ Contact: blah+oapicf@cliffano.com
8
8
  Generated by: https://openapi-generator.tech
9
- OpenAPI Generator version: 6.1.0-SNAPSHOT
9
+ Generator version: 7.6.0
10
10
 
11
11
  =end
12
12
 
@@ -4,9 +4,9 @@
4
4
  #No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5
5
 
6
6
  The version of the OpenAPI document: 20220523
7
- Contact: blah@cliffano.com
7
+ Contact: blah+oapicf@cliffano.com
8
8
  Generated by: https://openapi-generator.tech
9
- OpenAPI Generator version: 6.1.0-SNAPSHOT
9
+ Generator version: 7.6.0
10
10
 
11
11
  =end
12
12
 
@@ -4,9 +4,9 @@
4
4
  #No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5
5
 
6
6
  The version of the OpenAPI document: 20220523
7
- Contact: blah@cliffano.com
7
+ Contact: blah+oapicf@cliffano.com
8
8
  Generated by: https://openapi-generator.tech
9
- OpenAPI Generator version: 6.1.0-SNAPSHOT
9
+ Generator version: 7.6.0
10
10
 
11
11
  =end
12
12
 
@@ -4,9 +4,9 @@
4
4
  #No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5
5
 
6
6
  The version of the OpenAPI document: 20220523
7
- Contact: blah@cliffano.com
7
+ Contact: blah+oapicf@cliffano.com
8
8
  Generated by: https://openapi-generator.tech
9
- OpenAPI Generator version: 6.1.0-SNAPSHOT
9
+ Generator version: 7.6.0
10
10
 
11
11
  =end
12
12
 
@@ -4,9 +4,9 @@
4
4
  #No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5
5
 
6
6
  The version of the OpenAPI document: 20220523
7
- Contact: blah@cliffano.com
7
+ Contact: blah+oapicf@cliffano.com
8
8
  Generated by: https://openapi-generator.tech
9
- OpenAPI Generator version: 6.1.0-SNAPSHOT
9
+ Generator version: 7.6.0
10
10
 
11
11
  =end
12
12
 
@@ -4,9 +4,9 @@
4
4
  #No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5
5
 
6
6
  The version of the OpenAPI document: 20220523
7
- Contact: blah@cliffano.com
7
+ Contact: blah+oapicf@cliffano.com
8
8
  Generated by: https://openapi-generator.tech
9
- OpenAPI Generator version: 6.1.0-SNAPSHOT
9
+ Generator version: 7.6.0
10
10
 
11
11
  =end
12
12
 
@@ -4,9 +4,9 @@
4
4
  #No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5
5
 
6
6
  The version of the OpenAPI document: 20220523
7
- Contact: blah@cliffano.com
7
+ Contact: blah+oapicf@cliffano.com
8
8
  Generated by: https://openapi-generator.tech
9
- OpenAPI Generator version: 6.1.0-SNAPSHOT
9
+ Generator version: 7.6.0
10
10
 
11
11
  =end
12
12
 
@@ -4,9 +4,9 @@
4
4
  #No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5
5
 
6
6
  The version of the OpenAPI document: 20220523
7
- Contact: blah@cliffano.com
7
+ Contact: blah+oapicf@cliffano.com
8
8
  Generated by: https://openapi-generator.tech
9
- OpenAPI Generator version: 6.1.0-SNAPSHOT
9
+ Generator version: 7.6.0
10
10
 
11
11
  =end
12
12
 
@@ -17,6 +17,7 @@ require 'tempfile'
17
17
  require 'time'
18
18
  require 'typhoeus'
19
19
 
20
+
20
21
  module PokeApiClient
21
22
  class ApiClient
22
23
  # The Configuration object holding settings to be used in the API client.
@@ -45,9 +46,10 @@ module PokeApiClient
45
46
  # Call an API with given options.
46
47
  #
47
48
  # @return [Array<(Object, Integer, Hash)>] an array of 3 elements:
48
- # 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.
49
50
  def call_api(http_method, path, opts = {})
50
51
  request = build_request(http_method, path, opts)
52
+ tempfile = download_file(request) if opts[:return_type] == 'File'
51
53
  response = request.run
52
54
 
53
55
  if @config.debugging
@@ -69,7 +71,9 @@ module PokeApiClient
69
71
  end
70
72
  end
71
73
 
72
- if opts[:return_type]
74
+ if opts[:return_type] == 'File'
75
+ data = tempfile
76
+ elsif opts[:return_type]
73
77
  data = deserialize(response, opts[:return_type])
74
78
  else
75
79
  data = nil
@@ -124,9 +128,7 @@ module PokeApiClient
124
128
  end
125
129
  end
126
130
 
127
- request = Typhoeus::Request.new(url, req_opts)
128
- download_file(request) if opts[:return_type] == 'File'
129
- request
131
+ Typhoeus::Request.new(url, req_opts)
130
132
  end
131
133
 
132
134
  # Builds the HTTP request body
@@ -164,6 +166,8 @@ module PokeApiClient
164
166
  # process can use.
165
167
  #
166
168
  # @see Configuration#temp_folder_path
169
+ #
170
+ # @return [Tempfile] the tempfile generated
167
171
  def download_file(request)
168
172
  tempfile = nil
169
173
  encoding = nil
@@ -178,21 +182,24 @@ module PokeApiClient
178
182
  prefix = prefix + '-' unless prefix.end_with?('-')
179
183
  encoding = response.body.encoding
180
184
  tempfile = Tempfile.open(prefix, @config.temp_folder_path, encoding: encoding)
181
- @tempfile = tempfile
182
185
  end
183
186
  request.on_body do |chunk|
184
187
  chunk.force_encoding(encoding)
185
188
  tempfile.write(chunk)
186
189
  end
187
- request.on_complete do |response|
188
- if tempfile
189
- tempfile.close
190
- @config.logger.info "Temp file written to #{tempfile.path}, please copy the file to a proper folder "\
191
- "with e.g. `FileUtils.cp(tempfile.path, '/new/file/path')` otherwise the temp file "\
192
- "will be deleted automatically with GC. It's also recommended to delete the temp file "\
193
- "explicitly with `tempfile.delete`"
194
- 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}")
195
200
  end
201
+
202
+ tempfile
196
203
  end
197
204
 
198
205
  # Check if the given MIME is a JSON MIME.
@@ -204,7 +211,7 @@ module PokeApiClient
204
211
  # @param [String] mime MIME
205
212
  # @return [Boolean] True if the MIME is application/json
206
213
  def json_mime?(mime)
207
- (mime == '*/*') || !(mime =~ /Application\/.*json(?!p)(;.*)?/i).nil?
214
+ (mime == '*/*') || !(mime =~ /^Application\/.*json(?!p)(;.*)?/i).nil?
208
215
  end
209
216
 
210
217
  # Deserialize the response to the given return type.
@@ -213,15 +220,10 @@ module PokeApiClient
213
220
  # @param [String] return_type some examples: "User", "Array<User>", "Hash<String, Integer>"
214
221
  def deserialize(response, return_type)
215
222
  body = response.body
216
-
217
- # handle file downloading - return the File instance processed in request callbacks
218
- # note that response body is empty when the file is written in chunks in request on_body callback
219
- return @tempfile if return_type == 'File'
220
-
221
223
  return nil if body.nil? || body.empty?
222
224
 
223
225
  # return response body directly for String return type
224
- return body if return_type == 'String'
226
+ return body.to_s if return_type == 'String'
225
227
 
226
228
  # ensuring a default content type
227
229
  content_type = response.headers['Content-Type'] || 'application/json'
@@ -288,7 +290,7 @@ module PokeApiClient
288
290
  # @param [String] filename the filename to be sanitized
289
291
  # @return [String] the sanitized filename
290
292
  def sanitize_filename(filename)
291
- filename.gsub(/.*[\/\\]/, '')
293
+ filename.split(/[\/\\]/).last
292
294
  end
293
295
 
294
296
  def build_request_url(path, opts = {})
@@ -4,9 +4,9 @@
4
4
  #No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5
5
 
6
6
  The version of the OpenAPI document: 20220523
7
- Contact: blah@cliffano.com
7
+ Contact: blah+oapicf@cliffano.com
8
8
  Generated by: https://openapi-generator.tech
9
- OpenAPI Generator version: 6.1.0-SNAPSHOT
9
+ Generator version: 7.6.0
10
10
 
11
11
  =end
12
12
 
@@ -32,6 +32,7 @@ module PokeApiClient
32
32
  end
33
33
  else
34
34
  super arg
35
+ @message = arg
35
36
  end
36
37
  end
37
38
 
@@ -4,9 +4,9 @@
4
4
  #No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5
5
 
6
6
  The version of the OpenAPI document: 20220523
7
- Contact: blah@cliffano.com
7
+ Contact: blah+oapicf@cliffano.com
8
8
  Generated by: https://openapi-generator.tech
9
- OpenAPI Generator version: 6.1.0-SNAPSHOT
9
+ Generator version: 7.6.0
10
10
 
11
11
  =end
12
12
 
@@ -62,6 +62,16 @@ module PokeApiClient
62
62
  # Defines the access token (Bearer) used with OAuth2.
63
63
  attr_accessor :access_token
64
64
 
65
+ # Defines a Proc used to fetch or refresh access tokens (Bearer) used with OAuth2.
66
+ # Overrides the access_token if set
67
+ # @return [Proc]
68
+ attr_accessor :access_token_getter
69
+
70
+ # Set this to return data as binary instead of downloading a temp file. When enabled (set to true)
71
+ # HTTP responses with return type `File` will be returned as a stream of binary data.
72
+ # Default to false.
73
+ attr_accessor :return_binary_data
74
+
65
75
  # Set this to enable/disable debugging. When enabled (set to true), HTTP request/response
66
76
  # details will be logged with `logger.debug` (see the `logger` attribute).
67
77
  # Default to false.
@@ -142,7 +152,7 @@ module PokeApiClient
142
152
  @scheme = 'https'
143
153
  @host = 'pokeapi.co'
144
154
  @base_path = ''
145
- @server_index = 0
155
+ @server_index = nil
146
156
  @server_operation_index = {}
147
157
  @server_variables = {}
148
158
  @server_operation_variables = {}
@@ -190,10 +200,12 @@ module PokeApiClient
190
200
 
191
201
  # Returns base URL for specified operation based on server settings
192
202
  def base_url(operation = nil)
193
- index = server_operation_index.fetch(operation, server_index)
194
- return "#{scheme}://#{[host, base_path].join('/').gsub(/\/+/, '/')}".sub(/\/+\z/, '') if index == nil
195
-
196
- server_url(index, server_operation_variables.fetch(operation, server_variables), operation_server_settings[operation])
203
+ if operation_server_settings.key?(operation) then
204
+ index = server_operation_index.fetch(operation, server_index)
205
+ server_url(index.nil? ? 0 : index, server_operation_variables.fetch(operation, server_variables), operation_server_settings[operation])
206
+ else
207
+ server_index.nil? ? "#{scheme}://#{[host, base_path].join('/').gsub(/\/+/, '/')}".sub(/\/+\z/, '') : server_url(server_index, server_variables, nil)
208
+ end
197
209
  end
198
210
 
199
211
  # Gets API key (with prefix if set).
@@ -208,6 +220,12 @@ module PokeApiClient
208
220
  end
209
221
  end
210
222
 
223
+ # Gets access_token using access_token_getter or uses the static access_token
224
+ def access_token_with_refresh
225
+ return access_token if access_token_getter.nil?
226
+ access_token_getter.call
227
+ end
228
+
211
229
  # Gets Basic Auth token string
212
230
  def basic_auth_token
213
231
  'Basic ' + ["#{username}:#{password}"].pack('m').delete("\r\n")
@@ -242,8 +260,8 @@ module PokeApiClient
242
260
  servers = server_settings if servers == nil
243
261
 
244
262
  # check array index out of bound
245
- if (index < 0 || index >= servers.size)
246
- fail ArgumentError, "Invalid index #{index} when selecting the server. Must be less than #{servers.size}"
263
+ if (index.nil? || index < 0 || index >= servers.size)
264
+ fail ArgumentError, "Invalid index #{index} when selecting the server. Must not be nil and must be less than #{servers.size}"
247
265
  end
248
266
 
249
267
  server = servers[index]
@@ -268,5 +286,6 @@ module PokeApiClient
268
286
  url
269
287
  end
270
288
 
289
+
271
290
  end
272
291
  end
@@ -4,12 +4,12 @@
4
4
  #No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5
5
 
6
6
  The version of the OpenAPI document: 20220523
7
- Contact: blah@cliffano.com
7
+ Contact: blah+oapicf@cliffano.com
8
8
  Generated by: https://openapi-generator.tech
9
- OpenAPI Generator version: 6.1.0-SNAPSHOT
9
+ Generator version: 7.6.0
10
10
 
11
11
  =end
12
12
 
13
13
  module PokeApiClient
14
- VERSION = '0.10.0'
14
+ VERSION = '1.1.0'
15
15
  end
@@ -4,9 +4,9 @@
4
4
  #No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5
5
 
6
6
  The version of the OpenAPI document: 20220523
7
- Contact: blah@cliffano.com
7
+ Contact: blah+oapicf@cliffano.com
8
8
  Generated by: https://openapi-generator.tech
9
- OpenAPI Generator version: 6.1.0-SNAPSHOT
9
+ Generator version: 7.6.0
10
10
 
11
11
  =end
12
12
 
@@ -6,9 +6,9 @@
6
6
  #No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
7
7
 
8
8
  The version of the OpenAPI document: 20220523
9
- Contact: blah@cliffano.com
9
+ Contact: blah+oapicf@cliffano.com
10
10
  Generated by: https://openapi-generator.tech
11
- OpenAPI Generator version: 6.1.0-SNAPSHOT
11
+ Generator version: 7.6.0
12
12
 
13
13
  =end
14
14
 
@@ -19,13 +19,14 @@ Gem::Specification.new do |s|
19
19
  s.name = "pokeapi_client"
20
20
  s.version = PokeApiClient::VERSION
21
21
  s.platform = Gem::Platform::RUBY
22
- s.authors = ["Cliffano Subagio"]
23
- s.email = ["blah@cliffano.com"]
24
- s.homepage = "https://github.com/cliffano/pokeapi-clients"
22
+ s.authors = ["OpenAPI Clients Factory"]
23
+ s.email = ["blah+oapicf@cliffano.com"]
24
+ s.homepage = "https://github.com/oapicf/pokeapi-clients"
25
25
  s.summary = " Ruby Gem"
26
26
  s.description = "No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)"
27
27
  s.license = "MIT"
28
28
  s.required_ruby_version = ">= 2.0"
29
+ s.metadata = {}
29
30
 
30
31
  s.add_runtime_dependency 'typhoeus', '~> 1.0', '>= 1.0.1'
31
32
 
@@ -4,9 +4,9 @@
4
4
  #No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5
5
 
6
6
  The version of the OpenAPI document: 20220523
7
- Contact: blah@cliffano.com
7
+ Contact: blah+oapicf@cliffano.com
8
8
  Generated by: https://openapi-generator.tech
9
- OpenAPI Generator version: 6.1.0-SNAPSHOT
9
+ Generator version: 7.6.0
10
10
 
11
11
  =end
12
12
 
@@ -39,7 +39,7 @@ describe 'AbilityApi' do
39
39
  # @return [String]
40
40
  describe 'ability_list test' do
41
41
  it 'should work' do
42
- # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
42
+ # assertion here. ref: https://rspec.info/features/3-12/rspec-expectations/built-in-matchers/
43
43
  end
44
44
  end
45
45
 
@@ -49,7 +49,7 @@ describe 'AbilityApi' do
49
49
  # @return [String]
50
50
  describe 'ability_read test' do
51
51
  it 'should work' do
52
- # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
52
+ # assertion here. ref: https://rspec.info/features/3-12/rspec-expectations/built-in-matchers/
53
53
  end
54
54
  end
55
55
 
@@ -4,9 +4,9 @@
4
4
  #No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5
5
 
6
6
  The version of the OpenAPI document: 20220523
7
- Contact: blah@cliffano.com
7
+ Contact: blah+oapicf@cliffano.com
8
8
  Generated by: https://openapi-generator.tech
9
- OpenAPI Generator version: 6.1.0-SNAPSHOT
9
+ Generator version: 7.6.0
10
10
 
11
11
  =end
12
12
 
@@ -39,7 +39,7 @@ describe 'BerryApi' do
39
39
  # @return [String]
40
40
  describe 'berry_list test' do
41
41
  it 'should work' do
42
- # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
42
+ # assertion here. ref: https://rspec.info/features/3-12/rspec-expectations/built-in-matchers/
43
43
  end
44
44
  end
45
45
 
@@ -49,7 +49,7 @@ describe 'BerryApi' do
49
49
  # @return [String]
50
50
  describe 'berry_read test' do
51
51
  it 'should work' do
52
- # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
52
+ # assertion here. ref: https://rspec.info/features/3-12/rspec-expectations/built-in-matchers/
53
53
  end
54
54
  end
55
55