=begin #Tripletex API OpenAPI spec version: 2.69.5 Generated by: https://github.com/swagger-api/swagger-codegen.git Swagger Codegen version: 2.4.24 =end require 'uri' module TripletexRubyClient class PurchaseOrderApi attr_accessor :api_client def initialize(api_client = ApiClient.default) @api_client = api_client end # [BETA] Delete purchase order. # # @param id Element ID # @param [Hash] opts the optional parameters # @return [nil] def delete(id, opts = {}) delete_with_http_info(id, opts) nil end # [BETA] Delete purchase order. # # @param id Element ID # @param [Hash] opts the optional parameters # @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers def delete_with_http_info(id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: PurchaseOrderApi.delete ...' end # verify the required parameter 'id' is set if @api_client.config.client_side_validation && id.nil? fail ArgumentError, "Missing the required parameter 'id' when calling PurchaseOrderApi.delete" end # resource path local_var_path = '/purchaseOrder/{id}'.sub('{' + 'id' + '}', id.to_s) # query parameters query_params = {} # header parameters header_params = {} # form parameters form_params = {} # http body (model) post_body = nil auth_names = ['tokenAuthScheme'] data, status_code, headers = @api_client.call_api(:DELETE, local_var_path, :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names) if @api_client.config.debugging @api_client.config.logger.debug "API called: PurchaseOrderApi#delete\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # [BETA] Delete attachment. # # @param id ID of purchase order containing the attachment to delete. # @param [Hash] opts the optional parameters # @return [nil] def delete_attachment(id, opts = {}) delete_attachment_with_http_info(id, opts) nil end # [BETA] Delete attachment. # # @param id ID of purchase order containing the attachment to delete. # @param [Hash] opts the optional parameters # @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers def delete_attachment_with_http_info(id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: PurchaseOrderApi.delete_attachment ...' end # verify the required parameter 'id' is set if @api_client.config.client_side_validation && id.nil? fail ArgumentError, "Missing the required parameter 'id' when calling PurchaseOrderApi.delete_attachment" end # resource path local_var_path = '/purchaseOrder/{id}/attachment'.sub('{' + 'id' + '}', id.to_s) # query parameters query_params = {} # header parameters header_params = {} # form parameters form_params = {} # http body (model) post_body = nil auth_names = ['tokenAuthScheme'] data, status_code, headers = @api_client.call_api(:DELETE, local_var_path, :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names) if @api_client.config.debugging @api_client.config.logger.debug "API called: PurchaseOrderApi#delete_attachment\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # [BETA] Find purchase order by ID. # # @param id Element ID # @param [Hash] opts the optional parameters # @option opts [String] :fields Fields filter pattern # @return [ResponseWrapperPurchaseOrder] def get(id, opts = {}) data, _status_code, _headers = get_with_http_info(id, opts) data end # [BETA] Find purchase order by ID. # # @param id Element ID # @param [Hash] opts the optional parameters # @option opts [String] :fields Fields filter pattern # @return [Array<(ResponseWrapperPurchaseOrder, Fixnum, Hash)>] ResponseWrapperPurchaseOrder data, response status code and response headers def get_with_http_info(id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: PurchaseOrderApi.get ...' end # verify the required parameter 'id' is set if @api_client.config.client_side_validation && id.nil? fail ArgumentError, "Missing the required parameter 'id' when calling PurchaseOrderApi.get" end # resource path local_var_path = '/purchaseOrder/{id}'.sub('{' + 'id' + '}', id.to_s) # query parameters query_params = {} query_params[:'fields'] = opts[:'fields'] if !opts[:'fields'].nil? # header parameters header_params = {} # form parameters form_params = {} # http body (model) post_body = nil auth_names = ['tokenAuthScheme'] data, status_code, headers = @api_client.call_api(:GET, local_var_path, :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => 'ResponseWrapperPurchaseOrder') if @api_client.config.debugging @api_client.config.logger.debug "API called: PurchaseOrderApi#get\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # [BETA] Creates a new purchase order # # @param [Hash] opts the optional parameters # @option opts [PurchaseOrder] :body JSON representing the new object to be created. Should not have ID and version set. # @return [ResponseWrapperPurchaseOrder] def post(opts = {}) data, _status_code, _headers = post_with_http_info(opts) data end # [BETA] Creates a new purchase order # # @param [Hash] opts the optional parameters # @option opts [PurchaseOrder] :body JSON representing the new object to be created. Should not have ID and version set. # @return [Array<(ResponseWrapperPurchaseOrder, Fixnum, Hash)>] ResponseWrapperPurchaseOrder data, response status code and response headers def post_with_http_info(opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: PurchaseOrderApi.post ...' end # resource path local_var_path = '/purchaseOrder' # query parameters query_params = {} # header parameters header_params = {} # HTTP header 'Content-Type' header_params['Content-Type'] = @api_client.select_header_content_type(['application/json; charset=utf-8']) # form parameters form_params = {} # http body (model) post_body = @api_client.object_to_http_body(opts[:'body']) auth_names = ['tokenAuthScheme'] data, status_code, headers = @api_client.call_api(:POST, local_var_path, :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => 'ResponseWrapperPurchaseOrder') if @api_client.config.debugging @api_client.config.logger.debug "API called: PurchaseOrderApi#post\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # [BETA] Update purchase order. # # @param id Element ID # @param [Hash] opts the optional parameters # @option opts [PurchaseOrder] :body Partial object describing what should be updated # @return [ResponseWrapperPurchaseOrder] def put(id, opts = {}) data, _status_code, _headers = put_with_http_info(id, opts) data end # [BETA] Update purchase order. # # @param id Element ID # @param [Hash] opts the optional parameters # @option opts [PurchaseOrder] :body Partial object describing what should be updated # @return [Array<(ResponseWrapperPurchaseOrder, Fixnum, Hash)>] ResponseWrapperPurchaseOrder data, response status code and response headers def put_with_http_info(id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: PurchaseOrderApi.put ...' end # verify the required parameter 'id' is set if @api_client.config.client_side_validation && id.nil? fail ArgumentError, "Missing the required parameter 'id' when calling PurchaseOrderApi.put" end # resource path local_var_path = '/purchaseOrder/{id}'.sub('{' + 'id' + '}', id.to_s) # query parameters query_params = {} # header parameters header_params = {} # HTTP header 'Content-Type' header_params['Content-Type'] = @api_client.select_header_content_type(['application/json; charset=utf-8']) # form parameters form_params = {} # http body (model) post_body = @api_client.object_to_http_body(opts[:'body']) auth_names = ['tokenAuthScheme'] data, status_code, headers = @api_client.call_api(:PUT, local_var_path, :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => 'ResponseWrapperPurchaseOrder') if @api_client.config.debugging @api_client.config.logger.debug "API called: PurchaseOrderApi#put\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # [BETA] Find purchase orders with send data # # @param [Hash] opts the optional parameters # @option opts [String] :number Equals # @option opts [String] :delivery_date_from Format is yyyy-MM-dd (from and incl.). # @option opts [String] :delivery_date_to Format is yyyy-MM-dd (to and incl.). # @option opts [String] :creation_date_from Format is yyyy-MM-dd (from and incl.). # @option opts [String] :creation_date_to Format is yyyy-MM-dd (to and incl.). # @option opts [String] :id List of IDs # @option opts [String] :supplier_id List of IDs # @option opts [String] :project_id List of IDs # @option opts [BOOLEAN] :is_closed Equals # @option opts [BOOLEAN] :with_deviation_only Equals (default to false) # @option opts [Integer] :from From index (default to 0) # @option opts [Integer] :count Number of elements to return (default to 1000) # @option opts [String] :sorting Sorting pattern # @option opts [String] :fields Fields filter pattern # @return [ListResponsePurchaseOrder] def search(opts = {}) data, _status_code, _headers = search_with_http_info(opts) data end # [BETA] Find purchase orders with send data # # @param [Hash] opts the optional parameters # @option opts [String] :number Equals # @option opts [String] :delivery_date_from Format is yyyy-MM-dd (from and incl.). # @option opts [String] :delivery_date_to Format is yyyy-MM-dd (to and incl.). # @option opts [String] :creation_date_from Format is yyyy-MM-dd (from and incl.). # @option opts [String] :creation_date_to Format is yyyy-MM-dd (to and incl.). # @option opts [String] :id List of IDs # @option opts [String] :supplier_id List of IDs # @option opts [String] :project_id List of IDs # @option opts [BOOLEAN] :is_closed Equals # @option opts [BOOLEAN] :with_deviation_only Equals # @option opts [Integer] :from From index # @option opts [Integer] :count Number of elements to return # @option opts [String] :sorting Sorting pattern # @option opts [String] :fields Fields filter pattern # @return [Array<(ListResponsePurchaseOrder, Fixnum, Hash)>] ListResponsePurchaseOrder data, response status code and response headers def search_with_http_info(opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: PurchaseOrderApi.search ...' end # resource path local_var_path = '/purchaseOrder' # query parameters query_params = {} query_params[:'number'] = opts[:'number'] if !opts[:'number'].nil? query_params[:'deliveryDateFrom'] = opts[:'delivery_date_from'] if !opts[:'delivery_date_from'].nil? query_params[:'deliveryDateTo'] = opts[:'delivery_date_to'] if !opts[:'delivery_date_to'].nil? query_params[:'creationDateFrom'] = opts[:'creation_date_from'] if !opts[:'creation_date_from'].nil? query_params[:'creationDateTo'] = opts[:'creation_date_to'] if !opts[:'creation_date_to'].nil? query_params[:'id'] = opts[:'id'] if !opts[:'id'].nil? query_params[:'supplierId'] = opts[:'supplier_id'] if !opts[:'supplier_id'].nil? query_params[:'projectId'] = opts[:'project_id'] if !opts[:'project_id'].nil? query_params[:'isClosed'] = opts[:'is_closed'] if !opts[:'is_closed'].nil? query_params[:'withDeviationOnly'] = opts[:'with_deviation_only'] if !opts[:'with_deviation_only'].nil? query_params[:'from'] = opts[:'from'] if !opts[:'from'].nil? query_params[:'count'] = opts[:'count'] if !opts[:'count'].nil? query_params[:'sorting'] = opts[:'sorting'] if !opts[:'sorting'].nil? query_params[:'fields'] = opts[:'fields'] if !opts[:'fields'].nil? # header parameters header_params = {} # form parameters form_params = {} # http body (model) post_body = nil auth_names = ['tokenAuthScheme'] data, status_code, headers = @api_client.call_api(:GET, local_var_path, :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => 'ListResponsePurchaseOrder') if @api_client.config.debugging @api_client.config.logger.debug "API called: PurchaseOrderApi#search\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # [BETA] Send purchase order by id and sendType. # # @param id Element ID # @param [Hash] opts the optional parameters # @option opts [String] :send_type Send type.DEFAULT will determine the send parameter based on the supplier type.If supplier is not wholesaler, receiverEmail from the PO will be used if it's specified.If receiverEmail empty it will take the vendor email. (default to DEFAULT) # @return [ResponseWrapperPurchaseOrder] def send(id, opts = {}) data, _status_code, _headers = send_with_http_info(id, opts) data end # [BETA] Send purchase order by id and sendType. # # @param id Element ID # @param [Hash] opts the optional parameters # @option opts [String] :send_type Send type.DEFAULT will determine the send parameter based on the supplier type.If supplier is not wholesaler, receiverEmail from the PO will be used if it's specified.If receiverEmail empty it will take the vendor email. # @return [Array<(ResponseWrapperPurchaseOrder, Fixnum, Hash)>] ResponseWrapperPurchaseOrder data, response status code and response headers def send_with_http_info(id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: PurchaseOrderApi.send ...' end # verify the required parameter 'id' is set if @api_client.config.client_side_validation && id.nil? fail ArgumentError, "Missing the required parameter 'id' when calling PurchaseOrderApi.send" end if @api_client.config.client_side_validation && opts[:'send_type'] && !['DEFAULT', 'EMAIL', 'FTP'].include?(opts[:'send_type']) fail ArgumentError, 'invalid value for "send_type", must be one of DEFAULT, EMAIL, FTP' end # resource path local_var_path = '/purchaseOrder/{id}/:send'.sub('{' + 'id' + '}', id.to_s) # query parameters query_params = {} query_params[:'sendType'] = opts[:'send_type'] if !opts[:'send_type'].nil? # header parameters header_params = {} # form parameters form_params = {} # http body (model) post_body = nil auth_names = ['tokenAuthScheme'] data, status_code, headers = @api_client.call_api(:PUT, local_var_path, :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => 'ResponseWrapperPurchaseOrder') if @api_client.config.debugging @api_client.config.logger.debug "API called: PurchaseOrderApi#send\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # [BETA] Send purchase order by customisable email. # # @param id Element ID # @param email_address Email address # @param subject Subject # @param [Hash] opts the optional parameters # @option opts [String] :message Message # @return [ResponseWrapperPurchaseOrder] def send_by_email(id, email_address, subject, opts = {}) data, _status_code, _headers = send_by_email_with_http_info(id, email_address, subject, opts) data end # [BETA] Send purchase order by customisable email. # # @param id Element ID # @param email_address Email address # @param subject Subject # @param [Hash] opts the optional parameters # @option opts [String] :message Message # @return [Array<(ResponseWrapperPurchaseOrder, Fixnum, Hash)>] ResponseWrapperPurchaseOrder data, response status code and response headers def send_by_email_with_http_info(id, email_address, subject, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: PurchaseOrderApi.send_by_email ...' end # verify the required parameter 'id' is set if @api_client.config.client_side_validation && id.nil? fail ArgumentError, "Missing the required parameter 'id' when calling PurchaseOrderApi.send_by_email" end # verify the required parameter 'email_address' is set if @api_client.config.client_side_validation && email_address.nil? fail ArgumentError, "Missing the required parameter 'email_address' when calling PurchaseOrderApi.send_by_email" end # verify the required parameter 'subject' is set if @api_client.config.client_side_validation && subject.nil? fail ArgumentError, "Missing the required parameter 'subject' when calling PurchaseOrderApi.send_by_email" end # resource path local_var_path = '/purchaseOrder/{id}/:sendByEmail'.sub('{' + 'id' + '}', id.to_s) # query parameters query_params = {} query_params[:'emailAddress'] = email_address query_params[:'subject'] = subject query_params[:'message'] = opts[:'message'] if !opts[:'message'].nil? # header parameters header_params = {} # form parameters form_params = {} # http body (model) post_body = nil auth_names = ['tokenAuthScheme'] data, status_code, headers = @api_client.call_api(:PUT, local_var_path, :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => 'ResponseWrapperPurchaseOrder') if @api_client.config.debugging @api_client.config.logger.debug "API called: PurchaseOrderApi#send_by_email\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # [BETA] Upload attachment to Purchase Order. # # @param id Purchase Order ID to upload attachment to. # @param file The file # @param [Hash] opts the optional parameters # @option opts [String] :fields Fields filter pattern (default to *) # @return [ResponseWrapperPurchaseOrder] def upload_attachment(id, file, opts = {}) data, _status_code, _headers = upload_attachment_with_http_info(id, file, opts) data end # [BETA] Upload attachment to Purchase Order. # # @param id Purchase Order ID to upload attachment to. # @param file The file # @param [Hash] opts the optional parameters # @option opts [String] :fields Fields filter pattern # @return [Array<(ResponseWrapperPurchaseOrder, Fixnum, Hash)>] ResponseWrapperPurchaseOrder data, response status code and response headers def upload_attachment_with_http_info(id, file, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: PurchaseOrderApi.upload_attachment ...' end # verify the required parameter 'id' is set if @api_client.config.client_side_validation && id.nil? fail ArgumentError, "Missing the required parameter 'id' when calling PurchaseOrderApi.upload_attachment" end # verify the required parameter 'file' is set if @api_client.config.client_side_validation && file.nil? fail ArgumentError, "Missing the required parameter 'file' when calling PurchaseOrderApi.upload_attachment" end # resource path local_var_path = '/purchaseOrder/{id}/attachment'.sub('{' + 'id' + '}', id.to_s) # query parameters query_params = {} query_params[:'fields'] = opts[:'fields'] if !opts[:'fields'].nil? # header parameters header_params = {} # HTTP header 'Content-Type' header_params['Content-Type'] = @api_client.select_header_content_type(['multipart/form-data']) # form parameters form_params = {} form_params['file'] = file # http body (model) post_body = nil auth_names = ['tokenAuthScheme'] data, status_code, headers = @api_client.call_api(:POST, local_var_path, :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => 'ResponseWrapperPurchaseOrder') if @api_client.config.debugging @api_client.config.logger.debug "API called: PurchaseOrderApi#upload_attachment\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Upload multiple attachments to Purchase Order. # # @param id Purchase Order ID to upload attachment to. # @param body Multipart files # @param [Hash] opts the optional parameters # @return [ResponseWrapperPurchaseOrder] def upload_attachments(id, body, opts = {}) data, _status_code, _headers = upload_attachments_with_http_info(id, body, opts) data end # Upload multiple attachments to Purchase Order. # # @param id Purchase Order ID to upload attachment to. # @param body Multipart files # @param [Hash] opts the optional parameters # @return [Array<(ResponseWrapperPurchaseOrder, Fixnum, Hash)>] ResponseWrapperPurchaseOrder data, response status code and response headers def upload_attachments_with_http_info(id, body, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: PurchaseOrderApi.upload_attachments ...' end # verify the required parameter 'id' is set if @api_client.config.client_side_validation && id.nil? fail ArgumentError, "Missing the required parameter 'id' when calling PurchaseOrderApi.upload_attachments" end # verify the required parameter 'body' is set if @api_client.config.client_side_validation && body.nil? fail ArgumentError, "Missing the required parameter 'body' when calling PurchaseOrderApi.upload_attachments" end # resource path local_var_path = '/purchaseOrder/{id}/attachment/list'.sub('{' + 'id' + '}', id.to_s) # query parameters query_params = {} # header parameters header_params = {} # HTTP header 'Content-Type' header_params['Content-Type'] = @api_client.select_header_content_type(['multipart/form-data']) # form parameters form_params = {} # http body (model) post_body = @api_client.object_to_http_body(body) auth_names = ['tokenAuthScheme'] data, status_code, headers = @api_client.call_api(:POST, local_var_path, :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => 'ResponseWrapperPurchaseOrder') if @api_client.config.debugging @api_client.config.logger.debug "API called: PurchaseOrderApi#upload_attachments\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end end end