=begin
#MX API

#The MX Atrium API supports over 48,000 data connections to thousands of financial institutions. It provides secure access to your users' accounts and transactions with industry-leading cleansing, categorization, and classification.  Atrium is designed according to resource-oriented REST architecture and responds with JSON bodies and HTTP response codes.  Use Atrium's development environment, vestibule.mx.com, to quickly get up and running. The development environment limits are 100 users, 25 members per user, and access to the top 15 institutions. Contact MX to purchase production access. 


=end

require 'uri'

module Atrium
  class StatementsApi
    attr_accessor :api_client

    def initialize(api_client = ApiClient.default)
      @api_client = api_client
    end
    # Download statement PDF
    # Use this endpoint to download a specified statement. The endpoint URL is the same as the URI given in each `statement` object. 
    # @param member_guid The unique identifier for a &#x60;member&#x60;.
    # @param user_guid The unique identifier for a &#x60;user&#x60;.
    # @param statement_guid The unique identifier for an &#x60;statement&#x60;.
    # @param [Hash] opts the optional parameters
    # @return [File]
    def download_statement_pdf(member_guid, user_guid, statement_guid, opts = {})
      data, _status_code, _headers = download_statement_pdf_with_http_info(member_guid, user_guid, statement_guid, opts)
      data
    end

    # Fetch statements
    # The fetch statements endpoint begins fetching statements for a member.
    # @param member_guid The unique identifier for a &#x60;member&#x60;.
    # @param user_guid The unique identifier for a &#x60;user&#x60;.
    # @param [Hash] opts the optional parameters
    # @return [MemberResponseBody]
    def fetch_statements(member_guid, user_guid, opts = {})
      data, _status_code, _headers = fetch_statements_with_http_info(member_guid, user_guid, opts)
      data
    end

    # List member statements
    # Certain institutions in Atrium allow developers to access account statements associated with a particular `member`. Use this endpoint to get an array of available statements.  Before this endpoint can be used, `fetch_statements` should be performed on the relevant `member`. 
    # @param member_guid The unique identifier for a &#x60;member&#x60;.
    # @param user_guid The unique identifier for a &#x60;user&#x60;.
    # @param [Hash] opts the optional parameters
    # @option opts [Integer] :page Specify current page.
    # @option opts [Integer] :records_per_page Specify records per page.
    # @return [StatementsResponseBody]
    def list_member_statements(member_guid, user_guid, opts = {})
      data, _status_code, _headers = list_member_statements_with_http_info(member_guid, user_guid, opts)
      data
    end

    # Read statement JSON
    # Use this endpoint to download a specified statement. The endpoint URL is the same as the URI given in each `statement` object. 
    # @param member_guid The unique identifier for a &#x60;member&#x60;.
    # @param user_guid The unique identifier for a &#x60;user&#x60;.
    # @param statement_guid The unique identifier for an &#x60;statement&#x60;.
    # @param [Hash] opts the optional parameters
    # @return [StatementResponseBody]
    def read_member_statement(member_guid, user_guid, statement_guid, opts = {})
      data, _status_code, _headers = read_member_statement_with_http_info(member_guid, user_guid, statement_guid, opts)
      data
    end


  private

    # Download statement PDF
    # Use this endpoint to download a specified statement. The endpoint URL is the same as the URI given in each &#x60;statement&#x60; object. 
    # @param member_guid The unique identifier for a &#x60;member&#x60;.
    # @param user_guid The unique identifier for a &#x60;user&#x60;.
    # @param statement_guid The unique identifier for an &#x60;statement&#x60;.
    # @param [Hash] opts the optional parameters
    # @return [Array<(File, Fixnum, Hash)>] File data, response status code and response headers
    def download_statement_pdf_with_http_info(member_guid, user_guid, statement_guid, opts = {})
      if @api_client.config.debugging
        @api_client.config.logger.debug 'Calling API: StatementsApi.download_statement_pdf ...'
      end
      # verify the required parameter 'member_guid' is set
      if @api_client.config.client_side_validation && member_guid.nil?
        fail ArgumentError, "Missing the required parameter 'member_guid' when calling StatementsApi.download_statement_pdf"
      end
      # verify the required parameter 'user_guid' is set
      if @api_client.config.client_side_validation && user_guid.nil?
        fail ArgumentError, "Missing the required parameter 'user_guid' when calling StatementsApi.download_statement_pdf"
      end
      # verify the required parameter 'statement_guid' is set
      if @api_client.config.client_side_validation && statement_guid.nil?
        fail ArgumentError, "Missing the required parameter 'statement_guid' when calling StatementsApi.download_statement_pdf"
      end
      # resource path
      local_var_path = '/users/{user_guid}/members/{member_guid}/statements/{statement_guid}.pdf'.sub('{' + 'member_guid' + '}', member_guid.to_s).sub('{' + 'user_guid' + '}', user_guid.to_s).sub('{' + 'statement_guid' + '}', statement_guid.to_s)

      # query parameters
      query_params = {}

      # header parameters
      header_params = {}
      # HTTP header 'Accept' (if needed)
      header_params['Accept'] = @api_client.select_header_accept(['application/vnd.mx.atrium.v1+pdf'])

      # form parameters
      form_params = {}

      # http body (model)
      post_body = nil
      auth_names = ['apiKey', 'clientID']
      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 => 'File')
      if @api_client.config.debugging
        @api_client.config.logger.debug "API called: StatementsApi#download_statement_pdf\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
      end
      return data, status_code, headers
    end
    # Fetch statements
    # The fetch statements endpoint begins fetching statements for a member.
    # @param member_guid The unique identifier for a &#x60;member&#x60;.
    # @param user_guid The unique identifier for a &#x60;user&#x60;.
    # @param [Hash] opts the optional parameters
    # @return [Array<(MemberResponseBody, Fixnum, Hash)>] MemberResponseBody data, response status code and response headers
    def fetch_statements_with_http_info(member_guid, user_guid, opts = {})
      if @api_client.config.debugging
        @api_client.config.logger.debug 'Calling API: StatementsApi.fetch_statements ...'
      end
      # verify the required parameter 'member_guid' is set
      if @api_client.config.client_side_validation && member_guid.nil?
        fail ArgumentError, "Missing the required parameter 'member_guid' when calling StatementsApi.fetch_statements"
      end
      # verify the required parameter 'user_guid' is set
      if @api_client.config.client_side_validation && user_guid.nil?
        fail ArgumentError, "Missing the required parameter 'user_guid' when calling StatementsApi.fetch_statements"
      end
      # resource path
      local_var_path = '/users/{user_guid}/members/{member_guid}/fetch_statements'.sub('{' + 'member_guid' + '}', member_guid.to_s).sub('{' + 'user_guid' + '}', user_guid.to_s)

      # query parameters
      query_params = {}

      # header parameters
      header_params = {}
      # HTTP header 'Accept' (if needed)
      header_params['Accept'] = @api_client.select_header_accept(['application/vnd.mx.atrium.v1+json'])
      # HTTP header 'Content-Type'
      header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])

      # form parameters
      form_params = {}

      # http body (model)
      post_body = nil
      auth_names = ['apiKey', 'clientID']
      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 => 'MemberResponseBody')
      if @api_client.config.debugging
        @api_client.config.logger.debug "API called: StatementsApi#fetch_statements\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
      end
      return data, status_code, headers
    end
    # List member statements
    # Certain institutions in Atrium allow developers to access account statements associated with a particular &#x60;member&#x60;. Use this endpoint to get an array of available statements.  Before this endpoint can be used, &#x60;fetch_statements&#x60; should be performed on the relevant &#x60;member&#x60;. 
    # @param member_guid The unique identifier for a &#x60;member&#x60;.
    # @param user_guid The unique identifier for a &#x60;user&#x60;.
    # @param [Hash] opts the optional parameters
    # @option opts [Integer] :page Specify current page.
    # @option opts [Integer] :records_per_page Specify records per page.
    # @return [Array<(StatementsResponseBody, Fixnum, Hash)>] StatementsResponseBody data, response status code and response headers
    def list_member_statements_with_http_info(member_guid, user_guid, opts = {})
      if @api_client.config.debugging
        @api_client.config.logger.debug 'Calling API: StatementsApi.list_member_statements ...'
      end
      # verify the required parameter 'member_guid' is set
      if @api_client.config.client_side_validation && member_guid.nil?
        fail ArgumentError, "Missing the required parameter 'member_guid' when calling StatementsApi.list_member_statements"
      end
      # verify the required parameter 'user_guid' is set
      if @api_client.config.client_side_validation && user_guid.nil?
        fail ArgumentError, "Missing the required parameter 'user_guid' when calling StatementsApi.list_member_statements"
      end
      # resource path
      local_var_path = '/users/{user_guid}/members/{member_guid}/statements'.sub('{' + 'member_guid' + '}', member_guid.to_s).sub('{' + 'user_guid' + '}', user_guid.to_s)

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

      # header parameters
      header_params = {}
      # HTTP header 'Accept' (if needed)
      header_params['Accept'] = @api_client.select_header_accept(['application/vnd.mx.atrium.v1+json'])

      # form parameters
      form_params = {}

      # http body (model)
      post_body = nil
      auth_names = ['apiKey', 'clientID']
      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 => 'StatementsResponseBody')
      if @api_client.config.debugging
        @api_client.config.logger.debug "API called: StatementsApi#list_member_statements\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
      end
      return data, status_code, headers
    end
    # Read statement JSON
    # Use this endpoint to download a specified statement. The endpoint URL is the same as the URI given in each &#x60;statement&#x60; object. 
    # @param member_guid The unique identifier for a &#x60;member&#x60;.
    # @param user_guid The unique identifier for a &#x60;user&#x60;.
    # @param statement_guid The unique identifier for an &#x60;statement&#x60;.
    # @param [Hash] opts the optional parameters
    # @return [Array<(StatementResponseBody, Fixnum, Hash)>] StatementResponseBody data, response status code and response headers
    def read_member_statement_with_http_info(member_guid, user_guid, statement_guid, opts = {})
      if @api_client.config.debugging
        @api_client.config.logger.debug 'Calling API: StatementsApi.read_member_statement ...'
      end
      # verify the required parameter 'member_guid' is set
      if @api_client.config.client_side_validation && member_guid.nil?
        fail ArgumentError, "Missing the required parameter 'member_guid' when calling StatementsApi.read_member_statement"
      end
      # verify the required parameter 'user_guid' is set
      if @api_client.config.client_side_validation && user_guid.nil?
        fail ArgumentError, "Missing the required parameter 'user_guid' when calling StatementsApi.read_member_statement"
      end
      # verify the required parameter 'statement_guid' is set
      if @api_client.config.client_side_validation && statement_guid.nil?
        fail ArgumentError, "Missing the required parameter 'statement_guid' when calling StatementsApi.read_member_statement"
      end
      # resource path
      local_var_path = '/users/{user_guid}/members/{member_guid}/statements/{statement_guid}'.sub('{' + 'member_guid' + '}', member_guid.to_s).sub('{' + 'user_guid' + '}', user_guid.to_s).sub('{' + 'statement_guid' + '}', statement_guid.to_s)

      # query parameters
      query_params = {}

      # header parameters
      header_params = {}
      # HTTP header 'Accept' (if needed)
      header_params['Accept'] = @api_client.select_header_accept(['application/vnd.mx.atrium.v1+json'])

      # form parameters
      form_params = {}

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