<commit_before>module GreenButtonData
  module Parser
    class ApplicationInformation
      include SAXMachine
      include Enumerations
      include Utilities

      # Data Custodian
      element :dataCustodianId, as: :data_custodian_id
      element :dataCustodianApplicationStatus, class: Integer,
              as: :data_custodian_application_status
      element :dataCustodianScopeSelectionScreenURI,
              as: :data_custodian_scope_selection_screen_uri
      element :dataCustodianBulkRequestURI,
              as: :data_custodian_bulk_request_uri
      element :dataCustodianResourceEndpoint,
              as: :data_custodian_resource_endpoint

      # Third Party
      element :thirdPartyApplicationType, class: Integer,
              as: :third_party_application_type
      element :thirdPartyApplicationUse, class: Integer,
              as: :third_party_application_use
      element :thirdPartyApplicationDescription,
              as: :third_party_application_description
      element :thirdPartyPhone, as: :third_party_phone
      element :thirdPartyScopeSelectionScreenURI,
              as: :third_party_scope_selection_screen_uri
      element :thirdPartyUserPortalScreenURI,
              as: :third_party_user_portal_screen_uri
      element :thirdPartyNotifyUri, as: :third_party_notify_uri

      # Authorization Information
      element :authorizationServerUri, as: :authorization_server_uri
      element :authorizationServerAuthorizationEndpoint,
              as: :authorization_server_authorization_endpoint
      element :authorizationServerRegistrationEndpoint,
              as: :authorization_server_registration_endpoint
      element :authorizationServerTokenEndpoint,
              as: :authorization_server_token_endpoint
      element :token_endpoint_auth_method

      # Client Information
      element :client_name
      element :client_id
      element :client_secret
      element :client_id_issued_at, class: Integer do |epoch|
        Time.at(normalize_epoch(epoch)).utc.to_datetime
      end
      element :client_secret_expires_at, class: Integer do |epoch|
        Time.at(normalize_epoch(epoch)).utc.to_datetime
      end
      element :redirect_uri
      element :software_id
      element :software_version
      element :contacts

      element :scope

      element :grant_types
      element :response_types

      element :registration_client_uri
      element :registration_access_token

      def application_status
        DATA_CUSTODIAN_APPLICATION_STATUS[@data_custodian_application_status]
      end

      def application_type
        THIRD_PARTY_APPLICATION_TYPE[@third_party_application_type]
      end

      def application_use
        THIRD_PARTY_APPLICATION_USE[@third_party_application_use]
      end

      # ESPI Namespacing<commit_msg>Handle case when expiry epoch is set to 0 (never expire)<commit_after>module GreenButtonData
  module Parser
    class ApplicationInformation
      include SAXMachine
      include Enumerations
      include Utilities

      # Data Custodian
      element :dataCustodianId, as: :data_custodian_id
      element :dataCustodianApplicationStatus, class: Integer,
              as: :data_custodian_application_status
      element :dataCustodianScopeSelectionScreenURI,
              as: :data_custodian_scope_selection_screen_uri
      element :dataCustodianBulkRequestURI,
              as: :data_custodian_bulk_request_uri
      element :dataCustodianResourceEndpoint,
              as: :data_custodian_resource_endpoint

      # Third Party
      element :thirdPartyApplicationType, class: Integer,
              as: :third_party_application_type
      element :thirdPartyApplicationUse, class: Integer,
              as: :third_party_application_use
      element :thirdPartyApplicationDescription,
              as: :third_party_application_description
      element :thirdPartyPhone, as: :third_party_phone
      element :thirdPartyScopeSelectionScreenURI,
              as: :third_party_scope_selection_screen_uri
      element :thirdPartyUserPortalScreenURI,
              as: :third_party_user_portal_screen_uri
      element :thirdPartyNotifyUri, as: :third_party_notify_uri

      # Authorization Information
      element :authorizationServerUri, as: :authorization_server_uri
      element :authorizationServerAuthorizationEndpoint,
              as: :authorization_server_authorization_endpoint
      element :authorizationServerRegistrationEndpoint,
              as: :authorization_server_registration_endpoint
      element :authorizationServerTokenEndpoint,
              as: :authorization_server_token_endpoint
      element :token_endpoint_auth_method

      # Client Information
      element :client_name
      element :client_id
      element :client_secret
      element :client_id_issued_at, class: Integer do |epoch|
        Time.at(normalize_epoch(epoch)).utc.to_datetime
      end
      element :client_secret_expires_at, class: Integer do |epoch|
        if epoch == 0
          # 0 means don't expire; set it to distant future
          DateTime.new 9999, 12, 31, 23, 59, 59
        else
          Time.at(normalize_epoch(epoch)).utc.to_datetime
        end
      end
      element :redirect_uri
      element :software_id
      element :software_version
      element :contacts

      element :scope

      element :grant_types
      element :response_types

      element :registration_client_uri
      element :registration_access_token

      def application_status
        DATA_CUSTODIAN_APPLICATION_STATUS[@data_custodian_application_status]
      end

      def application_type
        THIRD_PARTY_APPLICATION_TYPE[@third_party_application_type]
      end

      def application_use
        THIRD_PARTY_APPLICATION_USE[@third_party_application_use]
      end

      # ESPI Namespacing
{'fraction_non_alphanumeric': 0.04468412942989214, 'fraction_numerical': 0.002910460537579182, 'mean_word_length': 3.152096659559346, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1458362', 'n_tokens_mistral': 1615, 'n_tokens_neox': 1547, 'n_words': 322}