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,224 +0,0 @@
1
- =begin
2
- #No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
3
-
4
- The version of the OpenAPI document: 20220523
5
-
6
- Generated by: https://openapi-generator.tech
7
- OpenAPI Generator version: 5.4.0
8
-
9
- =end
10
-
11
- require 'spec_helper'
12
-
13
- describe PokeApiClient::ApiClient do
14
- context 'initialization' do
15
- context 'URL stuff' do
16
- context 'host' do
17
- it 'removes http from host' do
18
- PokeApiClient.configure { |c| c.host = 'http://example.com' }
19
- expect(PokeApiClient::Configuration.default.host).to eq('example.com')
20
- end
21
-
22
- it 'removes https from host' do
23
- PokeApiClient.configure { |c| c.host = 'https://wookiee.com' }
24
- expect(PokeApiClient::ApiClient.default.config.host).to eq('wookiee.com')
25
- end
26
-
27
- it 'removes trailing path from host' do
28
- PokeApiClient.configure { |c| c.host = 'hobo.com/v4' }
29
- expect(PokeApiClient::Configuration.default.host).to eq('hobo.com')
30
- end
31
- end
32
-
33
- context 'base_path' do
34
- it "prepends a slash to base_path" do
35
- PokeApiClient.configure { |c| c.base_path = 'v4/dog' }
36
- expect(PokeApiClient::Configuration.default.base_path).to eq('/v4/dog')
37
- end
38
-
39
- it "doesn't prepend a slash if one is already there" do
40
- PokeApiClient.configure { |c| c.base_path = '/v4/dog' }
41
- expect(PokeApiClient::Configuration.default.base_path).to eq('/v4/dog')
42
- end
43
-
44
- it "ends up as a blank string if nil" do
45
- PokeApiClient.configure { |c| c.base_path = nil }
46
- expect(PokeApiClient::Configuration.default.base_path).to eq('')
47
- end
48
- end
49
- end
50
- end
51
-
52
- describe 'params_encoding in #build_request' do
53
- let(:config) { PokeApiClient::Configuration.new }
54
- let(:api_client) { PokeApiClient::ApiClient.new(config) }
55
-
56
- it 'defaults to nil' do
57
- expect(PokeApiClient::Configuration.default.params_encoding).to eq(nil)
58
- expect(config.params_encoding).to eq(nil)
59
-
60
- request = api_client.build_request(:get, '/test')
61
- expect(request.options[:params_encoding]).to eq(nil)
62
- end
63
-
64
- it 'can be customized' do
65
- config.params_encoding = :multi
66
- request = api_client.build_request(:get, '/test')
67
- expect(request.options[:params_encoding]).to eq(:multi)
68
- end
69
- end
70
-
71
- describe 'timeout in #build_request' do
72
- let(:config) { PokeApiClient::Configuration.new }
73
- let(:api_client) { PokeApiClient::ApiClient.new(config) }
74
-
75
- it 'defaults to 0' do
76
- expect(PokeApiClient::Configuration.default.timeout).to eq(0)
77
- expect(config.timeout).to eq(0)
78
-
79
- request = api_client.build_request(:get, '/test')
80
- expect(request.options[:timeout]).to eq(0)
81
- end
82
-
83
- it 'can be customized' do
84
- config.timeout = 100
85
- request = api_client.build_request(:get, '/test')
86
- expect(request.options[:timeout]).to eq(100)
87
- end
88
- end
89
-
90
- describe '#deserialize' do
91
- it "handles Array<Integer>" do
92
- api_client = PokeApiClient::ApiClient.new
93
- headers = { 'Content-Type' => 'application/json' }
94
- response = double('response', headers: headers, body: '[12, 34]')
95
- data = api_client.deserialize(response, 'Array<Integer>')
96
- expect(data).to be_instance_of(Array)
97
- expect(data).to eq([12, 34])
98
- end
99
-
100
- it 'handles Array<Array<Integer>>' do
101
- api_client = PokeApiClient::ApiClient.new
102
- headers = { 'Content-Type' => 'application/json' }
103
- response = double('response', headers: headers, body: '[[12, 34], [56]]')
104
- data = api_client.deserialize(response, 'Array<Array<Integer>>')
105
- expect(data).to be_instance_of(Array)
106
- expect(data).to eq([[12, 34], [56]])
107
- end
108
-
109
- it 'handles Hash<String, String>' do
110
- api_client = PokeApiClient::ApiClient.new
111
- headers = { 'Content-Type' => 'application/json' }
112
- response = double('response', headers: headers, body: '{"message": "Hello"}')
113
- data = api_client.deserialize(response, 'Hash<String, String>')
114
- expect(data).to be_instance_of(Hash)
115
- expect(data).to eq(:message => 'Hello')
116
- end
117
- end
118
-
119
- describe "#object_to_hash" do
120
- it 'ignores nils and includes empty arrays' do
121
- # uncomment below to test object_to_hash for model
122
- # api_client = PokeApiClient::ApiClient.new
123
- # _model = PokeApiClient::ModelName.new
124
- # update the model attribute below
125
- # _model.id = 1
126
- # update the expected value (hash) below
127
- # expected = {id: 1, name: '', tags: []}
128
- # expect(api_client.object_to_hash(_model)).to eq(expected)
129
- end
130
- end
131
-
132
- describe '#build_collection_param' do
133
- let(:param) { ['aa', 'bb', 'cc'] }
134
- let(:api_client) { PokeApiClient::ApiClient.new }
135
-
136
- it 'works for csv' do
137
- expect(api_client.build_collection_param(param, :csv)).to eq('aa,bb,cc')
138
- end
139
-
140
- it 'works for ssv' do
141
- expect(api_client.build_collection_param(param, :ssv)).to eq('aa bb cc')
142
- end
143
-
144
- it 'works for tsv' do
145
- expect(api_client.build_collection_param(param, :tsv)).to eq("aa\tbb\tcc")
146
- end
147
-
148
- it 'works for pipes' do
149
- expect(api_client.build_collection_param(param, :pipes)).to eq('aa|bb|cc')
150
- end
151
-
152
- it 'works for multi' do
153
- expect(api_client.build_collection_param(param, :multi)).to eq(['aa', 'bb', 'cc'])
154
- end
155
-
156
- it 'fails for invalid collection format' do
157
- expect { api_client.build_collection_param(param, :INVALID) }.to raise_error(RuntimeError, 'unknown collection format: :INVALID')
158
- end
159
- end
160
-
161
- describe '#json_mime?' do
162
- let(:api_client) { PokeApiClient::ApiClient.new }
163
-
164
- it 'works' do
165
- expect(api_client.json_mime?(nil)).to eq false
166
- expect(api_client.json_mime?('')).to eq false
167
-
168
- expect(api_client.json_mime?('application/json')).to eq true
169
- expect(api_client.json_mime?('application/json; charset=UTF8')).to eq true
170
- expect(api_client.json_mime?('APPLICATION/JSON')).to eq true
171
-
172
- expect(api_client.json_mime?('application/xml')).to eq false
173
- expect(api_client.json_mime?('text/plain')).to eq false
174
- expect(api_client.json_mime?('application/jsonp')).to eq false
175
- end
176
- end
177
-
178
- describe '#select_header_accept' do
179
- let(:api_client) { PokeApiClient::ApiClient.new }
180
-
181
- it 'works' do
182
- expect(api_client.select_header_accept(nil)).to be_nil
183
- expect(api_client.select_header_accept([])).to be_nil
184
-
185
- expect(api_client.select_header_accept(['application/json'])).to eq('application/json')
186
- expect(api_client.select_header_accept(['application/xml', 'application/json; charset=UTF8'])).to eq('application/json; charset=UTF8')
187
- expect(api_client.select_header_accept(['APPLICATION/JSON', 'text/html'])).to eq('APPLICATION/JSON')
188
-
189
- expect(api_client.select_header_accept(['application/xml'])).to eq('application/xml')
190
- expect(api_client.select_header_accept(['text/html', 'application/xml'])).to eq('text/html,application/xml')
191
- end
192
- end
193
-
194
- describe '#select_header_content_type' do
195
- let(:api_client) { PokeApiClient::ApiClient.new }
196
-
197
- it 'works' do
198
- expect(api_client.select_header_content_type(nil)).to be_nil
199
- expect(api_client.select_header_content_type([])).to be_nil
200
-
201
- expect(api_client.select_header_content_type(['application/json'])).to eq('application/json')
202
- expect(api_client.select_header_content_type(['application/xml', 'application/json; charset=UTF8'])).to eq('application/json; charset=UTF8')
203
- expect(api_client.select_header_content_type(['APPLICATION/JSON', 'text/html'])).to eq('APPLICATION/JSON')
204
- expect(api_client.select_header_content_type(['application/xml'])).to eq('application/xml')
205
- expect(api_client.select_header_content_type(['text/plain', 'application/xml'])).to eq('text/plain')
206
- end
207
- end
208
-
209
- describe '#sanitize_filename' do
210
- let(:api_client) { PokeApiClient::ApiClient.new }
211
-
212
- it 'works' do
213
- expect(api_client.sanitize_filename('sun')).to eq('sun')
214
- expect(api_client.sanitize_filename('sun.gif')).to eq('sun.gif')
215
- expect(api_client.sanitize_filename('../sun.gif')).to eq('sun.gif')
216
- expect(api_client.sanitize_filename('/var/tmp/sun.gif')).to eq('sun.gif')
217
- expect(api_client.sanitize_filename('./sun.gif')).to eq('sun.gif')
218
- expect(api_client.sanitize_filename('..\sun.gif')).to eq('sun.gif')
219
- expect(api_client.sanitize_filename('\var\tmp\sun.gif')).to eq('sun.gif')
220
- expect(api_client.sanitize_filename('c:\var\tmp\sun.gif')).to eq('sun.gif')
221
- expect(api_client.sanitize_filename('.\sun.gif')).to eq('sun.gif')
222
- end
223
- end
224
- end
@@ -1,40 +0,0 @@
1
- =begin
2
- #No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
3
-
4
- The version of the OpenAPI document: 20220523
5
-
6
- Generated by: https://openapi-generator.tech
7
- OpenAPI Generator version: 5.4.0
8
-
9
- =end
10
-
11
- require 'spec_helper'
12
-
13
- describe PokeApiClient::Configuration do
14
- let(:config) { PokeApiClient::Configuration.default }
15
-
16
- before(:each) do
17
- # uncomment below to setup host and base_path
18
- # require 'URI'
19
- # uri = URI.parse("https://pokeapi.co")
20
- # PokeApiClient.configure do |c|
21
- # c.host = uri.host
22
- # c.base_path = uri.path
23
- # end
24
- end
25
-
26
- describe '#base_url' do
27
- it 'should have the default value' do
28
- # uncomment below to test default value of the base path
29
- # expect(config.base_url).to eq("https://pokeapi.co")
30
- end
31
-
32
- it 'should remove trailing slashes' do
33
- [nil, '', '/', '//'].each do |base_path|
34
- config.base_path = base_path
35
- # uncomment below to test trailing slashes
36
- # expect(config.base_url).to eq("https://pokeapi.co")
37
- end
38
- end
39
- end
40
- end