=begin
#Public App Crm Cards

#Allows an app to extend the CRM UI by surfacing custom cards in the sidebar of record pages. These cards are defined up-front as part of app configuration, then populated by external data fetch requests when the record page is accessed by a user.

The version of the OpenAPI document: v3

Generated by: https://openapi-generator.tech
OpenAPI Generator version: 6.2.1

=end

require 'cgi'

module Hubspot
  module Crm
    module Extensions
      module Cards
        class CardsApi
          attr_accessor :api_client

          def initialize(api_client = ApiClient.default)
            @api_client = api_client
          end
          # Delete a card
          # Permanently deletes a card definition with the given ID. Once deleted, data fetch requests for this card will no longer be sent to your service. This can't be undone.
          # @param card_id [String] The ID of the card to delete.
          # @param app_id [Integer] The ID of the target app.
          # @param [Hash] opts the optional parameters
          # @return [nil]
          def archive(card_id, app_id, opts = {})
            archive_with_http_info(card_id, app_id, opts)
            nil
          end

          # Delete a card
          # Permanently deletes a card definition with the given ID. Once deleted, data fetch requests for this card will no longer be sent to your service. This can&#39;t be undone.
          # @param card_id [String] The ID of the card to delete.
          # @param app_id [Integer] The ID of the target app.
          # @param [Hash] opts the optional parameters
          # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers
          def archive_with_http_info(card_id, app_id, opts = {})
            if @api_client.config.debugging
              @api_client.config.logger.debug 'Calling API: CardsApi.archive ...'
            end
            # verify the required parameter 'card_id' is set
            if @api_client.config.client_side_validation && card_id.nil?
              fail ArgumentError, "Missing the required parameter 'card_id' when calling CardsApi.archive"
            end
            # verify the required parameter 'app_id' is set
            if @api_client.config.client_side_validation && app_id.nil?
              fail ArgumentError, "Missing the required parameter 'app_id' when calling CardsApi.archive"
            end
            # resource path
            local_var_path = '/crm/v3/extensions/cards-dev/{appId}/{cardId}'.sub('{' + 'cardId' + '}', CGI.escape(card_id.to_s)).sub('{' + 'appId' + '}', CGI.escape(app_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(['*/*'])

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

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

            # return_type
            return_type = opts[:debug_return_type]

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

            new_options = opts.merge(
              :operation => :"CardsApi.archive",
              :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(:DELETE, local_var_path, new_options)
            if @api_client.config.debugging
              @api_client.config.logger.debug "API called: CardsApi#archive\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
            end
            return data, status_code, headers
          end

          # Create a new card
          # Defines a new card that will become active on an account when this app is installed.
          # @param app_id [Integer] The ID of the target app.
          # @param card_create_request [CardCreateRequest] The new card definition.
          # @param [Hash] opts the optional parameters
          # @return [PublicCardResponse]
          def create(app_id, card_create_request, opts = {})
            data, _status_code, _headers = create_with_http_info(app_id, card_create_request, opts)
            data
          end

          # Create a new card
          # Defines a new card that will become active on an account when this app is installed.
          # @param app_id [Integer] The ID of the target app.
          # @param card_create_request [CardCreateRequest] The new card definition.
          # @param [Hash] opts the optional parameters
          # @return [Array<(PublicCardResponse, Integer, Hash)>] PublicCardResponse data, response status code and response headers
          def create_with_http_info(app_id, card_create_request, opts = {})
            if @api_client.config.debugging
              @api_client.config.logger.debug 'Calling API: CardsApi.create ...'
            end
            # verify the required parameter 'app_id' is set
            if @api_client.config.client_side_validation && app_id.nil?
              fail ArgumentError, "Missing the required parameter 'app_id' when calling CardsApi.create"
            end
            # verify the required parameter 'card_create_request' is set
            if @api_client.config.client_side_validation && card_create_request.nil?
              fail ArgumentError, "Missing the required parameter 'card_create_request' when calling CardsApi.create"
            end
            # resource path
            local_var_path = '/crm/v3/extensions/cards-dev/{appId}'.sub('{' + 'appId' + '}', CGI.escape(app_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', '*/*'])
            # 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(card_create_request)

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

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

            new_options = opts.merge(
              :operation => :"CardsApi.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: CardsApi#create\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
            end
            return data, status_code, headers
          end

          # Get all cards
          # Returns a list of cards for a given app.
          # @param app_id [Integer] The ID of the target app.
          # @param [Hash] opts the optional parameters
          # @return [PublicCardListResponse]
          def get_all(app_id, opts = {})
            data, _status_code, _headers = get_all_with_http_info(app_id, opts)
            data
          end

          # Get all cards
          # Returns a list of cards for a given app.
          # @param app_id [Integer] The ID of the target app.
          # @param [Hash] opts the optional parameters
          # @return [Array<(PublicCardListResponse, Integer, Hash)>] PublicCardListResponse data, response status code and response headers
          def get_all_with_http_info(app_id, opts = {})
            if @api_client.config.debugging
              @api_client.config.logger.debug 'Calling API: CardsApi.get_all ...'
            end
            # verify the required parameter 'app_id' is set
            if @api_client.config.client_side_validation && app_id.nil?
              fail ArgumentError, "Missing the required parameter 'app_id' when calling CardsApi.get_all"
            end
            # resource path
            local_var_path = '/crm/v3/extensions/cards-dev/{appId}'.sub('{' + 'appId' + '}', CGI.escape(app_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] || 'PublicCardListResponse'

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

            new_options = opts.merge(
              :operation => :"CardsApi.get_all",
              :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: CardsApi#get_all\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
            end
            return data, status_code, headers
          end

          # Get a card.
          # Returns the definition for a card with the given ID.
          # @param card_id [String] The ID of the target card.
          # @param app_id [Integer] The ID of the target app.
          # @param [Hash] opts the optional parameters
          # @return [PublicCardResponse]
          def get_by_id(card_id, app_id, opts = {})
            data, _status_code, _headers = get_by_id_with_http_info(card_id, app_id, opts)
            data
          end

          # Get a card.
          # Returns the definition for a card with the given ID.
          # @param card_id [String] The ID of the target card.
          # @param app_id [Integer] The ID of the target app.
          # @param [Hash] opts the optional parameters
          # @return [Array<(PublicCardResponse, Integer, Hash)>] PublicCardResponse data, response status code and response headers
          def get_by_id_with_http_info(card_id, app_id, opts = {})
            if @api_client.config.debugging
              @api_client.config.logger.debug 'Calling API: CardsApi.get_by_id ...'
            end
            # verify the required parameter 'card_id' is set
            if @api_client.config.client_side_validation && card_id.nil?
              fail ArgumentError, "Missing the required parameter 'card_id' when calling CardsApi.get_by_id"
            end
            # verify the required parameter 'app_id' is set
            if @api_client.config.client_side_validation && app_id.nil?
              fail ArgumentError, "Missing the required parameter 'app_id' when calling CardsApi.get_by_id"
            end
            # resource path
            local_var_path = '/crm/v3/extensions/cards-dev/{appId}/{cardId}'.sub('{' + 'cardId' + '}', CGI.escape(card_id.to_s)).sub('{' + 'appId' + '}', CGI.escape(app_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] || 'PublicCardResponse'

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

            new_options = opts.merge(
              :operation => :"CardsApi.get_by_id",
              :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: CardsApi#get_by_id\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
            end
            return data, status_code, headers
          end

          # Update a card
          # Update a card definition with new details.
          # @param card_id [String] The ID of the card to update.
          # @param app_id [Integer] The ID of the target app.
          # @param card_patch_request [CardPatchRequest] Card definition fields to be updated.
          # @param [Hash] opts the optional parameters
          # @return [PublicCardResponse]
          def update(card_id, app_id, card_patch_request, opts = {})
            data, _status_code, _headers = update_with_http_info(card_id, app_id, card_patch_request, opts)
            data
          end

          # Update a card
          # Update a card definition with new details.
          # @param card_id [String] The ID of the card to update.
          # @param app_id [Integer] The ID of the target app.
          # @param card_patch_request [CardPatchRequest] Card definition fields to be updated.
          # @param [Hash] opts the optional parameters
          # @return [Array<(PublicCardResponse, Integer, Hash)>] PublicCardResponse data, response status code and response headers
          def update_with_http_info(card_id, app_id, card_patch_request, opts = {})
            if @api_client.config.debugging
              @api_client.config.logger.debug 'Calling API: CardsApi.update ...'
            end
            # verify the required parameter 'card_id' is set
            if @api_client.config.client_side_validation && card_id.nil?
              fail ArgumentError, "Missing the required parameter 'card_id' when calling CardsApi.update"
            end
            # verify the required parameter 'app_id' is set
            if @api_client.config.client_side_validation && app_id.nil?
              fail ArgumentError, "Missing the required parameter 'app_id' when calling CardsApi.update"
            end
            # verify the required parameter 'card_patch_request' is set
            if @api_client.config.client_side_validation && card_patch_request.nil?
              fail ArgumentError, "Missing the required parameter 'card_patch_request' when calling CardsApi.update"
            end
            # resource path
            local_var_path = '/crm/v3/extensions/cards-dev/{appId}/{cardId}'.sub('{' + 'cardId' + '}', CGI.escape(card_id.to_s)).sub('{' + 'appId' + '}', CGI.escape(app_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', '*/*'])
            # 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(card_patch_request)

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

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

            new_options = opts.merge(
              :operation => :"CardsApi.update",
              :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(:PATCH, local_var_path, new_options)
            if @api_client.config.debugging
              @api_client.config.logger.debug "API called: CardsApi#update\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
            end
            return data, status_code, headers
          end
        end
      end
    end
  end
end
