=begin
#BombBomb

#We make it easy to build relationships using simple videos.

OpenAPI spec version: 2.0.831

Generated by: https://github.com/swagger-api/swagger-codegen.git
Swagger Codegen version: 2.3.1

=end

require "uri"

module BombBomb
  class IntegrationsApi
    attr_accessor :api_client

    def initialize(api_client = ApiClient.default)
      @api_client = api_client
    end

    # Activate an integration for a user.
    # Provide the correct parameters to enable an integration. Required Parameters vary based on the desired          integration. Integrations requiring OAuth will provide the OAuth link that the user must be presented.
    # @param code The identifier of the integration.
    # @param [Hash] opts the optional parameters
    # @option opts [String] :key The key value.
    # @option opts [String] :secret The secret value.
    # @option opts [String] :token The token value.
    # @option opts [String] :data The data value as JSON.
    # @option opts [String] :overwrite Boolean value to know whether or not to delete the integration if it already exists
    # @return [nil]
    def connect_integration(code, opts = {})
      connect_integration_with_http_info(code, opts)
      return nil
    end

    # Activate an integration for a user.
    # Provide the correct parameters to enable an integration. Required Parameters vary based on the desired          integration. Integrations requiring OAuth will provide the OAuth link that the user must be presented.
    # @param code The identifier of the integration.
    # @param [Hash] opts the optional parameters
    # @option opts [String] :key The key value.
    # @option opts [String] :secret The secret value.
    # @option opts [String] :token The token value.
    # @option opts [String] :data The data value as JSON.
    # @option opts [String] :overwrite Boolean value to know whether or not to delete the integration if it already exists
    # @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers
    def connect_integration_with_http_info(code, opts = {})
      if @api_client.config.debugging
        @api_client.config.logger.debug "Calling API: IntegrationsApi.connect_integration ..."
      end
      # verify the required parameter 'code' is set
      if @api_client.config.client_side_validation && code.nil?
        fail ArgumentError, "Missing the required parameter 'code' when calling IntegrationsApi.connect_integration"
      end
      # resource path
      local_var_path = "/integrations"

      # query parameters
      query_params = {}

      # header parameters
      header_params = {}
      # HTTP header 'Accept' (if needed)
      header_params['Accept'] = @api_client.select_header_accept(['application/json'])
      # HTTP header 'Content-Type'
      header_params['Content-Type'] = @api_client.select_header_content_type(['application/x-www-form-urlencoded'])

      # form parameters
      form_params = {}
      form_params["code"] = code
      form_params["key"] = opts[:'key'] if !opts[:'key'].nil?
      form_params["secret"] = opts[:'secret'] if !opts[:'secret'].nil?
      form_params["token"] = opts[:'token'] if !opts[:'token'].nil?
      form_params["data"] = opts[:'data'] if !opts[:'data'].nil?
      form_params["overwrite"] = opts[:'overwrite'] if !opts[:'overwrite'].nil?

      # http body (model)
      post_body = nil
      auth_names = ['BBOAuth2']
      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)
      if @api_client.config.debugging
        @api_client.config.logger.debug "API called: IntegrationsApi#connect_integration\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
      end
      return data, status_code, headers
    end

    # Remove an integration for a user.
    # Remove an integration by providing the integration id or integration code. Only provide one of the             parameters.
    # @param [Hash] opts the optional parameters
    # @option opts [String] :id Integration ID
    # @option opts [String] :code Integration Code
    # @return [nil]
    def delete_integration(opts = {})
      delete_integration_with_http_info(opts)
      return nil
    end

    # Remove an integration for a user.
    # Remove an integration by providing the integration id or integration code. Only provide one of the             parameters.
    # @param [Hash] opts the optional parameters
    # @option opts [String] :id Integration ID
    # @option opts [String] :code Integration Code
    # @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers
    def delete_integration_with_http_info(opts = {})
      if @api_client.config.debugging
        @api_client.config.logger.debug "Calling API: IntegrationsApi.delete_integration ..."
      end
      # resource path
      local_var_path = "/integrations"

      # query parameters
      query_params = {}

      # header parameters
      header_params = {}
      # HTTP header 'Accept' (if needed)
      header_params['Accept'] = @api_client.select_header_accept(['application/json'])
      # HTTP header 'Content-Type'
      header_params['Content-Type'] = @api_client.select_header_content_type(['application/x-www-form-urlencoded'])

      # form parameters
      form_params = {}
      form_params["id"] = opts[:'id'] if !opts[:'id'].nil?
      form_params["code"] = opts[:'code'] if !opts[:'code'].nil?

      # http body (model)
      post_body = nil
      auth_names = ['BBOAuth2']
      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: IntegrationsApi#delete_integration\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
      end
      return data, status_code, headers
    end

    # Get health for a given integration
    # Get health for an integration.
    # @param code The integration code for which to retrieve the information from
    # @param [Hash] opts the optional parameters
    # @return [nil]
    def get_integration_health(code, opts = {})
      get_integration_health_with_http_info(code, opts)
      return nil
    end

    # Get health for a given integration
    # Get health for an integration.
    # @param code The integration code for which to retrieve the information from
    # @param [Hash] opts the optional parameters
    # @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers
    def get_integration_health_with_http_info(code, opts = {})
      if @api_client.config.debugging
        @api_client.config.logger.debug "Calling API: IntegrationsApi.get_integration_health ..."
      end
      # verify the required parameter 'code' is set
      if @api_client.config.client_side_validation && code.nil?
        fail ArgumentError, "Missing the required parameter 'code' when calling IntegrationsApi.get_integration_health"
      end
      # resource path
      local_var_path = "/integrations/health/{code}".sub('{' + 'code' + '}', code.to_s)

      # query parameters
      query_params = {}

      # header parameters
      header_params = {}
      # HTTP header 'Accept' (if needed)
      header_params['Accept'] = @api_client.select_header_accept(['application/json'])
      # HTTP header 'Content-Type'
      header_params['Content-Type'] = @api_client.select_header_content_type(['application/x-www-form-urlencoded'])

      # form parameters
      form_params = {}

      # http body (model)
      post_body = nil
      auth_names = ['BBOAuth2']
      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)
      if @api_client.config.debugging
        @api_client.config.logger.debug "API called: IntegrationsApi#get_integration_health\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
      end
      return data, status_code, headers
    end

    # Get page components for a given integration
    # Get all page components for an integration.
    # @param integration_name The integration for which to retrieve HTML page components.
    # @param [Hash] opts the optional parameters
    # @return [nil]
    def get_integration_page_components(integration_name, opts = {})
      get_integration_page_components_with_http_info(integration_name, opts)
      return nil
    end

    # Get page components for a given integration
    # Get all page components for an integration.
    # @param integration_name The integration for which to retrieve HTML page components.
    # @param [Hash] opts the optional parameters
    # @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers
    def get_integration_page_components_with_http_info(integration_name, opts = {})
      if @api_client.config.debugging
        @api_client.config.logger.debug "Calling API: IntegrationsApi.get_integration_page_components ..."
      end
      # verify the required parameter 'integration_name' is set
      if @api_client.config.client_side_validation && integration_name.nil?
        fail ArgumentError, "Missing the required parameter 'integration_name' when calling IntegrationsApi.get_integration_page_components"
      end
      # resource path
      local_var_path = "/integrations/pageComponents"

      # query parameters
      query_params = {}
      query_params[:'integration_name'] = integration_name

      # header parameters
      header_params = {}
      # HTTP header 'Accept' (if needed)
      header_params['Accept'] = @api_client.select_header_accept(['application/json'])
      # HTTP header 'Content-Type'
      header_params['Content-Type'] = @api_client.select_header_content_type(['application/x-www-form-urlencoded'])

      # form parameters
      form_params = {}

      # http body (model)
      post_body = nil
      auth_names = ['BBOAuth2']
      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)
      if @api_client.config.debugging
        @api_client.config.logger.debug "API called: IntegrationsApi#get_integration_page_components\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
      end
      return data, status_code, headers
    end

    # Synchronize your integration list or lists.
    # Synchronize your integration contact list with the service you are integrated with. If no integration code is provided, all integrations will be synchronized.
    # @param [Hash] opts the optional parameters
    # @option opts [String] :integration_id The integration to sync lists for. All integrations will sync if nothing is provided.
    # @return [String]
    def sync_users_integrated_lists(opts = {})
      data, _status_code, _headers = sync_users_integrated_lists_with_http_info(opts)
      return data
    end

    # Synchronize your integration list or lists.
    # Synchronize your integration contact list with the service you are integrated with. If no integration code is provided, all integrations will be synchronized.
    # @param [Hash] opts the optional parameters
    # @option opts [String] :integration_id The integration to sync lists for. All integrations will sync if nothing is provided.
    # @return [Array<(String, Fixnum, Hash)>] String data, response status code and response headers
    def sync_users_integrated_lists_with_http_info(opts = {})
      if @api_client.config.debugging
        @api_client.config.logger.debug "Calling API: IntegrationsApi.sync_users_integrated_lists ..."
      end
      # resource path
      local_var_path = "/integrations/sync"

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

      # header parameters
      header_params = {}
      # HTTP header 'Accept' (if needed)
      header_params['Accept'] = @api_client.select_header_accept(['application/json'])
      # HTTP header 'Content-Type'
      header_params['Content-Type'] = @api_client.select_header_content_type(['application/x-www-form-urlencoded'])

      # form parameters
      form_params = {}

      # http body (model)
      post_body = nil
      auth_names = ['BBOAuth2']
      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 => 'String')
      if @api_client.config.debugging
        @api_client.config.logger.debug "API called: IntegrationsApi#sync_users_integrated_lists\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
      end
      return data, status_code, headers
    end
  end
end
