-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #18 from onyekvchi/feature/ecobank-parser
Feature/ecobank parser
- Loading branch information
Showing
10 changed files
with
272 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,14 @@ | ||
require "ng-bank-parser/version" | ||
require "ng-bank-parser/banks" | ||
require "ng-bank-parser/router" | ||
require "ng-bank-parser/pdf-unlocker" | ||
require "ng-bank-parser/parsers/gtb-excel-parser" | ||
require "ng-bank-parser/parsers/uba-pdf-parser" | ||
require "ng-bank-parser/parsers/hb-pdf-parser" | ||
require "ng-bank-parser/parsers/firstbank-pdf-parser" | ||
require "ng-bank-parser/parsers/accessbank-pdf-parser" | ||
require_relative "ng-bank-parser/version" | ||
require_relative "ng-bank-parser/banks" | ||
require_relative "ng-bank-parser/router" | ||
require_relative "ng-bank-parser/pdf-unlocker" | ||
require_relative "ng-bank-parser/parsers/gtb-excel-parser" | ||
require_relative "ng-bank-parser/parsers/uba-pdf-parser" | ||
require_relative "ng-bank-parser/parsers/hb-pdf-parser" | ||
require_relative "ng-bank-parser/parsers/firstbank-pdf-parser" | ||
require_relative "ng-bank-parser/parsers/accessbank-pdf-parser" | ||
require_relative "ng-bank-parser/parsers/ecobank-pdf-parser" | ||
|
||
module NgBankParser | ||
# Your code goes here... | ||
# Your code goes here... | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
require 'pdf-reader' | ||
require 'open-uri' | ||
require_relative 'ecobank-pdf-parser/helpers' | ||
|
||
module NgBankParser | ||
class EcobankPdf | ||
extend EcobankPdfHelpers | ||
|
||
FILE_FORMATS = [".pdf"] | ||
|
||
def self.parse(path, password=nil) | ||
unless FILE_FORMATS.include? File.extname(path) | ||
return error("Invalid file format. Please use one of the following: #{ FILE_FORMATS.each{ |format| format }}") | ||
end | ||
|
||
file = open(path) | ||
begin | ||
@pdf = PDF::Reader.new(file) | ||
rescue PDF::Reader::EncryptedPDFError | ||
return error("Invalid file. Please use an unencrypted pdf") | ||
rescue | ||
return error("Couldn't parse this file") | ||
end | ||
|
||
pdf_array = pdf_to_a(@pdf) | ||
|
||
unless has_valid_details?(pdf_array) | ||
return error("Couldn't fetch account details from pdf") | ||
end | ||
|
||
response = get_details(pdf_array) | ||
return success(response) | ||
end | ||
end | ||
end |
Oops, something went wrong.