Module: OxTenderAbstract
- Defined in:
- lib/ox-tender-abstract.rb,
lib/oxtenderabstract/client.rb,
lib/oxtenderabstract/engine.rb,
lib/oxtenderabstract/errors.rb,
lib/oxtenderabstract/logger.rb,
lib/oxtenderabstract/result.rb,
lib/oxtenderabstract/version.rb,
lib/oxtenderabstract/xml_parser.rb,
lib/oxtenderabstract/configuration.rb,
lib/oxtenderabstract/document_types.rb,
lib/oxtenderabstract/archive_processor.rb
Overview
Main module for OxTenderAbstract library
Defined Under Namespace
Modules: ContextualLogger, DocumentTypes Classes: ApiError, ArchiveBlockedError, ArchiveError, ArchiveProcessor, Client, Configuration, ConfigurationError, Engine, Error, NetworkError, ParseError, Result, XmlParser
Constant Summary collapse
- VERSION =
'0.9.5'
Class Attribute Summary collapse
Class Method Summary collapse
- .configure {|configuration| ... } ⇒ Object
-
.enhanced_search_tenders(org_region:, exact_date:, subsystem_type: DocumentTypes::DEFAULT_SUBSYSTEM, document_type: DocumentTypes::DEFAULT_DOCUMENT_TYPE, include_attachments: true) ⇒ Object
Enhanced search with detailed information extraction.
-
.get_docs_by_reestr_number(reestr_number:, subsystem_type: DocumentTypes::DEFAULT_SUBSYSTEM) ⇒ Object
Get documents by registry number across subsystems.
- .reset_configuration! ⇒ Object
-
.search_all_tenders(org_region:, exact_date:, subsystems: nil, document_types: nil, include_attachments: true) ⇒ Object
Enhanced method for searching tenders across multiple subsystems.
-
.search_tenders(org_region:, exact_date:, subsystem_type: DocumentTypes::DEFAULT_SUBSYSTEM, document_type: DocumentTypes::DEFAULT_DOCUMENT_TYPE, include_attachments: true) ⇒ Object
Convenience method for searching tenders in specific subsystem.
-
.search_tenders_with_auto_wait(org_region:, exact_date:, subsystem_type: DocumentTypes::DEFAULT_SUBSYSTEM, document_type: DocumentTypes::DEFAULT_DOCUMENT_TYPE, resume_state: nil, include_attachments: true) ⇒ Object
Search tenders with automatic wait on API blocks and resume capability.
Class Attribute Details
.configuration ⇒ Object
22 23 24 |
# File 'lib/ox-tender-abstract.rb', line 22 def configuration @configuration ||= Configuration.new end |
Class Method Details
.configure {|configuration| ... } ⇒ Object
18 19 20 |
# File 'lib/ox-tender-abstract.rb', line 18 def configure yield(configuration) end |
.enhanced_search_tenders(org_region:, exact_date:, subsystem_type: DocumentTypes::DEFAULT_SUBSYSTEM, document_type: DocumentTypes::DEFAULT_DOCUMENT_TYPE, include_attachments: true) ⇒ Object
Enhanced search with detailed information extraction
124 125 126 127 128 129 130 131 132 133 134 135 |
# File 'lib/ox-tender-abstract.rb', line 124 def enhanced_search_tenders(org_region:, exact_date:, subsystem_type: DocumentTypes::DEFAULT_SUBSYSTEM, document_type: DocumentTypes::DEFAULT_DOCUMENT_TYPE, include_attachments: true) client = Client.new client.enhanced_search_tenders( org_region: org_region, exact_date: exact_date, subsystem_type: subsystem_type, document_type: document_type, include_attachments: ) end |
.get_docs_by_reestr_number(reestr_number:, subsystem_type: DocumentTypes::DEFAULT_SUBSYSTEM) ⇒ Object
Get documents by registry number across subsystems
115 116 117 118 119 120 121 |
# File 'lib/ox-tender-abstract.rb', line 115 def get_docs_by_reestr_number(reestr_number:, subsystem_type: DocumentTypes::DEFAULT_SUBSYSTEM) client = Client.new client.get_docs_by_reestr_number( reestr_number: reestr_number, subsystem_type: subsystem_type ) end |
.reset_configuration! ⇒ Object
26 27 28 |
# File 'lib/ox-tender-abstract.rb', line 26 def reset_configuration! @configuration = nil end |
.search_all_tenders(org_region:, exact_date:, subsystems: nil, document_types: nil, include_attachments: true) ⇒ Object
Enhanced method for searching tenders across multiple subsystems
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 |
# File 'lib/ox-tender-abstract.rb', line 44 def search_all_tenders(org_region:, exact_date:, subsystems: nil, document_types: nil, include_attachments: true) # Default subsystems to search subsystems ||= %w[PRIZ RPEC RPGZ BTK UR RGK OD223 RD223] client = Client.new all_results = {} total_tenders = [] total_archives = 0 subsystems.each do |subsystem_type| # Get appropriate document types for this subsystem available_types = DocumentTypes.document_types_for_subsystem(subsystem_type) test_types = document_types || [available_types.first] # Test first type by default subsystem_results = { subsystem: subsystem_type, description: DocumentTypes.description_for_subsystem(subsystem_type), tenders: [], archives: 0, errors: [] } test_types.each do |doc_type| result = client.search_tenders( org_region: org_region, exact_date: exact_date, subsystem_type: subsystem_type, document_type: doc_type, include_attachments: ) if result.success? tenders = result.data[:tenders] || [] archives = result.data[:total_archives] || 0 subsystem_results[:tenders].concat(tenders) subsystem_results[:archives] += archives total_archives += archives # Add subsystem info to each tender tenders.each do |tender| tender[:subsystem_type] = subsystem_type tender[:subsystem_description] = DocumentTypes.description_for_subsystem(subsystem_type) tender[:document_type_used] = doc_type end total_tenders.concat(tenders) else subsystem_results[:errors] << "#{doc_type}: #{result.error}" end rescue StandardError => e subsystem_results[:errors] << "#{doc_type}: #{e.message}" end all_results[subsystem_type] = subsystem_results end Result.success({ tenders: total_tenders, total_archives: total_archives, subsystem_results: all_results, search_params: { org_region: org_region, exact_date: exact_date, subsystems_searched: subsystems.size }, processed_at: Time.now }) end |
.search_tenders(org_region:, exact_date:, subsystem_type: DocumentTypes::DEFAULT_SUBSYSTEM, document_type: DocumentTypes::DEFAULT_DOCUMENT_TYPE, include_attachments: true) ⇒ Object
Convenience method for searching tenders in specific subsystem
31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/ox-tender-abstract.rb', line 31 def search_tenders(org_region:, exact_date:, subsystem_type: DocumentTypes::DEFAULT_SUBSYSTEM, document_type: DocumentTypes::DEFAULT_DOCUMENT_TYPE, include_attachments: true) client = Client.new client.search_tenders( org_region: org_region, exact_date: exact_date, subsystem_type: subsystem_type, document_type: document_type, include_attachments: ) end |
.search_tenders_with_auto_wait(org_region:, exact_date:, subsystem_type: DocumentTypes::DEFAULT_SUBSYSTEM, document_type: DocumentTypes::DEFAULT_DOCUMENT_TYPE, resume_state: nil, include_attachments: true) ⇒ Object
Search tenders with automatic wait on API blocks and resume capability
138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 |
# File 'lib/ox-tender-abstract.rb', line 138 def search_tenders_with_auto_wait(org_region:, exact_date:, subsystem_type: DocumentTypes::DEFAULT_SUBSYSTEM, document_type: DocumentTypes::DEFAULT_DOCUMENT_TYPE, resume_state: nil, include_attachments: true) client = Client.new # Если есть состояние для продолжения if resume_state start_from = resume_state[:next_archive_index] || 0 client.search_tenders_with_resume( org_region: org_region, exact_date: exact_date, subsystem_type: subsystem_type, document_type: document_type, start_from_archive: start_from, resume_state: resume_state, include_attachments: ) else # Используем обычный метод если авто-ожидание включено if configuration.auto_wait_on_block client.search_tenders( org_region: org_region, exact_date: exact_date, subsystem_type: subsystem_type, document_type: document_type, include_attachments: ) else # Используем метод с возможностью продолжения client.search_tenders_with_resume( org_region: org_region, exact_date: exact_date, subsystem_type: subsystem_type, document_type: document_type, include_attachments: ) end end end |