|
| 1 | +=begin |
| 2 | +#Patch API V2 |
| 3 | +
|
| 4 | +#The core API used to integrate with Patch's service |
| 5 | +
|
| 6 | +The version of the OpenAPI document: 2 |
| 7 | + |
| 8 | +Generated by: https://openapi-generator.tech |
| 9 | +OpenAPI Generator version: 5.3.1 |
| 10 | +
|
| 11 | +=end |
| 12 | + |
| 13 | +require 'cgi' |
| 14 | + |
| 15 | +module Patch |
| 16 | + class OrderLineItemsApi |
| 17 | + OPERATIONS = [ |
| 18 | + :create_order_line_item, |
| 19 | + :delete_order_line_item, |
| 20 | + :update_order_line_item, |
| 21 | + ] |
| 22 | + |
| 23 | + attr_accessor :api_client |
| 24 | + |
| 25 | + def initialize(api_client = ApiClient.default) |
| 26 | + @api_client = api_client |
| 27 | + end |
| 28 | + # Creates an order line item |
| 29 | + # Creates a line item on an order that is in the `draft` state. |
| 30 | + # @param order_id [String] |
| 31 | + # @param create_order_line_item_request [CreateOrderLineItemRequest] |
| 32 | + # @param [Hash] opts the optional parameters |
| 33 | + # @option opts [Integer] :patch_version |
| 34 | + # @return [OrderLineItemResponse] |
| 35 | + def create_order_line_item(order_id, create_order_line_item_request = {}, opts = {}) |
| 36 | + _create_order_line_item_request = Patch::CreateOrderLineItemRequest.new(create_order_line_item_request) |
| 37 | + data, _status_code, _headers = create_order_line_item_with_http_info(order_id, _create_order_line_item_request, opts) |
| 38 | + data |
| 39 | + end |
| 40 | + |
| 41 | + # Creates an order line item |
| 42 | + # Creates a line item on an order that is in the `draft` state. |
| 43 | + # @param order_id [String] |
| 44 | + # @param create_order_line_item_request [CreateOrderLineItemRequest] |
| 45 | + # @param [Hash] opts the optional parameters |
| 46 | + # @option opts [Integer] :patch_version |
| 47 | + # @return [Array<(OrderLineItemResponse, Integer, Hash)>] OrderLineItemResponse data, response status code and response headers |
| 48 | + def create_order_line_item_with_http_info(order_id, create_order_line_item_request, opts = {}) |
| 49 | + if @api_client.config.debugging |
| 50 | + @api_client.config.logger.debug 'Calling API: OrderLineItemsApi.create_order_line_item ...' |
| 51 | + end |
| 52 | + # verify the required parameter 'order_id' is set |
| 53 | + if @api_client.config.client_side_validation && order_id.nil? |
| 54 | + fail ArgumentError, "Missing the required parameter 'order_id' when calling OrderLineItemsApi.create_order_line_item" |
| 55 | + end |
| 56 | + # verify the required parameter 'create_order_line_item_request' is set |
| 57 | + if @api_client.config.client_side_validation && create_order_line_item_request.nil? |
| 58 | + fail ArgumentError, "Missing the required parameter 'create_order_line_item_request' when calling OrderLineItemsApi.create_order_line_item" |
| 59 | + end |
| 60 | + # resource path |
| 61 | + local_var_path = '/v1/orders/{order_id}/line_items'.sub('{' + 'order_id' + '}', CGI.escape(order_id.to_s)) |
| 62 | + |
| 63 | + # query parameters |
| 64 | + query_params = opts[:query_params] || {} |
| 65 | + |
| 66 | + # header parameters |
| 67 | + header_params = opts[:header_params] || {} |
| 68 | + |
| 69 | + # HTTP header 'Accept' (if needed) |
| 70 | + header_params['Accept'] = @api_client.select_header_accept(['application/json']) |
| 71 | + # HTTP header 'Content-Type' |
| 72 | + content_type = @api_client.select_header_content_type(['application/json']) |
| 73 | + if !content_type.nil? |
| 74 | + header_params['Content-Type'] = content_type |
| 75 | + end |
| 76 | + header_params['Patch-Version'] = 2 |
| 77 | + header_params[:'Patch-Version'] = opts[:'patch_version'] if !opts[:'patch_version'].nil? |
| 78 | + |
| 79 | + # form parameters |
| 80 | + form_params = opts[:form_params] || {} |
| 81 | + |
| 82 | + # http body (model) |
| 83 | + post_body = opts[:debug_body] || @api_client.object_to_http_body(create_order_line_item_request) |
| 84 | + |
| 85 | + # return_type |
| 86 | + return_type = opts[:debug_return_type] || 'OrderLineItemResponse' |
| 87 | + |
| 88 | + # auth_names |
| 89 | + auth_names = opts[:debug_auth_names] || ['bearer_auth'] |
| 90 | + |
| 91 | + new_options = opts.merge( |
| 92 | + :operation => :"OrderLineItemsApi.create_order_line_item", |
| 93 | + :header_params => header_params, |
| 94 | + :query_params => query_params, |
| 95 | + :form_params => form_params, |
| 96 | + :body => post_body, |
| 97 | + :auth_names => auth_names, |
| 98 | + :return_type => return_type |
| 99 | + ) |
| 100 | + |
| 101 | + data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options) |
| 102 | + if @api_client.config.debugging |
| 103 | + @api_client.config.logger.debug "API called: OrderLineItemsApi#create_order_line_item\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" |
| 104 | + end |
| 105 | + return data, status_code, headers |
| 106 | + end |
| 107 | + |
| 108 | + # Deletes an order line item |
| 109 | + # Deletes a line item on an order that is in the `draft` state. |
| 110 | + # @param order_id [String] |
| 111 | + # @param serial_number [String] |
| 112 | + # @param [Hash] opts the optional parameters |
| 113 | + # @option opts [Integer] :patch_version |
| 114 | + # @return [DeleteOrderLineItemResponse] |
| 115 | + def delete_order_line_item(order_id, serial_number, opts = {}) |
| 116 | + |
| 117 | + data, _status_code, _headers = delete_order_line_item_with_http_info(order_id, serial_number, opts) |
| 118 | + data |
| 119 | + end |
| 120 | + |
| 121 | + # Deletes an order line item |
| 122 | + # Deletes a line item on an order that is in the `draft` state. |
| 123 | + # @param order_id [String] |
| 124 | + # @param serial_number [String] |
| 125 | + # @param [Hash] opts the optional parameters |
| 126 | + # @option opts [Integer] :patch_version |
| 127 | + # @return [Array<(DeleteOrderLineItemResponse, Integer, Hash)>] DeleteOrderLineItemResponse data, response status code and response headers |
| 128 | + def delete_order_line_item_with_http_info(order_id, serial_number, opts = {}) |
| 129 | + if @api_client.config.debugging |
| 130 | + @api_client.config.logger.debug 'Calling API: OrderLineItemsApi.delete_order_line_item ...' |
| 131 | + end |
| 132 | + # verify the required parameter 'order_id' is set |
| 133 | + if @api_client.config.client_side_validation && order_id.nil? |
| 134 | + fail ArgumentError, "Missing the required parameter 'order_id' when calling OrderLineItemsApi.delete_order_line_item" |
| 135 | + end |
| 136 | + # verify the required parameter 'serial_number' is set |
| 137 | + if @api_client.config.client_side_validation && serial_number.nil? |
| 138 | + fail ArgumentError, "Missing the required parameter 'serial_number' when calling OrderLineItemsApi.delete_order_line_item" |
| 139 | + end |
| 140 | + # resource path |
| 141 | + local_var_path = '/v1/orders/{order_id}/line_items/{serial_number}'.sub('{' + 'order_id' + '}', CGI.escape(order_id.to_s)).sub('{' + 'serial_number' + '}', CGI.escape(serial_number.to_s)) |
| 142 | + |
| 143 | + # query parameters |
| 144 | + query_params = opts[:query_params] || {} |
| 145 | + |
| 146 | + # header parameters |
| 147 | + header_params = opts[:header_params] || {} |
| 148 | + |
| 149 | + # HTTP header 'Accept' (if needed) |
| 150 | + header_params['Accept'] = @api_client.select_header_accept(['application/json']) |
| 151 | + header_params['Patch-Version'] = 2 |
| 152 | + header_params[:'Patch-Version'] = opts[:'patch_version'] if !opts[:'patch_version'].nil? |
| 153 | + |
| 154 | + # form parameters |
| 155 | + form_params = opts[:form_params] || {} |
| 156 | + |
| 157 | + # http body (model) |
| 158 | + post_body = opts[:debug_body] |
| 159 | + |
| 160 | + # return_type |
| 161 | + return_type = opts[:debug_return_type] || 'DeleteOrderLineItemResponse' |
| 162 | + |
| 163 | + # auth_names |
| 164 | + auth_names = opts[:debug_auth_names] || ['bearer_auth'] |
| 165 | + |
| 166 | + new_options = opts.merge( |
| 167 | + :operation => :"OrderLineItemsApi.delete_order_line_item", |
| 168 | + :header_params => header_params, |
| 169 | + :query_params => query_params, |
| 170 | + :form_params => form_params, |
| 171 | + :body => post_body, |
| 172 | + :auth_names => auth_names, |
| 173 | + :return_type => return_type |
| 174 | + ) |
| 175 | + |
| 176 | + data, status_code, headers = @api_client.call_api(:DELETE, local_var_path, new_options) |
| 177 | + if @api_client.config.debugging |
| 178 | + @api_client.config.logger.debug "API called: OrderLineItemsApi#delete_order_line_item\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" |
| 179 | + end |
| 180 | + return data, status_code, headers |
| 181 | + end |
| 182 | + |
| 183 | + # Updates an order line item |
| 184 | + # Updates a line item on an order that is in the `draft` state. |
| 185 | + # @param order_id [String] |
| 186 | + # @param serial_number [String] |
| 187 | + # @param update_order_line_item_request [UpdateOrderLineItemRequest] |
| 188 | + # @param [Hash] opts the optional parameters |
| 189 | + # @option opts [Integer] :patch_version |
| 190 | + # @return [OrderLineItemResponse] |
| 191 | + def update_order_line_item(order_id, serial_number, update_order_line_item_request = {}, opts = {}) |
| 192 | + _update_order_line_item_request = Patch::UpdateOrderLineItemRequest.new(update_order_line_item_request) |
| 193 | + data, _status_code, _headers = update_order_line_item_with_http_info(order_id, serial_number, _update_order_line_item_request, opts) |
| 194 | + data |
| 195 | + end |
| 196 | + |
| 197 | + # Updates an order line item |
| 198 | + # Updates a line item on an order that is in the `draft` state. |
| 199 | + # @param order_id [String] |
| 200 | + # @param serial_number [String] |
| 201 | + # @param update_order_line_item_request [UpdateOrderLineItemRequest] |
| 202 | + # @param [Hash] opts the optional parameters |
| 203 | + # @option opts [Integer] :patch_version |
| 204 | + # @return [Array<(OrderLineItemResponse, Integer, Hash)>] OrderLineItemResponse data, response status code and response headers |
| 205 | + def update_order_line_item_with_http_info(order_id, serial_number, update_order_line_item_request, opts = {}) |
| 206 | + if @api_client.config.debugging |
| 207 | + @api_client.config.logger.debug 'Calling API: OrderLineItemsApi.update_order_line_item ...' |
| 208 | + end |
| 209 | + # verify the required parameter 'order_id' is set |
| 210 | + if @api_client.config.client_side_validation && order_id.nil? |
| 211 | + fail ArgumentError, "Missing the required parameter 'order_id' when calling OrderLineItemsApi.update_order_line_item" |
| 212 | + end |
| 213 | + # verify the required parameter 'serial_number' is set |
| 214 | + if @api_client.config.client_side_validation && serial_number.nil? |
| 215 | + fail ArgumentError, "Missing the required parameter 'serial_number' when calling OrderLineItemsApi.update_order_line_item" |
| 216 | + end |
| 217 | + # verify the required parameter 'update_order_line_item_request' is set |
| 218 | + if @api_client.config.client_side_validation && update_order_line_item_request.nil? |
| 219 | + fail ArgumentError, "Missing the required parameter 'update_order_line_item_request' when calling OrderLineItemsApi.update_order_line_item" |
| 220 | + end |
| 221 | + # resource path |
| 222 | + local_var_path = '/v1/orders/{order_id}/line_items/{serial_number}'.sub('{' + 'order_id' + '}', CGI.escape(order_id.to_s)).sub('{' + 'serial_number' + '}', CGI.escape(serial_number.to_s)) |
| 223 | + |
| 224 | + # query parameters |
| 225 | + query_params = opts[:query_params] || {} |
| 226 | + |
| 227 | + # header parameters |
| 228 | + header_params = opts[:header_params] || {} |
| 229 | + |
| 230 | + # HTTP header 'Accept' (if needed) |
| 231 | + header_params['Accept'] = @api_client.select_header_accept(['application/json']) |
| 232 | + # HTTP header 'Content-Type' |
| 233 | + content_type = @api_client.select_header_content_type(['application/json']) |
| 234 | + if !content_type.nil? |
| 235 | + header_params['Content-Type'] = content_type |
| 236 | + end |
| 237 | + header_params['Patch-Version'] = 2 |
| 238 | + header_params[:'Patch-Version'] = opts[:'patch_version'] if !opts[:'patch_version'].nil? |
| 239 | + |
| 240 | + # form parameters |
| 241 | + form_params = opts[:form_params] || {} |
| 242 | + |
| 243 | + # http body (model) |
| 244 | + post_body = opts[:debug_body] || @api_client.object_to_http_body(update_order_line_item_request) |
| 245 | + |
| 246 | + # return_type |
| 247 | + return_type = opts[:debug_return_type] || 'OrderLineItemResponse' |
| 248 | + |
| 249 | + # auth_names |
| 250 | + auth_names = opts[:debug_auth_names] || ['bearer_auth'] |
| 251 | + |
| 252 | + new_options = opts.merge( |
| 253 | + :operation => :"OrderLineItemsApi.update_order_line_item", |
| 254 | + :header_params => header_params, |
| 255 | + :query_params => query_params, |
| 256 | + :form_params => form_params, |
| 257 | + :body => post_body, |
| 258 | + :auth_names => auth_names, |
| 259 | + :return_type => return_type |
| 260 | + ) |
| 261 | + |
| 262 | + data, status_code, headers = @api_client.call_api(:PATCH, local_var_path, new_options) |
| 263 | + if @api_client.config.debugging |
| 264 | + @api_client.config.logger.debug "API called: OrderLineItemsApi#update_order_line_item\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" |
| 265 | + end |
| 266 | + return data, status_code, headers |
| 267 | + end |
| 268 | + end |
| 269 | +end |
0 commit comments