source
stringclasses
1 value
repo
stringlengths
5
63
repo_url
stringlengths
24
82
path
stringlengths
5
167
language
stringclasses
1 value
license
stringclasses
5 values
stars
int64
10
51.4k
ref
stringclasses
23 values
size_bytes
int64
200
258k
text
stringlengths
137
258k
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/services/datastore/connection.rb
Ruby
mit
19
main
657
module Datastore class Connection extend Forwardable attr_reader :connection def_delegators :connection, :post def initialize @connection = Faraday.new(url:, headers:) end private def url Rails.configuration.x.data_access_api.url end def headers { "Con...
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/services/populators/transaction_type_populator.rb
Ruby
mit
19
main
2,605
module Populators class TransactionTypePopulator def self.call(param = :with_other_income) new.call(param) end def call(param) insert_new_records mark_old_as_archived update_other_income_types if param == :with_other_income populate_hierarchy end private def inse...
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/services/banking/bank_transaction_balance_calculator.rb
Ruby
mit
19
main
861
module Banking class BankTransactionBalanceCalculator delegate :applicant, to: :legal_aid_application delegate :bank_providers, to: :applicant attr_reader :legal_aid_application def self.call(legal_aid_application) new(legal_aid_application).call end def initialize(legal_aid_applicati...
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/services/banking/bank_transactions_trimmer.rb
Ruby
mit
19
main
542
module Banking class BankTransactionsTrimmer def self.call(legal_aid_application) new(legal_aid_application).call end def initialize(legal_aid_application) @legal_aid_application = legal_aid_application end def call @legal_aid_application.bank_transactions ...
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/services/metrics/sidekiq_queue_sizes.rb
Ruby
mit
19
main
780
module Metrics class SidekiqQueueSizes def self.call(prometheus_client) new(prometheus_client).call end def initialize(prometheus_client) @prometheus_client = prometheus_client end def call queues.each { |queue| send_metric(queue) } end private attr_reader :promethe...
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/services/metrics/send_metrics.rb
Ruby
mit
19
main
674
module Metrics class SendMetrics PROMETHEUS_THREAD_SLEEP = 0.1 # seconds def self.call new.call end def call Metrics::SidekiqQueueSizes.call(prometheus_client) # prometheus_exporter runs in a loop and we need to give it some time to send the metrics # https://github.com/disc...
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/services/ccms/manual_review_determiner.rb
Ruby
mit
19
main
3,420
module CCMS # Determines whether or not a manual review of the application by case workers is required # true means yes, false means no (the opposite of the APPLY_CASE_MEANS_REVIEW attribute in the payload) # # This is used in two cases: # - to determine the value of the APPLY_CASE_MEANS_REVIEW attribute for...
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/services/ccms/ccms_error.rb
Ruby
mit
19
main
218
module CCMS CCMSError = Class.new(StandardError) class CCMSUnsuccessfulResponseError < StandardError attr_reader :response def initialize(response) super @response = response end end end
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/services/ccms/attribute_value_generator.rb
Ruby
mit
19
main
17,777
module CCMS # This class is used to generate the Attribute key-value XML block within the instances of the # various entities on the CCMS add request payload. Each possible key value pair has an # entry in the attribute configuration hash (created by the CCMS::AttributeConfiguration class from # YAML files in ...
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/services/ccms/attribute_configuration.rb
Ruby
mit
19
main
1,139
module CCMS class AttributeConfiguration NON_STANDARD_TYPES = %i[non_means_tested non_passported special_children_act].freeze VALID_APPLICATION_TYPES = ([:standard] + NON_STANDARD_TYPES).freeze attr_reader :config # Expects application type of :standard or :non_passported def initialize(applicat...
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/services/ccms/parsers/document_id_response_parser.rb
Ruby
mit
19
main
501
module CCMS module Parsers class DocumentIdResponseParser < BaseResponseParser DOCUMENT_ID_PATH = "//Body//DocumentUploadRS//DocumentID".freeze def document_id @document_id ||= parse(:extracted_document_id) end private def response_type "DocumentUploadRS".freeze ...
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/services/ccms/parsers/reference_data_response_parser.rb
Ruby
mit
19
main
809
module CCMS module Parsers class ReferenceDataResponseParser < BaseResponseParser TRANSACTION_ID_PATH = "//Body//ReferenceDataInqRS//HeaderRS//TransactionID".freeze RESULTS_PATH = "//Body//ReferenceDataInqRS//Results".freeze def reference_id @reference_id ||= parse(:extracted_reference_...
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/services/ccms/parsers/case_add_response_parser.rb
Ruby
mit
19
main
593
module CCMS module Parsers class CaseAddResponseParser < BaseResponseParser TRANSACTION_REQUEST_ID_PATH = "//CaseAddRS//HeaderRS//RequestDetails//TransactionRequestID".freeze STATUS_PATH = "//CaseAddRS//HeaderRS//Status//Status".freeze def success? parse(:extracted_status) == "Success" ...
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/services/ccms/parsers/document_upload_response_parser.rb
Ruby
mit
19
main
657
module CCMS module Parsers class DocumentUploadResponseParser < BaseResponseParser STATUS_PATH = "//Body//DocumentUploadRS//HeaderRS//Status".freeze TRANSACTION_ID_PATH = "//Body/DocumentUploadRS/TransactionID".freeze def success? parse(:extracted_status).include?("Success") end ...
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/services/ccms/parsers/applicant_add_status_response_parser.rb
Ruby
mit
19
main
1,052
module CCMS module Parsers class ApplicantAddStatusResponseParser < BaseResponseParser TRANSACTION_REQUEST_ID_PATH = "//Body//ClientAddUpdtStatusRS//HeaderRS//RequestDetails//TransactionRequestID".freeze STATUS_FREE_TEXT_PATH = "//Body//ClientAddUpdtStatusRS//HeaderRS//Status//StatusFreeText".freeze ...
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/services/ccms/parsers/applicant_add_response_parser.rb
Ruby
mit
19
main
577
module CCMS module Parsers class ApplicantAddResponseParser < BaseResponseParser TRANSACTION_ID_PATH = "//Body//ClientAddRS//HeaderRS//TransactionID".freeze STATUS_PATH = "//Body//ClientAddRS//HeaderRS//Status//Status".freeze def success? parse(:extracted_status) == "Success" end ...
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/services/ccms/parsers/base_response_parser.rb
Ruby
mit
19
main
2,320
module CCMS module Parsers class BaseResponseParser include MessageLogger attr_reader :transaction_request_id, :response, :success, :message def initialize(tx_request_id, response) @transaction_request_id = tx_request_id @response = response @success = nil @mess...
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/services/ccms/parsers/case_add_status_response_parser.rb
Ruby
mit
19
main
685
module CCMS module Parsers class CaseAddStatusResponseParser < BaseResponseParser TRANSACTION_ID_PATH = "//Body//CaseAddUpdtStatusRS//HeaderRS//TransactionID".freeze STATUS_FREE_TEXT_PATH = "//Body//CaseAddUpdtStatusRS//HeaderRS//Status//StatusFreeText".freeze def success? @success = pa...
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/services/ccms/parsers/applicant_search_response_parser.rb
Ruby
mit
19
main
3,193
module CCMS module Parsers class ApplicantSearchResponseParser < BaseResponseParser TRANSACTION_ID_PATH = "//Body//ClientInqRS//HeaderRS//TransactionID".freeze RECORD_COUNT_PATH = "//Body//ClientInqRS//RecordCount//RecordsFetched".freeze ClientResult = Struct.new(:first_initial, :last_name, :la...
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/services/ccms/submitters/check_applicant_status_service.rb
Ruby
mit
19
main
1,632
module CCMS module Submitters class CheckApplicantStatusService < BaseSubmissionService def call tx_id = applicant_add_status_requestor.transaction_request_id submission.applicant_poll_count += 1 submission.save! response = applicant_add_status_requestor.call parser =...
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/services/ccms/submitters/obtain_applicant_reference_service.rb
Ruby
mit
19
main
1,749
module CCMS module Submitters class ObtainApplicantReferenceService < BaseSubmissionService def call tx_id = applicant_search_requestor.transaction_request_id parser = CCMS::Parsers::ApplicantSearchResponseParser.new(tx_id, response, legal_aid_application.applicant) process_records(p...
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/services/ccms/submitters/base_submission_service.rb
Ruby
mit
19
main
1,652
module CCMS require Rails.root.join("app/services/faraday/soap_call.rb") CCMS_SUBMISSION_ERRORS = [ CCMSError, CCMSUnsuccessfulResponseError, Faraday::Error, Faraday::SoapError, StandardError, ].freeze module Submitters class BaseSubmissionService include MessageLogger attr...
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/services/ccms/submitters/upload_documents_service.rb
Ruby
mit
19
main
2,696
module CCMS module Submitters class UploadDocumentsService < BaseSubmissionService def call submission.submission_documents.each do |submission_document| upload_document(submission_document) end raise CCMSError, "The following documents failed to upload: #{failed_upload_id...
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/services/ccms/submitters/add_case_service.rb
Ruby
mit
19
main
1,496
module CCMS module Submitters class AddCaseService < BaseSubmissionService def self.call(submission, options) new(submission).call(options) end def call(options = {}) @options = options unless case_add_response_parser.success? raise CCMSUnsuccessfulResponseErr...
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/services/ccms/submitters/obtain_document_id_service.rb
Ruby
mit
19
main
2,737
module CCMS module Submitters class ObtainDocumentIdService < BaseSubmissionService def call submission.submission_documents.destroy_all return unless populate_documents submission.reload.submission_documents.each do |document| request_document_id(document) end ...
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/services/ccms/submitters/check_case_status_service.rb
Ruby
mit
19
main
1,343
module CCMS module Submitters class CheckCaseStatusService < BaseSubmissionService def call tx_id = case_add_status_requestor.transaction_request_id submission.case_poll_count += 1 submission.save! parser = CCMS::Parsers::CaseAddStatusResponseParser.new(tx_id, response) ...
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/services/ccms/submitters/add_applicant_service.rb
Ruby
mit
19
main
1,484
module CCMS module Submitters class AddApplicantService < BaseSubmissionService def call unless applicant_add_response_parser.success? raise CCMSUnsuccessfulResponseError.new(response), "AddApplicantService failed with unsuccessful response for submission: #{submission.id}"...
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/services/ccms/submitters/obtain_case_reference_service.rb
Ruby
mit
19
main
998
module CCMS module Submitters class ObtainCaseReferenceService < BaseSubmissionService def call submission.case_ccms_reference = reference_id submission.save! create_history(:initialised, submission.aasm_state, xml_request, response) if submission.obtain_case_ref! rescue *CCMS_...
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/services/ccms/requestors/non_means_tested_case_add_requestor.rb
Ruby
mit
19
main
418
module CCMS module Requestors class NonMeansTestedCaseAddRequestor < CaseAddRequestor wsdl_from Rails.configuration.x.ccms_soa.caseServicesWsdl private def means_entity_config_file MEANS_ENTITY_CONFIG_DIR.join("non_means_tested.yml") end def attribute_configuration A...
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/services/ccms/requestors/document_upload_requestor.rb
Ruby
mit
19
main
1,977
module CCMS module Requestors class DocumentUploadRequestor < BaseRequestor wsdl_from Rails.configuration.x.ccms_soa.documentServicesWsdl attr_reader :case_ccms_reference, :ccms_document_id, :document_encoded_base64 def initialize(case_ccms_reference, ccms_document_id, document_encoded_base64,...
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/services/ccms/requestors/applicant_search_requestor.rb
Ruby
mit
19
main
1,418
module CCMS module Requestors class ApplicantSearchRequestor < BaseRequestor wsdl_from Rails.configuration.x.ccms_soa.clientProxyServiceWsdl def initialize(applicant, provider_username) super() @applicant = applicant @provider_username = provider_username end def ...
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/services/ccms/requestors/case_add_status_requestor.rb
Ruby
mit
19
main
849
module CCMS module Requestors class CaseAddStatusRequestor < BaseRequestor wsdl_from Rails.configuration.x.ccms_soa.caseServicesWsdl attr_reader :case_add_transaction_id def initialize(case_add_transaction_id, provider_username) super() @case_add_transaction_id = case_add_trans...
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/services/ccms/requestors/non_passported_case_add_requestor.rb
Ruby
mit
19
main
2,485
module CCMS module Requestors class NonPassportedCaseAddRequestor < CaseAddRequestor wsdl_from Rails.configuration.x.ccms_soa.caseServicesWsdl private def means_entity_config_file MEANS_ENTITY_CONFIG_DIR.join("non_passported.yml") end def national_savings_present? no...
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/services/ccms/requestors/special_children_act_case_add_requestor.rb
Ruby
mit
19
main
440
module CCMS module Requestors class SpecialChildrenActCaseAddRequestor < NonMeansTestedCaseAddRequestor wsdl_from Rails.configuration.x.ccms_soa.caseServicesWsdl private def means_entity_config_file MEANS_ENTITY_CONFIG_DIR.join("non_means_tested.yml") end def attribute_confi...
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/services/ccms/requestors/reference_data_requestor.rb
Ruby
mit
19
main
969
module CCMS module Requestors class ReferenceDataRequestor < BaseRequestor wsdl_from Rails.configuration.x.ccms_soa.getReferenceDataWsdl def initialize(provider_username) super() @provider_username = provider_username end def call Faraday::SoapCall.new(wsdl_locati...
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/services/ccms/requestors/case_add_requestor.rb
Ruby
mit
19
main
21,269
require_relative "../payload_generators/entity_attributes_generator" module CCMS module Requestors class CaseAddRequestor < BaseRequestor include CCMS::PayloadGenerators attr_reader :ccms_attribute_keys, :submission delegate :involved_children, :opponents, to: :legal_aid_applic...
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/services/ccms/requestors/applicant_add_requestor.rb
Ruby
mit
19
main
2,990
module CCMS module Requestors class ApplicantAddRequestor < BaseRequestor wsdl_from Rails.configuration.x.ccms_soa.clientProxyServiceWsdl attr_reader :applicant delegate :home_address_for_ccms, to: :applicant def initialize(applicant, provider_username) super() @applican...
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/services/ccms/requestors/document_id_requestor.rb
Ruby
mit
19
main
1,447
module CCMS module Requestors class DocumentIdRequestor < BaseRequestor wsdl_from Rails.configuration.x.ccms_soa.documentServicesWsdl attr_reader :case_ccms_reference def initialize(case_ccms_reference, provider_username, document_type) super() @case_ccms_reference = case_ccms_...
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/services/ccms/requestors/applicant_add_status_requestor.rb
Ruby
mit
19
main
891
module CCMS module Requestors class ApplicantAddStatusRequestor < BaseRequestor wsdl_from Rails.configuration.x.ccms_soa.clientProxyServiceWsdl attr_reader :applicant_add_transaction_id def initialize(applicant_add_transaction_id, provider_username) super() @applicant_add_trans...
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/services/ccms/requestors/base_requestor.rb
Ruby
mit
19
main
3,164
module CCMS module Requestors class BaseRequestor NAMESPACES = { "xmlns:bill" => "http://legalservices.gov.uk/CCMS/Finance/Payables/1.0/BillingBIO", "xmlns:casebim" => "http://legalservices.gov.uk/CCMS/CaseManagement/Case/1.0/CaseBIM", "xmlns:casebio" => "http://legalservices.gov.uk/...
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/services/ccms/payload_generators/other_party_attribute_generator.rb
Ruby
mit
19
main
4,230
module CCMS module PayloadGenerators class OtherPartyAttributeGenerator attr_accessor :xml, :other_party def initialize(xml, other_party) @xml = xml @other_party = other_party end def self.call(xml, other_party) new(xml, other_party).call end def call...
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/services/ccms/payload_generators/entity_attributes_generator.rb
Ruby
mit
19
main
3,503
module CCMS module PayloadGenerators # This class is responsible for generating the series of attribute blocks for an entity # class EntityAttributesGenerator delegate :ccms_attribute_keys, :submission, to: :requestor attr_reader :requestor CONFIG_METHOD_REGEX = /^#(\S+)/ RESPON...
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/services/reports/reports_creator.rb
Ruby
mit
19
main
433
module Reports class ReportsCreator def self.call(legal_aid_application) MeritsReportCreator.call(legal_aid_application) MeansReportCreator.call(legal_aid_application) BankTransactions::BankTransactionReportCreator.call(legal_aid_application) if legal_aid_application.non_passported? && !legal_ai...
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/services/reports/means_report_creator.rb
Ruby
mit
19
main
1,240
module Reports class MeansReportCreator < BaseReportCreator def call return if valid_report_exists delete_attachment if report_attachment_exists attachment = legal_aid_application.attachments.create!(attachment_type: "means_report", a...
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/services/reports/merits_report_creator.rb
Ruby
mit
19
main
1,100
module Reports class MeritsReportCreator < BaseReportCreator def call return if valid_report_exists delete_attachment if report_attachment_exists attachment = legal_aid_application.attachments.create!(attachment_type: "merits_report", ...
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/services/reports/reports_types_creator.rb
Ruby
mit
19
main
5,614
require "csv" module Reports class ReportsTypesCreator include ActiveModel::Model def self.call(params) new(params).call end attr_reader :application_type, :submitted_to_ccms, :capital_assessment_result, :records_to, :records_fro...
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/services/reports/base_report_creator.rb
Ruby
mit
19
main
1,709
module Reports class BaseReportCreator include GroverOptionable def self.call(legal_aid_application) new(legal_aid_application).call end attr_reader :legal_aid_application def initialize(legal_aid_application) @legal_aid_application = legal_aid_application end private de...
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/services/reports/bank_transactions/bank_transaction_report_creator.rb
Ruby
mit
19
main
1,923
require "csv" module Reports module BankTransactions class BankTransactionReportCreator < BaseReportCreator # generate_local_csv is used for manual testing in the console # rc = Reports::BankTransactions::BankTransactionReportCreator.new(laa) # rc.call(local_csv: true) # def c...
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/services/reports/mis/application_detail_csv_line.rb
Ruby
mit
19
main
16,687
module Reports module MIS class ApplicationDetailCsvLine include Sanitisable attr_reader :laa delegate :applicant, :applicant_receives_benefit?, :cash_transactions, :ccms_reason, :ccms_submission, :cfe_result, ...
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/services/reports/mis/non_passported_application_csv_line.rb
Ruby
mit
19
main
1,057
module Reports module MIS class NonPassportedApplicationCsvLine include Sanitisable attr_reader :laa delegate :provider, to: :laa def self.header_row %w[ state ccms_reason username provider_email created_at date_submitt...
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/services/reports/mis/application_details_report.rb
Ruby
mit
19
main
1,438
require "csv" module Reports module MIS class ApplicationDetailsReport def run generate_temp_file tempfile_name rescue StandardError => e notify_error(e) end private def generate_temp_file line_count = 0 CSV.open(tempfile_name, "w") do |csv| ...
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/services/reports/mis/sanitisable.rb
Ruby
mit
19
main
555
module Reports module MIS module Sanitisable def sanitise @line.map { |field| sanitise_field(field) } end def sanitise_field(field) field.nil? || field.is_a?(Numeric) ? field : prefix_if_necessary(field) end def prefix_if_necessary(field) starts_with_special...
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/services/reports/mis/non_passported_applications_report.rb
Ruby
mit
19
main
1,048
require "csv" module Reports module MIS class NonPassportedApplicationsReport START_DATE = Time.zone.local(2020, 9, 21, 0, 0, 0).freeze def run CSV.generate do |csv| csv << NonPassportedApplicationCsvLine.header_row legal_aid_applications.each do |legal_aid_application| ...
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/serializers/proceeding_type_serializer.rb
Ruby
mit
19
main
221
class ProceedingTypeSerializer < ActiveModel::Serializer attributes :code, :meaning, :description, :additional_search_terms attribute :ccms_category_law, key: :category_law attribute :ccms_matter, key: :matter end
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/jobs/post_submission_processing_job.rb
Ruby
mit
19
main
567
class PostSubmissionProcessingJob < ApplicationJob queue_as :default def perform(legal_aid_application_id, feedback_url) legal_aid_application = LegalAidApplication.find(legal_aid_application_id) ScheduledMailing.send_now!(mailer_klass: SubmissionConfirmationMailer, mailer_me...
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/jobs/email_monitor_job.rb
Ruby
mit
19
main
215
class EmailMonitorJob < ApplicationJob queue_as :default DEFAULT_DELAY = 2.minutes.freeze def perform ScheduledMailing.monitored.each do |mail| GovukEmails::Monitor.call(mail.id) end end end
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/jobs/citizen_complete_means_job.rb
Ruby
mit
19
main
455
class CitizenCompleteMeansJob < ApplicationJob queue_as :default def perform(legal_aid_application_id) @legal_aid_application = LegalAidApplication.find(legal_aid_application_id) reminder_mailings.each(&:cancel!) SubmitProviderReminderService.new(@legal_aid_application).send_email end private def...
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/jobs/scheduled_ccms_submissions_toggle_job.rb
Ruby
mit
19
main
1,945
class ScheduledCCMSSubmissionsToggleJob < ApplicationJob include Sidekiq::Status::Worker def perform(input) log "starting at #{Time.zone.now}" case input when :turn_on Setting.enable_ccms_submission? ? ccms_submissions_already_on : turn_on_ccms_submissions when :turn_off Setting.enable...
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/jobs/bank_transactions_analyser_job.rb
Ruby
mit
19
main
413
class BankTransactionsAnalyserJob < ApplicationJob def perform(legal_aid_application) Banking::BankTransactionBalanceCalculator.call(legal_aid_application) Banking::BankTransactionsTrimmer.call(legal_aid_application) legal_aid_application.complete_bank_transaction_analysis! ProviderEmailService.new(le...
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/jobs/reports_uploader_job.rb
Ruby
mit
19
main
1,454
class ReportsUploaderJob < ApplicationJob include Sidekiq::Status::Worker def perform log "starting at #{Time.zone.now}" unless admin_report.application_details_report&.blob.nil? log "preexisting record as follows:" log "blob key: #{blob.key}, blob_id: #{blob.id}" end tempfile_name = at...
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/jobs/scheduled_mailings_delivery_job.rb
Ruby
mit
19
main
485
class ScheduledMailingsDeliveryJob < ApplicationJob queue_as :default DEFAULT_DELAY = 2.minutes.freeze def perform ScheduledMailing.waiting.past_due.each do |scheduled_mail| GovukEmails::DeliveryMan.call(scheduled_mail.id) end reschedule unless JobQueue.enqueued?(ScheduledMailingsDeliveryJob) ...
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/lib/alert_manager.rb
Ruby
mit
19
main
543
class AlertManager class << self def capture_exception(exception) return unless sendable? alert_klass.capture_exception(exception) end def capture_message(message) return unless sendable? alert_klass.capture_message(message) end def alert_klass Setting.setting.ale...
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/lib/authorized_ip_ranges.rb
Ruby
mit
19
main
628
class AuthorizedIpRanges @authorized_ranges = nil def initialize self.class.authorized_ranges ||= parse_ipaddrs_config end class << self attr_accessor :authorized_ranges end def authorized?(string_ipaddr) ipaddr = IPAddr.new(string_ipaddr) AuthorizedIpRanges.authorized_ranges.each do |ip_...
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/lib/duration_logger.rb
Ruby
mit
19
main
255
module DurationLogger def log_duration(message, &block) started = Time.zone.now yield block total_duration = ActiveSupport::Duration.build(Time.zone.now - started).inspect Rails.logger.info("#{message} took #{total_duration}") end end
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/lib/message_logger.rb
Ruby
mit
19
main
217
module MessageLogger def log_message(message) message = "#{self.class}:: #{message}" message = Time.zone.now.strftime("%F %T.%L ") + message if Rails.env.development? Rails.logger.info message end end
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/lib/malware_scanning.rb
Ruby
mit
19
main
624
module MalwareScanning private def malware_scan_result(original_file) MalwareScanner.call( file_path: original_file.tempfile.path, uploader: provider_uploader, file_details: { size: original_file_size(original_file), name: original_file.original_filename, content_type: o...
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/lib/slack_alerter.rb
Ruby
mit
19
main
874
class SlackAlerter class << self def capture_message(message) send_alert(message) end def capture_exception(exception) send_alert(format_exception(exception)) end def format_exception(exception) <<-END_OF_TEXT Exception raised: #{exception.class} Message: #{exceptio...
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/lib/hmrc/interface_error.rb
Ruby
mit
19
main
232
module HMRC class InterfaceError < StandardError include Nesty::NestedError attr_reader :http_status def initialize(message, http_status = nil) @http_status = http_status super(message) end end end
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/lib/prometheus_collectors/sidekiq_queue_collector.rb
Ruby
mit
19
main
498
require "prometheus_exporter/server" module PrometheusCollectors class SidekiqQueueCollector < PrometheusExporter::Server::TypeCollector COLLECTOR_TYPE = "sidekiq_queue_size".freeze def initialize super @gauge = PrometheusExporter::Metric::Gauge.new(COLLECTOR_TYPE, "Sidekiq queue size") end ...
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/lib/sidekiq/exhausted_failure_message.rb
Ruby
mit
19
main
668
module Sidekiq class ExhaustedFailureMessage def initialize(msg) @msg = msg end def self.call(msg) new(msg).call end def call <<~ERROR #{call_type}: #{@msg['args'].first} failed Moving #{@msg['class']} to dead set, it failed with: #{@msg['error_class']}/#{@msg['...
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/lib/sidekiq/in_progress_warning_message.rb
Ruby
mit
19
main
649
module Sidekiq class InProgressWarningMessage def initialize(source, hmrc_response, retry_count) @source = source.to_s @hmrc_response = hmrc_response @retry_count = retry_count end def self.call(source, hmrc_response, retry_count) new(source, hmrc_response, retry_count).call e...
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/lib/omni_auth/hmrc.rb
Ruby
mit
19
main
884
module OmniAuth module HMRC class Client def initialize oauth_client end def oauth_client @oauth_client ||= ::OAuth2::Client.new( Rails.configuration.x.hmrc_interface.client_id, Rails.configuration.x.hmrc_interface.client_secret, site: Rails.configu...
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/lib/omni_auth/strategies/silas.rb
Ruby
mit
19
main
2,199
module OmniAuth module Strategies class Silas < OmniAuth::Strategies::OpenIDConnect # we may only need the user_name attribute to query PDA for offices and firms # info { { user_name:, email:, roles:, office_codes: } } # info { { user_name:, office_codes: } } # private # The `LAA_A...
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/lib/omni_auth/strategies/true_layer.rb
Ruby
mit
19
main
1,978
# This strategy modifies the behaviour of OmniAuth so that it can be used to manage # Oauth2 authentication via TrueLayer. # Note that you need to restart the server to apply changes to this file. require "omniauth-oauth2" # remove this once special true layer debugging removed require_relative "moj_oauth2" module Om...
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/lib/omni_auth/strategies/moj_oauth2.rb
Ruby
mit
19
main
7,411
require "oauth2" require "omniauth" require "securerandom" require "socket" # for SocketError require "timeout" # for Timeout::Error # rubocop:disable Lint/MissingSuper # :nocov: module OmniAuth module Strategies # Authentication strategy for connecting with APIs constructed using # the [OAuth 2....
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/lib/omni_auth/strategies/admin_login.rb
Ruby
mit
19
main
692
module OmniAuth module Strategies class AdminLogin < OmniAuth::Strategies::OpenIDConnect class << self def mock_auth OmniAuth.config.mock_auth[:admin_entra_id] = OmniAuth::AuthHash.new({ provider: "entra_id", uid: "mock-admin-123", info: { ...
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/controllers/flow_base_controller.rb
Ruby
mit
19
main
671
class FlowBaseController < ApplicationController include Flowable # This stops the browser caching these pages. # This is done so that someone can't use the Back button to return to a users pages # after they have logged out. There is a cost to page load speeds as a result def set_cache_buster response.h...
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/controllers/auth_controller.rb
Ruby
mit
19
main
616
class AuthController < ApplicationController include Devise::Controllers::Rememberable def failure # redirect to consents page if it was an applicant failing to login at his bank if during_citizen_bank_login? redirect_to citizens_consent_path(auth_failure: true) else redirect_to error_path(...
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/controllers/mock_auth_sessions_base_controller.rb
Ruby
mit
19
main
445
class MockAuthSessionsBaseController < Devise::SessionsController def create if mock_auth_session_params[:email] == mock_username && mock_auth_session_params[:password] == mock_password flash[:notice] = I18n.t "devise.sessions.signed_in" sign_in_and_redirect user, event: :authentication el...
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/controllers/application_controller.rb
Ruby
mit
19
main
1,458
class ApplicationController < ActionController::Base layout "application" before_action :out_of_hours_redirect include Backable include HomePathHelper include YourApplicationsHelper helper_method :home_path private def out_of_hours_redirect return if skip_out_of_hours? render "pages/service_o...
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/controllers/errors_controller.rb
Ruby
mit
19
main
1,661
# This controller is called by the application config exceptions_app. # idea taken from https://dev.to/ayushn21/custom-error-pages-in-rails-4i43 # # We may need to consider handling ActionDispatch::Http::MimeNegotiation::InvalidType # as mentioned here https://guides.rubyonrails.org/configuring.html#config-exceptions-...
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/controllers/status_controller.rb
Ruby
mit
19
main
1,717
class StatusController < ApiController def status checks = { database: database_alive?, redis: redis_alive?, sidekiq: sidekiq_alive?, sidekiq_queue: sidekiq_queue_healthy?, malware_scanner: { positive: malware_scanner_positive?, negative: malware_scanner_negative?, ...
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/controllers/feedback_controller.rb
Ruby
mit
19
main
3,467
class FeedbackController < ApplicationController before_action :update_return_path, :update_locale def new @journey = source @feedback = Feedback.new @signed_out = session.delete("signed_out") @submission_feedback = submission_feedback? if submission_feedback? application = LegalAidApplic...
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/controllers/pages_controller.rb
Ruby
mit
19
main
663
class PagesController < ApplicationController def servicedown respond_to do |format| format.html do render :servicedown end format.json do render json: [{ error: "Service temporarily unavailable" }], status: :service_unavailable end fo...
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/controllers/applicants/omniauth_callbacks_controller.rb
Ruby
mit
19
main
1,328
# This controller handles the user's return from the True Layer Oauth2 authentication # Note that you may need to restart the server to apply changes to this file. module Applicants class OmniauthCallbacksController < Devise::OmniauthCallbacksController before_action :authenticate_applicant!, only: [:true_layer] ...
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/controllers/concerns/flowable.rb
Ruby
mit
19
main
1,379
module Flowable extend ActiveSupport::Concern class_methods do # Use a step prefix to avoid step name clashes. # For example: # # class BarsController < ProviderBaseController # prefix_step_with :foo # # With this modification step name will be :foo_bars rather than :bars de...
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/controllers/concerns/office_address_handling.rb
Ruby
mit
19
main
688
module OfficeAddressHandling private def office_address address = PDA::OfficeAddressRetriever.call(current_provider.selected_office.code) [ address.firm_name.downcase.titleize, address.address_line_one.downcase.titleize, address.address_line_two&.downcase&.titleize, address.address_l...
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/controllers/concerns/address_handling.rb
Ruby
mit
19
main
1,084
module AddressHandling AddressCollectionItem = Struct.new(:id, :address) private def filter_addresses(building_number_name) @addresses.select! do |addr| [addr.address_line_one, addr.address_line_two].any? do |str| str.downcase.include?(building_number_name.downcase) end end end de...
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/controllers/concerns/backable.rb
Ruby
mit
19
main
2,945
module Backable extend ActiveSupport::Concern HISTORY_SIZE = 20 EXCLUDED_BACK_PATHS = %w[statement_of_case_upload/list].freeze class_methods do def skip_back_history_actions @skip_back_history_actions || [] end def skip_back_history_for(*actions) @skip_back_history_actions = actions.m...
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/controllers/concerns/grover_optionable.rb
Ruby
mit
19
main
218
module GroverOptionable extend ActiveSupport::Concern included do private def style_tag_options [ content: Rails.root.join("app/assets/builds/application.css").read, ] end end end
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/controllers/concerns/providers/authorizable.rb
Ruby
mit
19
main
1,957
# If included in a controller this will enable pundit and make `authorize legal_aid_application` the default behaviour # Controllers that have `legal_aid_application_not_required!` will also not use the default behaviour set here. # Relies on `legal_aid_application` method being available - so define after `Application...
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/controllers/concerns/providers/cfe_result_mockable.rb
Ruby
mit
19
main
491
module Providers module CFEResultMockable private def mark_as_cfe_result_skipped! CFE::Empty::Result.create!( legal_aid_application_id: legal_aid_application.id, submission_id: submission.id, result: CFE::Empty::EmptyResult.blank_cfe_result.to_json, type: "CFE::Empty::Resu...
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/controllers/concerns/providers/applicant_details_checkable.rb
Ruby
mit
19
main
250
module Providers module ApplicantDetailsCheckable private def details_checked! legal_aid_application.applicant_details_checked! end def details_checked? legal_aid_application.applicant_details_checked? end end end
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/controllers/concerns/providers/appointable.rb
Ruby
mit
19
main
2,896
module Providers module Appointable extend ActiveSupport::Concern included do before_action :appoint_provider! # Redirects to the office selection page if there is no `selected_office`, # remembering wheree the user/provider came from. The office select controller # will then redirec...
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/controllers/concerns/providers/draftable.rb
Ruby
mit
19
main
1,418
module Providers # Adds facility to handle save as draft operations. # Note that it requires both `legal_aid_application` and `go_forward` # So usually depends on `Flowable` and `ApplicationDependable` being included # into the host controller module Draftable ENDPOINT = Flow::KeyPoint.path_for(journey: :...
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/controllers/concerns/providers/delete_attachments.rb
Ruby
mit
19
main
437
module Providers module DeleteAttachments private def find_attachments_starting_with(text) legal_aid_application.attachments.find_all { |attachment| attachment[:attachment_type].start_with?(text) } end def delete_evidence(array) array.each do |attachment| attachment.document.purge_...
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/controllers/concerns/providers/transaction_type_settable.rb
Ruby
mit
19
main
630
module Providers module TransactionTypeSettable extend ActiveSupport::Concern included do before_action :set_transaction_types end private def set_transaction_types @credit_transaction_types = if legal_aid_application.client_uploading_bank_statements? ...
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/controllers/concerns/providers/application_dependable.rb
Ruby
mit
19
main
2,034
module Providers module ApplicationDependable extend ActiveSupport::Concern class_methods do def legal_aid_application_not_required! @legal_aid_application_not_required = true end def legal_aid_application_not_required? @legal_aid_application_not_required end d...
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/controllers/concerns/providers/benefit_check_skippable.rb
Ruby
mit
19
main
210
module Providers module BenefitCheckSkippable private def mark_as_benefit_check_skipped!(reason) legal_aid_application.create_benefit_check_result!(result: "skipped:#{reason}") end end end
github
ministryofjustice/laa-apply-for-legal-aid
https://github.com/ministryofjustice/laa-apply-for-legal-aid
app/controllers/concerns/reviewable/controller.rb
Ruby
mit
19
main
1,906
# Reviewable # # The idea here is to store the fact that (and when) a page or thing # has been visited, reviewed or otherwise "handled" when no other # data exists that can provide this information easily or reliably. # # This was created to track completion of the CYA pages primarily # but may be useful more generally...