pokeapi_client 0.10.0 → 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.
- checksums.yaml +4 -4
- data/Gemfile.lock +26 -24
- data/README.md +7 -6
- data/bin/bundle +5 -10
- data/bin/byebug +1 -1
- data/bin/coderay +1 -1
- data/bin/htmldiff +1 -1
- data/bin/ldiff +1 -1
- data/bin/pry +1 -1
- data/bin/racc +27 -0
- data/bin/rake +1 -1
- data/bin/rspec +1 -1
- data/bin/rubocop +1 -1
- data/bin/ruby-parse +1 -1
- data/bin/ruby-rewrite +1 -1
- data/lib/pokeapi_client/api/ability_api.rb +2 -2
- data/lib/pokeapi_client/api/berry_api.rb +2 -2
- data/lib/pokeapi_client/api/berry_firmness_api.rb +2 -2
- data/lib/pokeapi_client/api/berry_flavor_api.rb +2 -2
- data/lib/pokeapi_client/api/characteristic_api.rb +2 -2
- data/lib/pokeapi_client/api/contest_effect_api.rb +2 -2
- data/lib/pokeapi_client/api/contest_type_api.rb +2 -2
- data/lib/pokeapi_client/api/egg_group_api.rb +2 -2
- data/lib/pokeapi_client/api/encounter_condition_api.rb +2 -2
- data/lib/pokeapi_client/api/encounter_condition_value_api.rb +2 -2
- data/lib/pokeapi_client/api/encounter_method_api.rb +2 -2
- data/lib/pokeapi_client/api/evolution_chain_api.rb +2 -2
- data/lib/pokeapi_client/api/evolution_trigger_api.rb +2 -2
- data/lib/pokeapi_client/api/gender_api.rb +2 -2
- data/lib/pokeapi_client/api/generation_api.rb +2 -2
- data/lib/pokeapi_client/api/growth_rate_api.rb +2 -2
- data/lib/pokeapi_client/api/item_api.rb +2 -2
- data/lib/pokeapi_client/api/item_attribute_api.rb +2 -2
- data/lib/pokeapi_client/api/item_category_api.rb +2 -2
- data/lib/pokeapi_client/api/item_fling_effect_api.rb +2 -2
- data/lib/pokeapi_client/api/item_pocket_api.rb +2 -2
- data/lib/pokeapi_client/api/language_api.rb +2 -2
- data/lib/pokeapi_client/api/location_api.rb +2 -2
- data/lib/pokeapi_client/api/location_area_api.rb +2 -2
- data/lib/pokeapi_client/api/machine_api.rb +2 -2
- data/lib/pokeapi_client/api/move_ailment_api.rb +2 -2
- data/lib/pokeapi_client/api/move_api.rb +2 -2
- data/lib/pokeapi_client/api/move_battle_style_api.rb +2 -2
- data/lib/pokeapi_client/api/move_category_api.rb +2 -2
- data/lib/pokeapi_client/api/move_damage_class_api.rb +2 -2
- data/lib/pokeapi_client/api/move_learn_method_api.rb +2 -2
- data/lib/pokeapi_client/api/move_target_api.rb +2 -2
- data/lib/pokeapi_client/api/nature_api.rb +2 -2
- data/lib/pokeapi_client/api/pal_park_area_api.rb +2 -2
- data/lib/pokeapi_client/api/pokeathlon_stat_api.rb +2 -2
- data/lib/pokeapi_client/api/pokedex_api.rb +2 -2
- data/lib/pokeapi_client/api/pokemon_api.rb +2 -2
- data/lib/pokeapi_client/api/pokemon_color_api.rb +2 -2
- data/lib/pokeapi_client/api/pokemon_form_api.rb +2 -2
- data/lib/pokeapi_client/api/pokemon_habitat_api.rb +2 -2
- data/lib/pokeapi_client/api/pokemon_shape_api.rb +2 -2
- data/lib/pokeapi_client/api/pokemon_species_api.rb +2 -2
- data/lib/pokeapi_client/api/region_api.rb +2 -2
- data/lib/pokeapi_client/api/stat_api.rb +2 -2
- data/lib/pokeapi_client/api/super_contest_effect_api.rb +2 -2
- data/lib/pokeapi_client/api/type_api.rb +2 -2
- data/lib/pokeapi_client/api/version_api.rb +2 -2
- data/lib/pokeapi_client/api/version_group_api.rb +2 -2
- data/lib/pokeapi_client/api_client.rb +24 -22
- data/lib/pokeapi_client/api_error.rb +3 -2
- data/lib/pokeapi_client/configuration.rb +28 -9
- data/lib/pokeapi_client/version.rb +3 -3
- data/lib/pokeapi_client.rb +2 -2
- data/pokeapi_client.gemspec +6 -5
- data/spec/api/ability_api_spec.rb +4 -4
- data/spec/api/berry_api_spec.rb +4 -4
- data/spec/api/berry_firmness_api_spec.rb +4 -4
- data/spec/api/berry_flavor_api_spec.rb +4 -4
- data/spec/api/characteristic_api_spec.rb +4 -4
- data/spec/api/contest_effect_api_spec.rb +4 -4
- data/spec/api/contest_type_api_spec.rb +4 -4
- data/spec/api/egg_group_api_spec.rb +4 -4
- data/spec/api/encounter_condition_api_spec.rb +4 -4
- data/spec/api/encounter_condition_value_api_spec.rb +4 -4
- data/spec/api/encounter_method_api_spec.rb +4 -4
- data/spec/api/evolution_chain_api_spec.rb +4 -4
- data/spec/api/evolution_trigger_api_spec.rb +4 -4
- data/spec/api/gender_api_spec.rb +4 -4
- data/spec/api/generation_api_spec.rb +4 -4
- data/spec/api/growth_rate_api_spec.rb +4 -4
- data/spec/api/item_api_spec.rb +4 -4
- data/spec/api/item_attribute_api_spec.rb +4 -4
- data/spec/api/item_category_api_spec.rb +4 -4
- data/spec/api/item_fling_effect_api_spec.rb +4 -4
- data/spec/api/item_pocket_api_spec.rb +4 -4
- data/spec/api/language_api_spec.rb +4 -4
- data/spec/api/location_api_spec.rb +4 -4
- data/spec/api/location_area_api_spec.rb +4 -4
- data/spec/api/machine_api_spec.rb +4 -4
- data/spec/api/move_ailment_api_spec.rb +4 -4
- data/spec/api/move_api_spec.rb +4 -4
- data/spec/api/move_battle_style_api_spec.rb +4 -4
- data/spec/api/move_category_api_spec.rb +4 -4
- data/spec/api/move_damage_class_api_spec.rb +4 -4
- data/spec/api/move_learn_method_api_spec.rb +4 -4
- data/spec/api/move_target_api_spec.rb +4 -4
- data/spec/api/nature_api_spec.rb +4 -4
- data/spec/api/pal_park_area_api_spec.rb +4 -4
- data/spec/api/pokeathlon_stat_api_spec.rb +4 -4
- data/spec/api/pokedex_api_spec.rb +4 -4
- data/spec/api/pokemon_api_spec.rb +4 -4
- data/spec/api/pokemon_color_api_spec.rb +4 -4
- data/spec/api/pokemon_form_api_spec.rb +4 -4
- data/spec/api/pokemon_habitat_api_spec.rb +4 -4
- data/spec/api/pokemon_shape_api_spec.rb +4 -4
- data/spec/api/pokemon_species_api_spec.rb +4 -4
- data/spec/api/region_api_spec.rb +4 -4
- data/spec/api/stat_api_spec.rb +4 -4
- data/spec/api/super_contest_effect_api_spec.rb +4 -4
- data/spec/api/type_api_spec.rb +4 -4
- data/spec/api/version_api_spec.rb +4 -4
- data/spec/api/version_group_api_spec.rb +4 -4
- data/spec/spec_helper.rb +2 -2
- metadata +45 -48
- data/spec/api_client_spec.rb +0 -226
- 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
|
-
|
9
|
+
Generator version: 7.4.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
|
-
|
9
|
+
Generator version: 7.4.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
|
-
|
9
|
+
Generator version: 7.4.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
|
-
|
9
|
+
Generator version: 7.4.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
|
-
|
9
|
+
Generator version: 7.4.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
|
-
|
9
|
+
Generator version: 7.4.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
|
-
|
9
|
+
Generator version: 7.4.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
|
-
|
9
|
+
Generator version: 7.4.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
|
-
|
9
|
+
Generator version: 7.4.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
|
-
|
9
|
+
Generator version: 7.4.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
|
-
|
9
|
+
Generator version: 7.4.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
|
-
|
9
|
+
Generator version: 7.4.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
|
-
|
9
|
+
Generator version: 7.4.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
|
-
|
9
|
+
Generator version: 7.4.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
|
-
|
9
|
+
Generator version: 7.4.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
|
-
|
9
|
+
Generator version: 7.4.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
|
-
|
9
|
+
Generator version: 7.4.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
|
-
|
9
|
+
Generator version: 7.4.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
|
-
|
9
|
+
Generator version: 7.4.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
|
-
|
9
|
+
Generator version: 7.4.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
|
-
|
9
|
+
Generator version: 7.4.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
|
-
|
9
|
+
Generator version: 7.4.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
|
-
|
9
|
+
Generator version: 7.4.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
|
-
|
9
|
+
Generator version: 7.4.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 (
|
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
|
-
|
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
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
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.
|
@@ -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'
|
@@ -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
|
-
|
9
|
+
Generator version: 7.4.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
|
-
|
9
|
+
Generator version: 7.4.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 =
|
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
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
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
|
-
|
9
|
+
Generator version: 7.4.0
|
10
10
|
|
11
11
|
=end
|
12
12
|
|
13
13
|
module PokeApiClient
|
14
|
-
VERSION = '0.
|
14
|
+
VERSION = '1.0.0'
|
15
15
|
end
|
data/lib/pokeapi_client.rb
CHANGED
@@ -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
|
-
|
9
|
+
Generator version: 7.4.0
|
10
10
|
|
11
11
|
=end
|
12
12
|
|
data/pokeapi_client.gemspec
CHANGED
@@ -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
|
-
|
11
|
+
Generator version: 7.4.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 = ["
|
23
|
-
s.email = ["blah@cliffano.com"]
|
24
|
-
s.homepage = "https://github.com/
|
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
|
-
|
9
|
+
Generator version: 7.4.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://
|
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://
|
52
|
+
# assertion here. ref: https://rspec.info/features/3-12/rspec-expectations/built-in-matchers/
|
53
53
|
end
|
54
54
|
end
|
55
55
|
|
data/spec/api/berry_api_spec.rb
CHANGED
@@ -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
|
-
|
9
|
+
Generator version: 7.4.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://
|
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://
|
52
|
+
# assertion here. ref: https://rspec.info/features/3-12/rspec-expectations/built-in-matchers/
|
53
53
|
end
|
54
54
|
end
|
55
55
|
|