=begin
#Pinterest REST API

#Pinterest's REST API

The version of the OpenAPI document: 5.3.0
Contact: blah@cliffano.com
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 5.4.0

=end

require 'cgi'

module PinterestSdkClient
  class MediaApi
    attr_accessor :api_client

    def initialize(api_client = ApiClient.default)
      @api_client = api_client
    end
    # Register media upload
    # Register your intent to upload media  The response includes all of the information needed to upload the media to Pinterest.  To upload the media, make an HTTP POST request (using <tt>curl</tt>, for example) to <tt>upload_url</tt> using the <tt>Content-Type</tt> header value. Send the media file's contents as the request's <tt>file</tt> parameter and also include all of the parameters from <tt>upload_parameters</tt>.  <strong><a href='/docs/solutions/content-apps/#creatingvideopins'>Learn more</a></strong> about video Pin creation.
    # @param media_upload_request [MediaUploadRequest] Create a media upload request
    # @param [Hash] opts the optional parameters
    # @return [MediaUpload]
    def media_create(media_upload_request, opts = {})
      data, _status_code, _headers = media_create_with_http_info(media_upload_request, opts)
      data
    end

    # Register media upload
    # Register your intent to upload media  The response includes all of the information needed to upload the media to Pinterest.  To upload the media, make an HTTP POST request (using &lt;tt&gt;curl&lt;/tt&gt;, for example) to &lt;tt&gt;upload_url&lt;/tt&gt; using the &lt;tt&gt;Content-Type&lt;/tt&gt; header value. Send the media file&#39;s contents as the request&#39;s &lt;tt&gt;file&lt;/tt&gt; parameter and also include all of the parameters from &lt;tt&gt;upload_parameters&lt;/tt&gt;.  &lt;strong&gt;&lt;a href&#x3D;&#39;/docs/solutions/content-apps/#creatingvideopins&#39;&gt;Learn more&lt;/a&gt;&lt;/strong&gt; about video Pin creation.
    # @param media_upload_request [MediaUploadRequest] Create a media upload request
    # @param [Hash] opts the optional parameters
    # @return [Array<(MediaUpload, Integer, Hash)>] MediaUpload data, response status code and response headers
    def media_create_with_http_info(media_upload_request, opts = {})
      if @api_client.config.debugging
        @api_client.config.logger.debug 'Calling API: MediaApi.media_create ...'
      end
      # verify the required parameter 'media_upload_request' is set
      if @api_client.config.client_side_validation && media_upload_request.nil?
        fail ArgumentError, "Missing the required parameter 'media_upload_request' when calling MediaApi.media_create"
      end
      # resource path
      local_var_path = '/media'

      # query parameters
      query_params = opts[:query_params] || {}

      # header parameters
      header_params = opts[:header_params] || {}
      # HTTP header 'Accept' (if needed)
      header_params['Accept'] = @api_client.select_header_accept(['application/json'])
      # HTTP header 'Content-Type'
      content_type = @api_client.select_header_content_type(['application/json'])
      if !content_type.nil?
          header_params['Content-Type'] = content_type
      end

      # form parameters
      form_params = opts[:form_params] || {}

      # http body (model)
      post_body = opts[:debug_body] || @api_client.object_to_http_body(media_upload_request)

      # return_type
      return_type = opts[:debug_return_type] || 'MediaUpload'

      # auth_names
      auth_names = opts[:debug_auth_names] || ['pinterest_oauth2']

      new_options = opts.merge(
        :operation => :"MediaApi.media_create",
        :header_params => header_params,
        :query_params => query_params,
        :form_params => form_params,
        :body => post_body,
        :auth_names => auth_names,
        :return_type => return_type
      )

      data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
      if @api_client.config.debugging
        @api_client.config.logger.debug "API called: MediaApi#media_create\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
      end
      return data, status_code, headers
    end

    # Get media upload details
    # Get details for a registered media upload, including its current status.  <strong><a href='/docs/solutions/content-apps/#creatingvideopins'>Learn more</a></strong> about video Pin creation.
    # @param media_id [String] Media identifier
    # @param [Hash] opts the optional parameters
    # @return [MediaUploadDetails]
    def media_get(media_id, opts = {})
      data, _status_code, _headers = media_get_with_http_info(media_id, opts)
      data
    end

    # Get media upload details
    # Get details for a registered media upload, including its current status.  &lt;strong&gt;&lt;a href&#x3D;&#39;/docs/solutions/content-apps/#creatingvideopins&#39;&gt;Learn more&lt;/a&gt;&lt;/strong&gt; about video Pin creation.
    # @param media_id [String] Media identifier
    # @param [Hash] opts the optional parameters
    # @return [Array<(MediaUploadDetails, Integer, Hash)>] MediaUploadDetails data, response status code and response headers
    def media_get_with_http_info(media_id, opts = {})
      if @api_client.config.debugging
        @api_client.config.logger.debug 'Calling API: MediaApi.media_get ...'
      end
      # verify the required parameter 'media_id' is set
      if @api_client.config.client_side_validation && media_id.nil?
        fail ArgumentError, "Missing the required parameter 'media_id' when calling MediaApi.media_get"
      end
      pattern = Regexp.new(/^\d+$/)
      if @api_client.config.client_side_validation && media_id !~ pattern
        fail ArgumentError, "invalid value for 'media_id' when calling MediaApi.media_get, must conform to the pattern #{pattern}."
      end

      # resource path
      local_var_path = '/media/{media_id}'.sub('{' + 'media_id' + '}', CGI.escape(media_id.to_s))

      # query parameters
      query_params = opts[:query_params] || {}

      # header parameters
      header_params = opts[:header_params] || {}
      # HTTP header 'Accept' (if needed)
      header_params['Accept'] = @api_client.select_header_accept(['application/json'])

      # form parameters
      form_params = opts[:form_params] || {}

      # http body (model)
      post_body = opts[:debug_body]

      # return_type
      return_type = opts[:debug_return_type] || 'MediaUploadDetails'

      # auth_names
      auth_names = opts[:debug_auth_names] || ['pinterest_oauth2']

      new_options = opts.merge(
        :operation => :"MediaApi.media_get",
        :header_params => header_params,
        :query_params => query_params,
        :form_params => form_params,
        :body => post_body,
        :auth_names => auth_names,
        :return_type => return_type
      )

      data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
      if @api_client.config.debugging
        @api_client.config.logger.debug "API called: MediaApi#media_get\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
      end
      return data, status_code, headers
    end

    # List media uploads
    # List media uploads filtered by given parameters.  <strong><a href='/docs/solutions/content-apps/#creatingvideopins'>Learn more</a></strong> about video Pin creation.
    # @param [Hash] opts the optional parameters
    # @option opts [String] :bookmark Cursor used to fetch the next page of items
    # @option opts [Integer] :page_size Maximum number of items to include in a single page of the response. See documentation on &lt;a href&#x3D;&#39;/docs/api/v5/#tag/Pagination&#39;&gt;Pagination&lt;/a&gt; for more information. (default to 25)
    # @return [Paginated]
    def media_list(opts = {})
      data, _status_code, _headers = media_list_with_http_info(opts)
      data
    end

    # List media uploads
    # List media uploads filtered by given parameters.  &lt;strong&gt;&lt;a href&#x3D;&#39;/docs/solutions/content-apps/#creatingvideopins&#39;&gt;Learn more&lt;/a&gt;&lt;/strong&gt; about video Pin creation.
    # @param [Hash] opts the optional parameters
    # @option opts [String] :bookmark Cursor used to fetch the next page of items
    # @option opts [Integer] :page_size Maximum number of items to include in a single page of the response. See documentation on &lt;a href&#x3D;&#39;/docs/api/v5/#tag/Pagination&#39;&gt;Pagination&lt;/a&gt; for more information.
    # @return [Array<(Paginated, Integer, Hash)>] Paginated data, response status code and response headers
    def media_list_with_http_info(opts = {})
      if @api_client.config.debugging
        @api_client.config.logger.debug 'Calling API: MediaApi.media_list ...'
      end
      if @api_client.config.client_side_validation && !opts[:'page_size'].nil? && opts[:'page_size'] > 100
        fail ArgumentError, 'invalid value for "opts[:"page_size"]" when calling MediaApi.media_list, must be smaller than or equal to 100.'
      end

      if @api_client.config.client_side_validation && !opts[:'page_size'].nil? && opts[:'page_size'] < 1
        fail ArgumentError, 'invalid value for "opts[:"page_size"]" when calling MediaApi.media_list, must be greater than or equal to 1.'
      end

      # resource path
      local_var_path = '/media'

      # query parameters
      query_params = opts[:query_params] || {}
      query_params[:'bookmark'] = opts[:'bookmark'] if !opts[:'bookmark'].nil?
      query_params[:'page_size'] = opts[:'page_size'] if !opts[:'page_size'].nil?

      # header parameters
      header_params = opts[:header_params] || {}
      # HTTP header 'Accept' (if needed)
      header_params['Accept'] = @api_client.select_header_accept(['application/json'])

      # form parameters
      form_params = opts[:form_params] || {}

      # http body (model)
      post_body = opts[:debug_body]

      # return_type
      return_type = opts[:debug_return_type] || 'Paginated'

      # auth_names
      auth_names = opts[:debug_auth_names] || ['pinterest_oauth2']

      new_options = opts.merge(
        :operation => :"MediaApi.media_list",
        :header_params => header_params,
        :query_params => query_params,
        :form_params => form_params,
        :body => post_body,
        :auth_names => auth_names,
        :return_type => return_type
      )

      data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
      if @api_client.config.debugging
        @api_client.config.logger.debug "API called: MediaApi#media_list\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
      end
      return data, status_code, headers
    end
  end
end