insights-approval-api-client 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (90) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +9 -0
  3. data/README.md +142 -0
  4. data/Rakefile +10 -0
  5. data/client-meta.json +9 -0
  6. data/docs/Action.md +27 -0
  7. data/docs/ActionApi.md +172 -0
  8. data/docs/ActionCollection.md +21 -0
  9. data/docs/CollectionLinks.md +23 -0
  10. data/docs/CollectionMetadata.md +21 -0
  11. data/docs/GraphqlApi.md +62 -0
  12. data/docs/GraphqlIn.md +21 -0
  13. data/docs/GraphqlOut.md +19 -0
  14. data/docs/GroupRef.md +19 -0
  15. data/docs/HttpApiError.md +19 -0
  16. data/docs/HttpApiErrorCollection.md +17 -0
  17. data/docs/Request.md +49 -0
  18. data/docs/RequestApi.md +292 -0
  19. data/docs/RequestCollection.md +21 -0
  20. data/docs/RequestIn.md +23 -0
  21. data/docs/ResourceObject.md +21 -0
  22. data/docs/Tag.md +17 -0
  23. data/docs/TagResource.md +21 -0
  24. data/docs/Template.md +23 -0
  25. data/docs/TemplateApi.md +124 -0
  26. data/docs/TemplateCollection.md +21 -0
  27. data/docs/Workflow.md +29 -0
  28. data/docs/WorkflowApi.md +469 -0
  29. data/docs/WorkflowCollection.md +21 -0
  30. data/generate.sh +9 -0
  31. data/git_push.sh +58 -0
  32. data/insights-approval-api-client.gemspec +39 -0
  33. data/lib/insights-approval-api-client.rb +63 -0
  34. data/lib/insights-approval-api-client/api/action_api.rb +231 -0
  35. data/lib/insights-approval-api-client/api/graphql_api.rb +86 -0
  36. data/lib/insights-approval-api-client/api/request_api.rb +381 -0
  37. data/lib/insights-approval-api-client/api/template_api.rb +169 -0
  38. data/lib/insights-approval-api-client/api/workflow_api.rb +630 -0
  39. data/lib/insights-approval-api-client/api_client.rb +386 -0
  40. data/lib/insights-approval-api-client/api_error.rb +57 -0
  41. data/lib/insights-approval-api-client/configuration.rb +268 -0
  42. data/lib/insights-approval-api-client/models/action.rb +293 -0
  43. data/lib/insights-approval-api-client/models/action_collection.rb +226 -0
  44. data/lib/insights-approval-api-client/models/collection_links.rb +237 -0
  45. data/lib/insights-approval-api-client/models/collection_metadata.rb +227 -0
  46. data/lib/insights-approval-api-client/models/graphql_in.rb +237 -0
  47. data/lib/insights-approval-api-client/models/graphql_out.rb +219 -0
  48. data/lib/insights-approval-api-client/models/group_ref.rb +223 -0
  49. data/lib/insights-approval-api-client/models/http_api_error.rb +218 -0
  50. data/lib/insights-approval-api-client/models/http_api_error_collection.rb +210 -0
  51. data/lib/insights-approval-api-client/models/request.rb +417 -0
  52. data/lib/insights-approval-api-client/models/request_collection.rb +226 -0
  53. data/lib/insights-approval-api-client/models/request_in.rb +255 -0
  54. data/lib/insights-approval-api-client/models/resource_object.rb +243 -0
  55. data/lib/insights-approval-api-client/models/tag.rb +207 -0
  56. data/lib/insights-approval-api-client/models/tag_resource.rb +242 -0
  57. data/lib/insights-approval-api-client/models/template.rb +235 -0
  58. data/lib/insights-approval-api-client/models/template_collection.rb +226 -0
  59. data/lib/insights-approval-api-client/models/workflow.rb +283 -0
  60. data/lib/insights-approval-api-client/models/workflow_collection.rb +226 -0
  61. data/lib/insights-approval-api-client/version.rb +15 -0
  62. data/openapi.json +1540 -0
  63. data/spec/api/action_api_spec.rb +72 -0
  64. data/spec/api/graphql_api_spec.rb +47 -0
  65. data/spec/api/request_api_spec.rb +100 -0
  66. data/spec/api/template_api_spec.rb +62 -0
  67. data/spec/api/workflow_api_spec.rb +145 -0
  68. data/spec/api_client_spec.rb +226 -0
  69. data/spec/configuration_spec.rb +42 -0
  70. data/spec/models/action_collection_spec.rb +53 -0
  71. data/spec/models/action_spec.rb +75 -0
  72. data/spec/models/collection_links_spec.rb +59 -0
  73. data/spec/models/collection_metadata_spec.rb +53 -0
  74. data/spec/models/graphql_in_spec.rb +53 -0
  75. data/spec/models/graphql_out_spec.rb +47 -0
  76. data/spec/models/group_ref_spec.rb +47 -0
  77. data/spec/models/http_api_error_collection_spec.rb +41 -0
  78. data/spec/models/http_api_error_spec.rb +47 -0
  79. data/spec/models/request_collection_spec.rb +53 -0
  80. data/spec/models/request_in_spec.rb +59 -0
  81. data/spec/models/request_spec.rb +145 -0
  82. data/spec/models/resource_object_spec.rb +53 -0
  83. data/spec/models/tag_resource_spec.rb +53 -0
  84. data/spec/models/tag_spec.rb +41 -0
  85. data/spec/models/template_collection_spec.rb +53 -0
  86. data/spec/models/template_spec.rb +59 -0
  87. data/spec/models/workflow_collection_spec.rb +53 -0
  88. data/spec/models/workflow_spec.rb +77 -0
  89. data/spec/spec_helper.rb +111 -0
  90. metadata +218 -0
@@ -0,0 +1,72 @@
1
+ =begin
2
+ #Insights Service Approval APIs
3
+
4
+ #APIs to query approval service
5
+
6
+ The version of the OpenAPI document: 1.2.0
7
+ Contact: support@redhat.com
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 4.2.2
10
+
11
+ =end
12
+
13
+ require 'spec_helper'
14
+ require 'json'
15
+
16
+ # Unit tests for ApprovalApiClient::ActionApi
17
+ # Automatically generated by openapi-generator (https://openapi-generator.tech)
18
+ # Please update as you see appropriate
19
+ describe 'ActionApi' do
20
+ before do
21
+ # run before each test
22
+ @api_instance = ApprovalApiClient::ActionApi.new
23
+ end
24
+
25
+ after do
26
+ # run after each test
27
+ end
28
+
29
+ describe 'test an instance of ActionApi' do
30
+ it 'should create an instance of ActionApi' do
31
+ expect(@api_instance).to be_instance_of(ApprovalApiClient::ActionApi)
32
+ end
33
+ end
34
+
35
+ # unit tests for create_action
36
+ # Add an action to a given request
37
+ # Add an action to a given request. Admin can do approve, deny, memo, and cancel operations; approver can do approve, deny and memo operations; while requester can do only cancel operation.
38
+ # @param request_id Id of request
39
+ # @param action Action object that will be added
40
+ # @param [Hash] opts the optional parameters
41
+ # @return [Action]
42
+ describe 'create_action test' do
43
+ it 'should work' do
44
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
45
+ end
46
+ end
47
+
48
+ # unit tests for list_actions_by_request
49
+ # List all actions of a request
50
+ # Return actions in a given request, available for admin/approver
51
+ # @param request_id Id of request
52
+ # @param [Hash] opts the optional parameters
53
+ # @return [ActionCollection]
54
+ describe 'list_actions_by_request test' do
55
+ it 'should work' do
56
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
57
+ end
58
+ end
59
+
60
+ # unit tests for show_action
61
+ # Return an user action by id
62
+ # Return an user action by id, available to all
63
+ # @param id Query by id
64
+ # @param [Hash] opts the optional parameters
65
+ # @return [Action]
66
+ describe 'show_action test' do
67
+ it 'should work' do
68
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
69
+ end
70
+ end
71
+
72
+ end
@@ -0,0 +1,47 @@
1
+ =begin
2
+ #Insights Service Approval APIs
3
+
4
+ #APIs to query approval service
5
+
6
+ The version of the OpenAPI document: 1.2.0
7
+ Contact: support@redhat.com
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 4.2.2
10
+
11
+ =end
12
+
13
+ require 'spec_helper'
14
+ require 'json'
15
+
16
+ # Unit tests for ApprovalApiClient::GraphqlApi
17
+ # Automatically generated by openapi-generator (https://openapi-generator.tech)
18
+ # Please update as you see appropriate
19
+ describe 'GraphqlApi' do
20
+ before do
21
+ # run before each test
22
+ @api_instance = ApprovalApiClient::GraphqlApi.new
23
+ end
24
+
25
+ after do
26
+ # run after each test
27
+ end
28
+
29
+ describe 'test an instance of GraphqlApi' do
30
+ it 'should create an instance of GraphqlApi' do
31
+ expect(@api_instance).to be_instance_of(ApprovalApiClient::GraphqlApi)
32
+ end
33
+ end
34
+
35
+ # unit tests for post_graphql
36
+ # Perform a GraphQL Query
37
+ # Performs a GraphQL Query
38
+ # @param graphql_in GraphQL Query Request
39
+ # @param [Hash] opts the optional parameters
40
+ # @return [GraphqlOut]
41
+ describe 'post_graphql test' do
42
+ it 'should work' do
43
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
44
+ end
45
+ end
46
+
47
+ end
@@ -0,0 +1,100 @@
1
+ =begin
2
+ #Insights Service Approval APIs
3
+
4
+ #APIs to query approval service
5
+
6
+ The version of the OpenAPI document: 1.2.0
7
+ Contact: support@redhat.com
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 4.2.2
10
+
11
+ =end
12
+
13
+ require 'spec_helper'
14
+ require 'json'
15
+
16
+ # Unit tests for ApprovalApiClient::RequestApi
17
+ # Automatically generated by openapi-generator (https://openapi-generator.tech)
18
+ # Please update as you see appropriate
19
+ describe 'RequestApi' do
20
+ before do
21
+ # run before each test
22
+ @api_instance = ApprovalApiClient::RequestApi.new
23
+ end
24
+
25
+ after do
26
+ # run after each test
27
+ end
28
+
29
+ describe 'test an instance of RequestApi' do
30
+ it 'should create an instance of RequestApi' do
31
+ expect(@api_instance).to be_instance_of(ApprovalApiClient::RequestApi)
32
+ end
33
+ end
34
+
35
+ # unit tests for create_request
36
+ # Add an approval request by given parameters
37
+ # Add an approval request by given parameters, available to anyone
38
+ # @param request_in Parameters need to create a request
39
+ # @param [Hash] opts the optional parameters
40
+ # @return [Request]
41
+ describe 'create_request test' do
42
+ it 'should work' do
43
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
44
+ end
45
+ end
46
+
47
+ # unit tests for list_requests
48
+ # Return an array of requester made approval requests, available to anyone
49
+ # The result depends on the x-rh-persona header (approval/admin, approval/requseter, or approval/approver). Program generated child requests are not included.
50
+ # @param [Hash] opts the optional parameters
51
+ # @option opts [String] :x_rh_persona Current login user's persona
52
+ # @option opts [Integer] :limit How many items to return at one time (max 1000)
53
+ # @option opts [Integer] :offset Starting Offset
54
+ # @option opts [Object] :filter Filter for querying collections.
55
+ # @option opts [String] :sort_by Parameter to sort collection
56
+ # @return [RequestCollection]
57
+ describe 'list_requests test' do
58
+ it 'should work' do
59
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
60
+ end
61
+ end
62
+
63
+ # unit tests for list_requests_by_request
64
+ # Return an array of child requests of a given request id
65
+ # Return an array of child requests of a given request id. The result depends on the x-rh-persona header (approval/admin, approval/requseter, or approval/approver).
66
+ # @param request_id Id of request
67
+ # @param [Hash] opts the optional parameters
68
+ # @option opts [String] :x_rh_persona Current login user's persona
69
+ # @return [RequestCollection]
70
+ describe 'list_requests_by_request test' do
71
+ it 'should work' do
72
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
73
+ end
74
+ end
75
+
76
+ # unit tests for show_request
77
+ # Return an approval request by given id
78
+ # Return an approval request by given id, available to anyone who can access the request
79
+ # @param id Query by id
80
+ # @param [Hash] opts the optional parameters
81
+ # @return [Request]
82
+ describe 'show_request test' do
83
+ it 'should work' do
84
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
85
+ end
86
+ end
87
+
88
+ # unit tests for show_request_content
89
+ # Return request content of a given request id
90
+ # Return request content of a given request id, available to all
91
+ # @param request_id Id of request
92
+ # @param [Hash] opts the optional parameters
93
+ # @return [Object]
94
+ describe 'show_request_content test' do
95
+ it 'should work' do
96
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
97
+ end
98
+ end
99
+
100
+ end
@@ -0,0 +1,62 @@
1
+ =begin
2
+ #Insights Service Approval APIs
3
+
4
+ #APIs to query approval service
5
+
6
+ The version of the OpenAPI document: 1.2.0
7
+ Contact: support@redhat.com
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 4.2.2
10
+
11
+ =end
12
+
13
+ require 'spec_helper'
14
+ require 'json'
15
+
16
+ # Unit tests for ApprovalApiClient::TemplateApi
17
+ # Automatically generated by openapi-generator (https://openapi-generator.tech)
18
+ # Please update as you see appropriate
19
+ describe 'TemplateApi' do
20
+ before do
21
+ # run before each test
22
+ @api_instance = ApprovalApiClient::TemplateApi.new
23
+ end
24
+
25
+ after do
26
+ # run after each test
27
+ end
28
+
29
+ describe 'test an instance of TemplateApi' do
30
+ it 'should create an instance of TemplateApi' do
31
+ expect(@api_instance).to be_instance_of(ApprovalApiClient::TemplateApi)
32
+ end
33
+ end
34
+
35
+ # unit tests for list_templates
36
+ # Return all templates, only available for admin
37
+ # Return all templates
38
+ # @param [Hash] opts the optional parameters
39
+ # @option opts [Integer] :limit How many items to return at one time (max 1000)
40
+ # @option opts [Integer] :offset Starting Offset
41
+ # @option opts [Object] :filter Filter for querying collections.
42
+ # @option opts [String] :sort_by Parameter to sort collection
43
+ # @return [TemplateCollection]
44
+ describe 'list_templates test' do
45
+ it 'should work' do
46
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
47
+ end
48
+ end
49
+
50
+ # unit tests for show_template
51
+ # Return a template by given id, only available for admin
52
+ # Return a template by given id
53
+ # @param id Query by id
54
+ # @param [Hash] opts the optional parameters
55
+ # @return [Template]
56
+ describe 'show_template test' do
57
+ it 'should work' do
58
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
59
+ end
60
+ end
61
+
62
+ end
@@ -0,0 +1,145 @@
1
+ =begin
2
+ #Insights Service Approval APIs
3
+
4
+ #APIs to query approval service
5
+
6
+ The version of the OpenAPI document: 1.2.0
7
+ Contact: support@redhat.com
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 4.2.2
10
+
11
+ =end
12
+
13
+ require 'spec_helper'
14
+ require 'json'
15
+
16
+ # Unit tests for ApprovalApiClient::WorkflowApi
17
+ # Automatically generated by openapi-generator (https://openapi-generator.tech)
18
+ # Please update as you see appropriate
19
+ describe 'WorkflowApi' do
20
+ before do
21
+ # run before each test
22
+ @api_instance = ApprovalApiClient::WorkflowApi.new
23
+ end
24
+
25
+ after do
26
+ # run after each test
27
+ end
28
+
29
+ describe 'test an instance of WorkflowApi' do
30
+ it 'should create an instance of WorkflowApi' do
31
+ expect(@api_instance).to be_instance_of(ApprovalApiClient::WorkflowApi)
32
+ end
33
+ end
34
+
35
+ # unit tests for add_workflow_to_template
36
+ # Add a workflow by given template id, only available for admin
37
+ # Add a workflow by given template id
38
+ # @param template_id Id of template
39
+ # @param workflow Parameters need to create workflow
40
+ # @param [Hash] opts the optional parameters
41
+ # @return [Workflow]
42
+ describe 'add_workflow_to_template test' do
43
+ it 'should work' do
44
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
45
+ end
46
+ end
47
+
48
+ # unit tests for destroy_workflow
49
+ # Delete approval workflow by given id, only available for admin
50
+ # Delete approval workflow by given id
51
+ # @param id Query by id
52
+ # @param [Hash] opts the optional parameters
53
+ # @return [nil]
54
+ describe 'destroy_workflow test' do
55
+ it 'should work' do
56
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
57
+ end
58
+ end
59
+
60
+ # unit tests for link_workflow
61
+ # Create a resource link to a given workflow
62
+ # Link a resource object to a given workflow
63
+ # @param id Query by id
64
+ # @param resource_object Parameters needed to create a link
65
+ # @param [Hash] opts the optional parameters
66
+ # @return [nil]
67
+ describe 'link_workflow test' do
68
+ it 'should work' do
69
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
70
+ end
71
+ end
72
+
73
+ # unit tests for list_workflows
74
+ # Return all approval workflows, only available for admin
75
+ # Depends on the query parameters, either return all workflows in ascending sequence order when no parameters are provided; or return the workflows linking to the resource object whose app_name, object_type and object_id are specified by query parameters
76
+ # @param [Hash] opts the optional parameters
77
+ # @option opts [String] :app_name Name of the application
78
+ # @option opts [String] :object_id Id of the resource object
79
+ # @option opts [String] :object_type Type of the resource object
80
+ # @option opts [Integer] :limit How many items to return at one time (max 1000)
81
+ # @option opts [Integer] :offset Starting Offset
82
+ # @option opts [Object] :filter Filter for querying collections.
83
+ # @option opts [String] :sort_by Parameter to sort collection
84
+ # @return [WorkflowCollection]
85
+ describe 'list_workflows test' do
86
+ it 'should work' do
87
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
88
+ end
89
+ end
90
+
91
+ # unit tests for list_workflows_by_template
92
+ # Return an array of workflows by given template id, only available for admin
93
+ # Return an array of workflows by given template id
94
+ # @param template_id Id of template
95
+ # @param [Hash] opts the optional parameters
96
+ # @option opts [Integer] :limit How many items to return at one time (max 1000)
97
+ # @option opts [Integer] :offset Starting Offset
98
+ # @option opts [Object] :filter Filter for querying collections.
99
+ # @option opts [String] :sort_by Parameter to sort collection
100
+ # @return [WorkflowCollection]
101
+ describe 'list_workflows_by_template test' do
102
+ it 'should work' do
103
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
104
+ end
105
+ end
106
+
107
+ # unit tests for show_workflow
108
+ # Return an approval workflow by given id, only available for admin
109
+ # Return an approval workflow by given id
110
+ # @param id Query by id
111
+ # @param [Hash] opts the optional parameters
112
+ # @return [Workflow]
113
+ describe 'show_workflow test' do
114
+ it 'should work' do
115
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
116
+ end
117
+ end
118
+
119
+ # unit tests for unlink_workflow
120
+ # Break the link between a resource object and selected workflow
121
+ # Break the link between a resource object and selected workflow
122
+ # @param id Query by id
123
+ # @param resource_object Parameters needed to remove a link
124
+ # @param [Hash] opts the optional parameters
125
+ # @return [nil]
126
+ describe 'unlink_workflow test' do
127
+ it 'should work' do
128
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
129
+ end
130
+ end
131
+
132
+ # unit tests for update_workflow
133
+ # Update an approval workflow by given id, only available for admin
134
+ # Update an approval workflow by given id
135
+ # @param id Query by id
136
+ # @param workflow Parameters need to update approval workflow
137
+ # @param [Hash] opts the optional parameters
138
+ # @return [Workflow]
139
+ describe 'update_workflow test' do
140
+ it 'should work' do
141
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
142
+ end
143
+ end
144
+
145
+ end
@@ -0,0 +1,226 @@
1
+ =begin
2
+ #Insights Service Approval APIs
3
+
4
+ #APIs to query approval service
5
+
6
+ The version of the OpenAPI document: 1.2.0
7
+ Contact: support@redhat.com
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 4.2.2
10
+
11
+ =end
12
+
13
+ require 'spec_helper'
14
+
15
+ describe ApprovalApiClient::ApiClient do
16
+ context 'initialization' do
17
+ context 'URL stuff' do
18
+ context 'host' do
19
+ it 'removes http from host' do
20
+ ApprovalApiClient.configure { |c| c.host = 'http://example.com' }
21
+ expect(ApprovalApiClient::Configuration.default.host).to eq('example.com')
22
+ end
23
+
24
+ it 'removes https from host' do
25
+ ApprovalApiClient.configure { |c| c.host = 'https://wookiee.com' }
26
+ expect(ApprovalApiClient::ApiClient.default.config.host).to eq('wookiee.com')
27
+ end
28
+
29
+ it 'removes trailing path from host' do
30
+ ApprovalApiClient.configure { |c| c.host = 'hobo.com/v4' }
31
+ expect(ApprovalApiClient::Configuration.default.host).to eq('hobo.com')
32
+ end
33
+ end
34
+
35
+ context 'base_path' do
36
+ it "prepends a slash to base_path" do
37
+ ApprovalApiClient.configure { |c| c.base_path = 'v4/dog' }
38
+ expect(ApprovalApiClient::Configuration.default.base_path).to eq('/v4/dog')
39
+ end
40
+
41
+ it "doesn't prepend a slash if one is already there" do
42
+ ApprovalApiClient.configure { |c| c.base_path = '/v4/dog' }
43
+ expect(ApprovalApiClient::Configuration.default.base_path).to eq('/v4/dog')
44
+ end
45
+
46
+ it "ends up as a blank string if nil" do
47
+ ApprovalApiClient.configure { |c| c.base_path = nil }
48
+ expect(ApprovalApiClient::Configuration.default.base_path).to eq('')
49
+ end
50
+ end
51
+ end
52
+ end
53
+
54
+ describe 'params_encoding in #build_request' do
55
+ let(:config) { ApprovalApiClient::Configuration.new }
56
+ let(:api_client) { ApprovalApiClient::ApiClient.new(config) }
57
+
58
+ it 'defaults to nil' do
59
+ expect(ApprovalApiClient::Configuration.default.params_encoding).to eq(nil)
60
+ expect(config.params_encoding).to eq(nil)
61
+
62
+ request = api_client.build_request(:get, '/test')
63
+ expect(request.options[:params_encoding]).to eq(nil)
64
+ end
65
+
66
+ it 'can be customized' do
67
+ config.params_encoding = :multi
68
+ request = api_client.build_request(:get, '/test')
69
+ expect(request.options[:params_encoding]).to eq(:multi)
70
+ end
71
+ end
72
+
73
+ describe 'timeout in #build_request' do
74
+ let(:config) { ApprovalApiClient::Configuration.new }
75
+ let(:api_client) { ApprovalApiClient::ApiClient.new(config) }
76
+
77
+ it 'defaults to 0' do
78
+ expect(ApprovalApiClient::Configuration.default.timeout).to eq(0)
79
+ expect(config.timeout).to eq(0)
80
+
81
+ request = api_client.build_request(:get, '/test')
82
+ expect(request.options[:timeout]).to eq(0)
83
+ end
84
+
85
+ it 'can be customized' do
86
+ config.timeout = 100
87
+ request = api_client.build_request(:get, '/test')
88
+ expect(request.options[:timeout]).to eq(100)
89
+ end
90
+ end
91
+
92
+ describe '#deserialize' do
93
+ it "handles Array<Integer>" do
94
+ api_client = ApprovalApiClient::ApiClient.new
95
+ headers = { 'Content-Type' => 'application/json' }
96
+ response = double('response', headers: headers, body: '[12, 34]')
97
+ data = api_client.deserialize(response, 'Array<Integer>')
98
+ expect(data).to be_instance_of(Array)
99
+ expect(data).to eq([12, 34])
100
+ end
101
+
102
+ it 'handles Array<Array<Integer>>' do
103
+ api_client = ApprovalApiClient::ApiClient.new
104
+ headers = { 'Content-Type' => 'application/json' }
105
+ response = double('response', headers: headers, body: '[[12, 34], [56]]')
106
+ data = api_client.deserialize(response, 'Array<Array<Integer>>')
107
+ expect(data).to be_instance_of(Array)
108
+ expect(data).to eq([[12, 34], [56]])
109
+ end
110
+
111
+ it 'handles Hash<String, String>' do
112
+ api_client = ApprovalApiClient::ApiClient.new
113
+ headers = { 'Content-Type' => 'application/json' }
114
+ response = double('response', headers: headers, body: '{"message": "Hello"}')
115
+ data = api_client.deserialize(response, 'Hash<String, String>')
116
+ expect(data).to be_instance_of(Hash)
117
+ expect(data).to eq(:message => 'Hello')
118
+ end
119
+ end
120
+
121
+ describe "#object_to_hash" do
122
+ it 'ignores nils and includes empty arrays' do
123
+ # uncomment below to test object_to_hash for model
124
+ # api_client = ApprovalApiClient::ApiClient.new
125
+ # _model = ApprovalApiClient::ModelName.new
126
+ # update the model attribute below
127
+ # _model.id = 1
128
+ # update the expected value (hash) below
129
+ # expected = {id: 1, name: '', tags: []}
130
+ # expect(api_client.object_to_hash(_model)).to eq(expected)
131
+ end
132
+ end
133
+
134
+ describe '#build_collection_param' do
135
+ let(:param) { ['aa', 'bb', 'cc'] }
136
+ let(:api_client) { ApprovalApiClient::ApiClient.new }
137
+
138
+ it 'works for csv' do
139
+ expect(api_client.build_collection_param(param, :csv)).to eq('aa,bb,cc')
140
+ end
141
+
142
+ it 'works for ssv' do
143
+ expect(api_client.build_collection_param(param, :ssv)).to eq('aa bb cc')
144
+ end
145
+
146
+ it 'works for tsv' do
147
+ expect(api_client.build_collection_param(param, :tsv)).to eq("aa\tbb\tcc")
148
+ end
149
+
150
+ it 'works for pipes' do
151
+ expect(api_client.build_collection_param(param, :pipes)).to eq('aa|bb|cc')
152
+ end
153
+
154
+ it 'works for multi' do
155
+ expect(api_client.build_collection_param(param, :multi)).to eq(['aa', 'bb', 'cc'])
156
+ end
157
+
158
+ it 'fails for invalid collection format' do
159
+ expect{api_client.build_collection_param(param, :INVALID)}.to raise_error(RuntimeError, 'unknown collection format: :INVALID')
160
+ end
161
+ end
162
+
163
+ describe '#json_mime?' do
164
+ let(:api_client) { ApprovalApiClient::ApiClient.new }
165
+
166
+ it 'works' do
167
+ expect(api_client.json_mime?(nil)).to eq false
168
+ expect(api_client.json_mime?('')).to eq false
169
+
170
+ expect(api_client.json_mime?('application/json')).to eq true
171
+ expect(api_client.json_mime?('application/json; charset=UTF8')).to eq true
172
+ expect(api_client.json_mime?('APPLICATION/JSON')).to eq true
173
+
174
+ expect(api_client.json_mime?('application/xml')).to eq false
175
+ expect(api_client.json_mime?('text/plain')).to eq false
176
+ expect(api_client.json_mime?('application/jsonp')).to eq false
177
+ end
178
+ end
179
+
180
+ describe '#select_header_accept' do
181
+ let(:api_client) { ApprovalApiClient::ApiClient.new }
182
+
183
+ it 'works' do
184
+ expect(api_client.select_header_accept(nil)).to be_nil
185
+ expect(api_client.select_header_accept([])).to be_nil
186
+
187
+ expect(api_client.select_header_accept(['application/json'])).to eq('application/json')
188
+ expect(api_client.select_header_accept(['application/xml', 'application/json; charset=UTF8'])).to eq('application/json; charset=UTF8')
189
+ expect(api_client.select_header_accept(['APPLICATION/JSON', 'text/html'])).to eq('APPLICATION/JSON')
190
+
191
+ expect(api_client.select_header_accept(['application/xml'])).to eq('application/xml')
192
+ expect(api_client.select_header_accept(['text/html', 'application/xml'])).to eq('text/html,application/xml')
193
+ end
194
+ end
195
+
196
+ describe '#select_header_content_type' do
197
+ let(:api_client) { ApprovalApiClient::ApiClient.new }
198
+
199
+ it 'works' do
200
+ expect(api_client.select_header_content_type(nil)).to eq('application/json')
201
+ expect(api_client.select_header_content_type([])).to eq('application/json')
202
+
203
+ expect(api_client.select_header_content_type(['application/json'])).to eq('application/json')
204
+ expect(api_client.select_header_content_type(['application/xml', 'application/json; charset=UTF8'])).to eq('application/json; charset=UTF8')
205
+ expect(api_client.select_header_content_type(['APPLICATION/JSON', 'text/html'])).to eq('APPLICATION/JSON')
206
+ expect(api_client.select_header_content_type(['application/xml'])).to eq('application/xml')
207
+ expect(api_client.select_header_content_type(['text/plain', 'application/xml'])).to eq('text/plain')
208
+ end
209
+ end
210
+
211
+ describe '#sanitize_filename' do
212
+ let(:api_client) { ApprovalApiClient::ApiClient.new }
213
+
214
+ it 'works' do
215
+ expect(api_client.sanitize_filename('sun')).to eq('sun')
216
+ expect(api_client.sanitize_filename('sun.gif')).to eq('sun.gif')
217
+ expect(api_client.sanitize_filename('../sun.gif')).to eq('sun.gif')
218
+ expect(api_client.sanitize_filename('/var/tmp/sun.gif')).to eq('sun.gif')
219
+ expect(api_client.sanitize_filename('./sun.gif')).to eq('sun.gif')
220
+ expect(api_client.sanitize_filename('..\sun.gif')).to eq('sun.gif')
221
+ expect(api_client.sanitize_filename('\var\tmp\sun.gif')).to eq('sun.gif')
222
+ expect(api_client.sanitize_filename('c:\var\tmp\sun.gif')).to eq('sun.gif')
223
+ expect(api_client.sanitize_filename('.\sun.gif')).to eq('sun.gif')
224
+ end
225
+ end
226
+ end