stage-ruby 0.0.02

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 (40) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +9 -0
  3. data/Gemfile.lock +73 -0
  4. data/README.md +143 -0
  5. data/Rakefile +8 -0
  6. data/docs/AccessFeatureForm.md +8 -0
  7. data/docs/AccessForm.md +9 -0
  8. data/docs/ClientUserForm.md +7 -0
  9. data/docs/ClientUserObjectForm.md +13 -0
  10. data/docs/Field.md +8 -0
  11. data/docs/StageApi.md +167 -0
  12. data/docs/StageError.md +11 -0
  13. data/example.rb +41 -0
  14. data/git_push.sh +55 -0
  15. data/lib/stage-ruby/api/stage_api.rb +232 -0
  16. data/lib/stage-ruby/api_client.rb +388 -0
  17. data/lib/stage-ruby/api_error.rb +57 -0
  18. data/lib/stage-ruby/configuration.rb +205 -0
  19. data/lib/stage-ruby/models/access_feature_form.rb +227 -0
  20. data/lib/stage-ruby/models/access_form.rb +246 -0
  21. data/lib/stage-ruby/models/client_user_form.rb +209 -0
  22. data/lib/stage-ruby/models/client_user_object_form.rb +267 -0
  23. data/lib/stage-ruby/models/field.rb +217 -0
  24. data/lib/stage-ruby/models/stage_error.rb +245 -0
  25. data/lib/stage-ruby/utils.rb +13 -0
  26. data/lib/stage-ruby/version.rb +14 -0
  27. data/lib/stage-ruby.rb +45 -0
  28. data/spec/api/stage_api_spec.rb +69 -0
  29. data/spec/api_client_spec.rb +225 -0
  30. data/spec/base_object_spec.rb +109 -0
  31. data/spec/configuration_spec.rb +41 -0
  32. data/spec/models/access_feature_form_spec.rb +46 -0
  33. data/spec/models/access_form_spec.rb +52 -0
  34. data/spec/models/client_user_form_spec.rb +40 -0
  35. data/spec/models/client_user_object_form_spec.rb +76 -0
  36. data/spec/models/field_spec.rb +46 -0
  37. data/spec/models/stage_error_spec.rb +64 -0
  38. data/spec/spec_helper.rb +110 -0
  39. data/stage-ruby.gemspec +38 -0
  40. metadata +152 -0
@@ -0,0 +1,245 @@
1
+ =begin
2
+ #Stage API Docs
3
+
4
+ #Stage Technologies complete API Documentation
5
+
6
+ OpenAPI spec version: 1.0.0
7
+ Contact: support@heystage.com
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+ Swagger Codegen version: 3.0.33
10
+ =end
11
+
12
+ require 'date'
13
+
14
+ module Stage
15
+ class StageError
16
+ # The string representation of the HTTP status.
17
+ attr_accessor :error
18
+
19
+ attr_accessor :field
20
+
21
+ # Additional error messages.
22
+ attr_accessor :message
23
+
24
+ # The HTTP status of this request.
25
+ attr_accessor :status
26
+
27
+ attr_accessor :timestamp
28
+
29
+ # Attribute mapping from ruby-style variable name to JSON key.
30
+ def self.attribute_map
31
+ {
32
+ :'error' => :'error',
33
+ :'field' => :'field',
34
+ :'message' => :'message',
35
+ :'status' => :'status',
36
+ :'timestamp' => :'timestamp'
37
+ }
38
+ end
39
+
40
+ # Attribute type mapping.
41
+ def self.openapi_types
42
+ {
43
+ :'error' => :'Object',
44
+ :'field' => :'Object',
45
+ :'message' => :'Object',
46
+ :'status' => :'Object',
47
+ :'timestamp' => :'Object'
48
+ }
49
+ end
50
+
51
+ # List of attributes with nullable: true
52
+ def self.openapi_nullable
53
+ Set.new([
54
+ ])
55
+ end
56
+
57
+ # Initializes the object
58
+ # @param [Hash] attributes Model attributes in the form of hash
59
+ def initialize(attributes = {})
60
+ if (!attributes.is_a?(Hash))
61
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Stage::StageError` initialize method"
62
+ end
63
+
64
+ # check to see if the attribute exists and convert string to symbol for hash key
65
+ attributes = attributes.each_with_object({}) { |(k, v), h|
66
+ if (!self.class.attribute_map.key?(k.to_sym))
67
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Stage::StageError`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
68
+ end
69
+ h[k.to_sym] = v
70
+ }
71
+
72
+ if attributes.key?(:'error')
73
+ self.error = attributes[:'error']
74
+ end
75
+
76
+ if attributes.key?(:'field')
77
+ self.field = attributes[:'field']
78
+ end
79
+
80
+ if attributes.key?(:'message')
81
+ self.message = attributes[:'message']
82
+ end
83
+
84
+ if attributes.key?(:'status')
85
+ self.status = attributes[:'status']
86
+ end
87
+
88
+ if attributes.key?(:'timestamp')
89
+ self.timestamp = attributes[:'timestamp']
90
+ end
91
+ end
92
+
93
+ # Show invalid properties with the reasons. Usually used together with valid?
94
+ # @return Array for valid properties with the reasons
95
+ def list_invalid_properties
96
+ invalid_properties = Array.new
97
+ invalid_properties
98
+ end
99
+
100
+ # Check to see if the all the properties in the model are valid
101
+ # @return true if the model is valid
102
+ def valid?
103
+ true
104
+ end
105
+
106
+ # Checks equality by comparing each attribute.
107
+ # @param [Object] Object to be compared
108
+ def ==(o)
109
+ return true if self.equal?(o)
110
+ self.class == o.class &&
111
+ error == o.error &&
112
+ field == o.field &&
113
+ message == o.message &&
114
+ status == o.status &&
115
+ timestamp == o.timestamp
116
+ end
117
+
118
+ # @see the `==` method
119
+ # @param [Object] Object to be compared
120
+ def eql?(o)
121
+ self == o
122
+ end
123
+
124
+ # Calculates hash code according to all attributes.
125
+ # @return [Integer] Hash code
126
+ def hash
127
+ [error, field, message, status, timestamp].hash
128
+ end
129
+
130
+ # Builds the object from hash
131
+ # @param [Hash] attributes Model attributes in the form of hash
132
+ # @return [Object] Returns the model itself
133
+ def self.build_from_hash(attributes)
134
+ new.build_from_hash(attributes)
135
+ end
136
+
137
+ # Builds the object from hash
138
+ # @param [Hash] attributes Model attributes in the form of hash
139
+ # @return [Object] Returns the model itself
140
+ def build_from_hash(attributes)
141
+ return nil unless attributes.is_a?(Hash)
142
+ self.class.openapi_types.each_pair do |key, type|
143
+ if type =~ /\AArray<(.*)>/i
144
+ # check to ensure the input is an array given that the attribute
145
+ # is documented as an array but the input is not
146
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
147
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
148
+ end
149
+ elsif !attributes[self.class.attribute_map[key]].nil?
150
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
151
+ elsif attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
152
+ self.send("#{key}=", nil)
153
+ end
154
+ end
155
+
156
+ self
157
+ end
158
+
159
+ # Deserializes the data based on type
160
+ # @param string type Data type
161
+ # @param string value Value to be deserialized
162
+ # @return [Object] Deserialized data
163
+ def _deserialize(type, value)
164
+ case type.to_sym
165
+ when :DateTime
166
+ DateTime.parse(value)
167
+ when :Date
168
+ Date.parse(value)
169
+ when :String
170
+ value.to_s
171
+ when :Integer
172
+ value.to_i
173
+ when :Float
174
+ value.to_f
175
+ when :Boolean
176
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
177
+ true
178
+ else
179
+ false
180
+ end
181
+ when :Object
182
+ # generic object (usually a Hash), return directly
183
+ value
184
+ when /\AArray<(?<inner_type>.+)>\z/
185
+ inner_type = Regexp.last_match[:inner_type]
186
+ value.map { |v| _deserialize(inner_type, v) }
187
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
188
+ k_type = Regexp.last_match[:k_type]
189
+ v_type = Regexp.last_match[:v_type]
190
+ {}.tap do |hash|
191
+ value.each do |k, v|
192
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
193
+ end
194
+ end
195
+ else # model
196
+ Stage.const_get(type).build_from_hash(value)
197
+ end
198
+ end
199
+
200
+ # Returns the string representation of the object
201
+ # @return [String] String presentation of the object
202
+ def to_s
203
+ to_hash.to_s
204
+ end
205
+
206
+ # to_body is an alias to to_hash (backward compatibility)
207
+ # @return [Hash] Returns the object in the form of hash
208
+ def to_body
209
+ to_hash
210
+ end
211
+
212
+ # Returns the object in the form of hash
213
+ # @return [Hash] Returns the object in the form of hash
214
+ def to_hash
215
+ hash = {}
216
+ self.class.attribute_map.each_pair do |attr, param|
217
+ value = self.send(attr)
218
+ if value.nil?
219
+ is_nullable = self.class.openapi_nullable.include?(attr)
220
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
221
+ end
222
+
223
+ hash[param] = _to_hash(value)
224
+ end
225
+ hash
226
+ end
227
+
228
+ # Outputs non-array value in the form of hash
229
+ # For object, use to_hash. Otherwise, just return the value
230
+ # @param [Object] value Any valid value
231
+ # @return [Hash] Returns the value in the form of hash
232
+ def _to_hash(value)
233
+ if value.is_a?(Array)
234
+ value.compact.map { |v| _to_hash(v) }
235
+ elsif value.is_a?(Hash)
236
+ {}.tap do |hash|
237
+ value.each { |k, v| hash[k] = _to_hash(v) }
238
+ end
239
+ elsif value.respond_to? :to_hash
240
+ value.to_hash
241
+ else
242
+ value
243
+ end
244
+ end end
245
+ end
@@ -0,0 +1,13 @@
1
+ SDK_API_PATH_PREFIX = "/sdk-api"
2
+
3
+ API_VERSION = "v1"
4
+
5
+ CREATE_USER_PATH = "#{SDK_API_PATH_PREFIX}/#{API_VERSION}/users"
6
+
7
+ def has_access_path(user_identifier)
8
+ "#{CREATE_USER_PATH}/#{user_identifier}/features"
9
+ end
10
+
11
+ def update_user_plan_path(user_identifier)
12
+ "#{SDK_API_PATH_PREFIX}/#{API_VERSION}/users/#{user_identifier}/plans"
13
+ end
@@ -0,0 +1,14 @@
1
+ =begin
2
+ #Stage API Docs
3
+
4
+ #Stage Technologies complete API Documentation
5
+
6
+ OpenAPI spec version: 1.0.0
7
+ Contact: support@heystage.com
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+ Swagger Codegen version: 3.0.33
10
+ =end
11
+
12
+ module Stage
13
+ VERSION = '0.0.02'
14
+ end
data/lib/stage-ruby.rb ADDED
@@ -0,0 +1,45 @@
1
+ =begin
2
+ #Stage API Docs
3
+
4
+ #Stage Technologies complete API Documentation
5
+
6
+ OpenAPI spec version: 1.0.0
7
+ Contact: support@heystage.com
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+ Swagger Codegen version: 3.0.33
10
+ =end
11
+
12
+ # Common files
13
+ require 'stage-ruby/api_client'
14
+ require 'stage-ruby/api_error'
15
+ require 'stage-ruby/version'
16
+ require 'stage-ruby/configuration'
17
+
18
+ # Models
19
+ require 'stage-ruby/models/access_feature_form'
20
+ require 'stage-ruby/models/access_form'
21
+ require 'stage-ruby/models/client_user_form'
22
+ require 'stage-ruby/models/client_user_object_form'
23
+ require 'stage-ruby/models/field'
24
+ require 'stage-ruby/models/stage_error'
25
+
26
+ # APIs
27
+ require 'stage-ruby/api/stage_api'
28
+
29
+ module Stage
30
+ class << self
31
+ # Customize default settings for the SDK using block.
32
+ # Stage.configure do |config|
33
+ # config.username = "xxx"
34
+ # config.password = "xxx"
35
+ # end
36
+ # If no block given, return the default Configuration object.
37
+ def configure
38
+ if block_given?
39
+ yield(Configuration.default)
40
+ else
41
+ Configuration.default
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,69 @@
1
+ =begin
2
+ #Stage API Docs
3
+
4
+ #Stage Technologies complete API Documentation
5
+
6
+ OpenAPI spec version: 1.0.0
7
+ Contact: support@heystage.com
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+ Swagger Codegen version: 3.0.33
10
+ =end
11
+
12
+ require 'spec_helper'
13
+ require 'json'
14
+
15
+ # Unit tests for Stage::StageApi
16
+ # Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen)
17
+ # Please update as you see appropriate
18
+ describe 'StageApi' do
19
+ before do
20
+ # run before each test
21
+ @instance = Stage::StageApi.new
22
+ end
23
+
24
+ after do
25
+ # run after each test
26
+ end
27
+
28
+ describe 'test an instance of StageApi' do
29
+ it 'should create an instance of StageApi' do
30
+ expect(@instance).to be_instance_of(Stage::StageApi)
31
+ end
32
+ end
33
+
34
+ # unit tests for create_user
35
+ # Creates a user and assigning it to a pre-defined role.
36
+ # @param body The payload containing the information to create a user.
37
+ # @param [Hash] opts the optional parameters
38
+ # @return [ClientUserForm]
39
+ describe 'create_user test' do
40
+ it 'should work' do
41
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
42
+ end
43
+ end
44
+
45
+ # unit tests for has_access
46
+ # Checks if a user has access to the identified feature.
47
+ # @param identifiers identifiers
48
+ # @param user_identifier The identifier of the user who is accessing the feature.
49
+ # @param [Hash] opts the optional parameters
50
+ # @return [AccessForm]
51
+ describe 'has_access test' do
52
+ it 'should work' do
53
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
54
+ end
55
+ end
56
+
57
+ # unit tests for update_user_plan
58
+ # Updates a user&#x27;s plan..
59
+ # @param body The payload containing the information to update a user&#x27;s plan. Only identifier and planIdentifier fields are required.
60
+ # @param user_identifier The identifier of the user.
61
+ # @param [Hash] opts the optional parameters
62
+ # @return [ClientUserForm]
63
+ describe 'update_user_plan test' do
64
+ it 'should work' do
65
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
66
+ end
67
+ end
68
+
69
+ end
@@ -0,0 +1,225 @@
1
+ =begin
2
+ #Stage API Docs
3
+
4
+ #Stage Technologies complete API Documentation
5
+
6
+ OpenAPI spec version: 1.0.0
7
+ Contact: support@heystage.com
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+ Swagger Codegen version: 3.0.33
10
+ =end
11
+
12
+ require 'spec_helper'
13
+
14
+ describe Stage::ApiClient do
15
+ context 'initialization' do
16
+ context 'URL stuff' do
17
+ context 'host' do
18
+ it 'removes http from host' do
19
+ Stage.configure { |c| c.host = 'http://example.com' }
20
+ expect(Stage::Configuration.default.host).to eq('example.com')
21
+ end
22
+
23
+ it 'removes https from host' do
24
+ Stage.configure { |c| c.host = 'https://wookiee.com' }
25
+ expect(Stage::ApiClient.default.config.host).to eq('wookiee.com')
26
+ end
27
+
28
+ it 'removes trailing path from host' do
29
+ Stage.configure { |c| c.host = 'hobo.com/v4' }
30
+ expect(Stage::Configuration.default.host).to eq('hobo.com')
31
+ end
32
+ end
33
+
34
+ context 'base_path' do
35
+ it "prepends a slash to base_path" do
36
+ Stage.configure { |c| c.base_path = 'v4/dog' }
37
+ expect(Stage::Configuration.default.base_path).to eq('/v4/dog')
38
+ end
39
+
40
+ it "doesn't prepend a slash if one is already there" do
41
+ Stage.configure { |c| c.base_path = '/v4/dog' }
42
+ expect(Stage::Configuration.default.base_path).to eq('/v4/dog')
43
+ end
44
+
45
+ it "ends up as a blank string if nil" do
46
+ Stage.configure { |c| c.base_path = nil }
47
+ expect(Stage::Configuration.default.base_path).to eq('')
48
+ end
49
+ end
50
+ end
51
+ end
52
+
53
+ describe 'params_encoding in #build_request' do
54
+ let(:config) { Stage::Configuration.new }
55
+ let(:api_client) { Stage::ApiClient.new(config) }
56
+
57
+ it 'defaults to nil' do
58
+ expect(Stage::Configuration.default.params_encoding).to eq(nil)
59
+ expect(config.params_encoding).to eq(nil)
60
+
61
+ request = api_client.build_request(:get, '/test')
62
+ expect(request.options[:params_encoding]).to eq(nil)
63
+ end
64
+
65
+ it 'can be customized' do
66
+ config.params_encoding = :multi
67
+ request = api_client.build_request(:get, '/test')
68
+ expect(request.options[:params_encoding]).to eq(:multi)
69
+ end
70
+ end
71
+
72
+ describe 'timeout in #build_request' do
73
+ let(:config) { Stage::Configuration.new }
74
+ let(:api_client) { Stage::ApiClient.new(config) }
75
+
76
+ it 'defaults to 0' do
77
+ expect(Stage::Configuration.default.timeout).to eq(0)
78
+ expect(config.timeout).to eq(0)
79
+
80
+ request = api_client.build_request(:get, '/test')
81
+ expect(request.options[:timeout]).to eq(0)
82
+ end
83
+
84
+ it 'can be customized' do
85
+ config.timeout = 100
86
+ request = api_client.build_request(:get, '/test')
87
+ expect(request.options[:timeout]).to eq(100)
88
+ end
89
+ end
90
+
91
+ describe '#deserialize' do
92
+ it "handles Array<Integer>" do
93
+ api_client = Stage::ApiClient.new
94
+ headers = { 'Content-Type' => 'application/json' }
95
+ response = double('response', headers: headers, body: '[12, 34]')
96
+ data = api_client.deserialize(response, 'Array<Integer>')
97
+ expect(data).to be_instance_of(Array)
98
+ expect(data).to eq([12, 34])
99
+ end
100
+
101
+ it 'handles Array<Array<Integer>>' do
102
+ api_client = Stage::ApiClient.new
103
+ headers = { 'Content-Type' => 'application/json' }
104
+ response = double('response', headers: headers, body: '[[12, 34], [56]]')
105
+ data = api_client.deserialize(response, 'Array<Array<Integer>>')
106
+ expect(data).to be_instance_of(Array)
107
+ expect(data).to eq([[12, 34], [56]])
108
+ end
109
+
110
+ it 'handles Hash<String, String>' do
111
+ api_client = Stage::ApiClient.new
112
+ headers = { 'Content-Type' => 'application/json' }
113
+ response = double('response', headers: headers, body: '{"message": "Hello"}')
114
+ data = api_client.deserialize(response, 'Hash<String, String>')
115
+ expect(data).to be_instance_of(Hash)
116
+ expect(data).to eq(:message => 'Hello')
117
+ end
118
+ end
119
+
120
+ describe "#object_to_hash" do
121
+ it 'ignores nils and includes empty arrays' do
122
+ # uncomment below to test object_to_hash for model
123
+ # api_client = Stage::ApiClient.new
124
+ # _model = Stage::ModelName.new
125
+ # update the model attribute below
126
+ # _model.id = 1
127
+ # update the expected value (hash) below
128
+ # expected = {id: 1, name: '', tags: []}
129
+ # expect(api_client.object_to_hash(_model)).to eq(expected)
130
+ end
131
+ end
132
+
133
+ describe '#build_collection_param' do
134
+ let(:param) { ['aa', 'bb', 'cc'] }
135
+ let(:api_client) { Stage::ApiClient.new }
136
+
137
+ it 'works for csv' do
138
+ expect(api_client.build_collection_param(param, :csv)).to eq('aa,bb,cc')
139
+ end
140
+
141
+ it 'works for ssv' do
142
+ expect(api_client.build_collection_param(param, :ssv)).to eq('aa bb cc')
143
+ end
144
+
145
+ it 'works for tsv' do
146
+ expect(api_client.build_collection_param(param, :tsv)).to eq("aa\tbb\tcc")
147
+ end
148
+
149
+ it 'works for pipes' do
150
+ expect(api_client.build_collection_param(param, :pipes)).to eq('aa|bb|cc')
151
+ end
152
+
153
+ it 'works for multi' do
154
+ expect(api_client.build_collection_param(param, :multi)).to eq(['aa', 'bb', 'cc'])
155
+ end
156
+
157
+ it 'fails for invalid collection format' do
158
+ expect(proc { api_client.build_collection_param(param, :INVALID) }).to raise_error(RuntimeError, 'unknown collection format: :INVALID')
159
+ end
160
+ end
161
+
162
+ describe '#json_mime?' do
163
+ let(:api_client) { Stage::ApiClient.new }
164
+
165
+ it 'works' do
166
+ expect(api_client.json_mime?(nil)).to eq false
167
+ expect(api_client.json_mime?('')).to eq false
168
+
169
+ expect(api_client.json_mime?('application/json')).to eq true
170
+ expect(api_client.json_mime?('application/json; charset=UTF8')).to eq true
171
+ expect(api_client.json_mime?('APPLICATION/JSON')).to eq true
172
+
173
+ expect(api_client.json_mime?('application/xml')).to eq false
174
+ expect(api_client.json_mime?('text/plain')).to eq false
175
+ expect(api_client.json_mime?('application/jsonp')).to eq false
176
+ end
177
+ end
178
+
179
+ describe '#select_header_accept' do
180
+ let(:api_client) { Stage::ApiClient.new }
181
+
182
+ it 'works' do
183
+ expect(api_client.select_header_accept(nil)).to be_nil
184
+ expect(api_client.select_header_accept([])).to be_nil
185
+
186
+ expect(api_client.select_header_accept(['application/json'])).to eq('application/json')
187
+ expect(api_client.select_header_accept(['application/xml', 'application/json; charset=UTF8'])).to eq('application/json; charset=UTF8')
188
+ expect(api_client.select_header_accept(['APPLICATION/JSON', 'text/html'])).to eq('APPLICATION/JSON')
189
+
190
+ expect(api_client.select_header_accept(['application/xml'])).to eq('application/xml')
191
+ expect(api_client.select_header_accept(['text/html', 'application/xml'])).to eq('text/html,application/xml')
192
+ end
193
+ end
194
+
195
+ describe '#select_header_content_type' do
196
+ let(:api_client) { Stage::ApiClient.new }
197
+
198
+ it 'works' do
199
+ expect(api_client.select_header_content_type(nil)).to eq('application/json')
200
+ expect(api_client.select_header_content_type([])).to eq('application/json')
201
+
202
+ expect(api_client.select_header_content_type(['application/json'])).to eq('application/json')
203
+ expect(api_client.select_header_content_type(['application/xml', 'application/json; charset=UTF8'])).to eq('application/json; charset=UTF8')
204
+ expect(api_client.select_header_content_type(['APPLICATION/JSON', 'text/html'])).to eq('APPLICATION/JSON')
205
+ expect(api_client.select_header_content_type(['application/xml'])).to eq('application/xml')
206
+ expect(api_client.select_header_content_type(['text/plain', 'application/xml'])).to eq('text/plain')
207
+ end
208
+ end
209
+
210
+ describe '#sanitize_filename' do
211
+ let(:api_client) { Stage::ApiClient.new }
212
+
213
+ it 'works' do
214
+ expect(api_client.sanitize_filename('sun')).to eq('sun')
215
+ expect(api_client.sanitize_filename('sun.gif')).to eq('sun.gif')
216
+ expect(api_client.sanitize_filename('../sun.gif')).to eq('sun.gif')
217
+ expect(api_client.sanitize_filename('/var/tmp/sun.gif')).to eq('sun.gif')
218
+ expect(api_client.sanitize_filename('./sun.gif')).to eq('sun.gif')
219
+ expect(api_client.sanitize_filename('..\sun.gif')).to eq('sun.gif')
220
+ expect(api_client.sanitize_filename('\var\tmp\sun.gif')).to eq('sun.gif')
221
+ expect(api_client.sanitize_filename('c:\var\tmp\sun.gif')).to eq('sun.gif')
222
+ expect(api_client.sanitize_filename('.\sun.gif')).to eq('sun.gif')
223
+ end
224
+ end
225
+ end