mindee 4.0.0 → 4.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (116) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +18 -0
  3. data/bin/cli_products.rb +172 -0
  4. data/bin/mindee.rb +6 -121
  5. data/docs/advanced_file_operations.md +7 -9
  6. data/docs/code_samples/invoice_splitter_v1_async.txt +2 -1
  7. data/docs/code_samples/{license_plates_v1.txt → us_mail_v2_async.txt} +1 -1
  8. data/docs/code_samples/workflow_execution.txt +28 -0
  9. data/docs/getting_started.md +1 -1
  10. data/docs/global_products/barcode_reader_v1.md +1 -1
  11. data/docs/global_products/bill_of_lading_v1.md +1 -1
  12. data/docs/global_products/business_card_v1.md +1 -1
  13. data/docs/global_products/cropper_v1.md +1 -1
  14. data/docs/global_products/delivery_notes_v1.md +2 -2
  15. data/docs/global_products/driver_license_v1.md +1 -1
  16. data/docs/global_products/expense_receipts_v5.md +26 -25
  17. data/docs/global_products/financial_document_v1.md +34 -33
  18. data/docs/global_products/international_id_v2.md +7 -7
  19. data/docs/global_products/invoice_splitter_v1.md +53 -33
  20. data/docs/global_products/invoices_v4.md +19 -19
  21. data/docs/global_products/multi_receipts_detector_v1.md +1 -1
  22. data/docs/global_products/nutrition_facts_v1.md +1 -1
  23. data/docs/global_products/passport_v1.md +1 -1
  24. data/docs/global_products/resume_v1.md +4 -4
  25. data/docs/global_products/universal.md +1 -1
  26. data/docs/global_products.md +1 -1
  27. data/docs/loading_a_document.md +87 -73
  28. data/docs/localized_products/bank_account_details_v2.md +1 -1
  29. data/docs/localized_products/bank_check_v1.md +1 -1
  30. data/docs/localized_products/bank_statement_fr_v2.md +1 -1
  31. data/docs/localized_products/carte_grise_v1.md +1 -1
  32. data/docs/localized_products/energy_bill_fra_v1.md +11 -3
  33. data/docs/localized_products/french_healthcard_v1.md +1 -1
  34. data/docs/localized_products/idcard_fr_v2.md +6 -6
  35. data/docs/localized_products/ind_passport_v1.md +5 -5
  36. data/docs/localized_products/payslip_fra_v3.md +1 -1
  37. data/docs/localized_products/us_healthcare_cards_v1.md +2 -2
  38. data/docs/localized_products/us_mail_v3.md +1 -1
  39. data/docs/localized_products/us_w9_v1.md +1 -1
  40. data/docs/localized_products.md +1 -1
  41. data/lib/mindee/client.rb +6 -8
  42. data/lib/mindee/geometry/polygon.rb +1 -1
  43. data/lib/mindee/http/workflow_endpoint.rb +23 -23
  44. data/lib/mindee/pdf/pdf_extractor.rb +3 -3
  45. data/lib/mindee/product/delivery_note/delivery_note_v1_document.rb +1 -1
  46. data/lib/mindee/product/delivery_note/delivery_note_v1_page.rb +1 -1
  47. data/lib/mindee/product/financial_document/financial_document_v1_document.rb +15 -14
  48. data/lib/mindee/product/financial_document/financial_document_v1_line_item.rb +1 -1
  49. data/lib/mindee/product/financial_document/financial_document_v1_line_items.rb +1 -1
  50. data/lib/mindee/product/fr/energy_bill/energy_bill_v1_document.rb +5 -1
  51. data/lib/mindee/product/fr/energy_bill/energy_bill_v1_energy_usage.rb +18 -0
  52. data/lib/mindee/product/fr/energy_bill/energy_bill_v1_energy_usages.rb +4 -0
  53. data/lib/mindee/product/fr/energy_bill/energy_bill_v1_meter_detail.rb +2 -2
  54. data/lib/mindee/product/fr/energy_bill/energy_bill_v1_page.rb +1 -1
  55. data/lib/mindee/product/invoice/invoice_v4_document.rb +14 -14
  56. data/lib/mindee/product/invoice/invoice_v4_line_item.rb +2 -2
  57. data/lib/mindee/product/invoice/invoice_v4_line_items.rb +1 -1
  58. data/lib/mindee/product/invoice_splitter/invoice_splitter_v1.rb +2 -2
  59. data/lib/mindee/product/invoice_splitter/invoice_splitter_v1_document.rb +38 -42
  60. data/lib/mindee/product/invoice_splitter/invoice_splitter_v1_invoice_page_group.rb +55 -0
  61. data/lib/mindee/product/invoice_splitter/invoice_splitter_v1_invoice_page_groups.rb +48 -0
  62. data/lib/mindee/product/invoice_splitter/invoice_splitter_v1_page.rb +9 -5
  63. data/lib/mindee/product/receipt/receipt_v5_document.rb +8 -8
  64. data/lib/mindee/product/receipt/receipt_v5_line_item.rb +1 -1
  65. data/lib/mindee/product/receipt/receipt_v5_line_items.rb +1 -1
  66. data/lib/mindee/product/us/healthcare_card/healthcare_card_v1_document.rb +1 -1
  67. data/lib/mindee/product/us/healthcare_card/healthcare_card_v1_page.rb +1 -1
  68. data/lib/mindee/product/{eu/license_plate/license_plate_v1.rb → us/us_mail/us_mail_v2.rb} +13 -13
  69. data/lib/mindee/product/us/us_mail/us_mail_v2_document.rb +105 -0
  70. data/lib/mindee/product/{eu/license_plate/license_plate_v1_page.rb → us/us_mail/us_mail_v2_page.rb} +8 -8
  71. data/lib/mindee/product/us/us_mail/us_mail_v2_recipient_address.rb +105 -0
  72. data/lib/mindee/product/us/us_mail/us_mail_v2_recipient_addresses.rb +63 -0
  73. data/lib/mindee/product/us/us_mail/us_mail_v2_sender_address.rb +66 -0
  74. data/lib/mindee/product.rb +5 -5
  75. data/lib/mindee/version.rb +1 -1
  76. data/mindee.gemspec +11 -11
  77. data/sig/custom/net_http.rbs +5 -0
  78. data/sig/mindee/client.rbs +1 -0
  79. data/sig/mindee/http/workflow_endpoint.rbs +8 -2
  80. data/sig/mindee/pdf/pdf_extractor.rbs +1 -1
  81. data/sig/mindee/product/bill_of_lading/bill_of_lading_v1_carrier_items.rbs +1 -1
  82. data/sig/mindee/product/financial_document/financial_document_v1_line_items.rbs +1 -1
  83. data/sig/mindee/product/fr/bank_statement/bank_statement_v2_transactions.rbs +1 -1
  84. data/sig/mindee/product/fr/energy_bill/energy_bill_v1_energy_usage.rbs +2 -0
  85. data/sig/mindee/product/fr/energy_bill/energy_bill_v1_energy_usages.rbs +1 -1
  86. data/sig/mindee/product/fr/energy_bill/energy_bill_v1_subscriptions.rbs +1 -1
  87. data/sig/mindee/product/fr/energy_bill/energy_bill_v1_taxes_and_contributions.rbs +1 -1
  88. data/sig/mindee/product/fr/payslip/payslip_v2_salary_details.rbs +1 -1
  89. data/sig/mindee/product/fr/payslip/payslip_v3_paid_time_offs.rbs +1 -1
  90. data/sig/mindee/product/fr/payslip/payslip_v3_salary_details.rbs +1 -1
  91. data/sig/mindee/product/invoice/invoice_v4_line_items.rbs +1 -1
  92. data/sig/mindee/product/invoice_splitter/invoice_splitter_v1.rbs +1 -4
  93. data/sig/mindee/product/invoice_splitter/invoice_splitter_v1_document.rbs +5 -9
  94. data/sig/mindee/product/invoice_splitter/invoice_splitter_v1_invoice_page_group.rbs +14 -0
  95. data/sig/mindee/product/invoice_splitter/invoice_splitter_v1_invoice_page_groups.rbs +13 -0
  96. data/sig/mindee/product/invoice_splitter/invoice_splitter_v1_page.rbs +2 -0
  97. data/sig/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_nutrients.rbs +1 -1
  98. data/sig/mindee/product/receipt/receipt_v5_line_items.rbs +1 -1
  99. data/sig/mindee/product/resume/resume_v1_certificates.rbs +1 -1
  100. data/sig/mindee/product/resume/resume_v1_educations.rbs +1 -1
  101. data/sig/mindee/product/resume/resume_v1_languages.rbs +1 -1
  102. data/sig/mindee/product/resume/resume_v1_professional_experiences.rbs +1 -1
  103. data/sig/mindee/product/resume/resume_v1_social_networks_urls.rbs +1 -1
  104. data/sig/mindee/product/us/healthcare_card/healthcare_card_v1_copays.rbs +1 -1
  105. data/sig/mindee/product/us/us_mail/us_mail_v2.rbs +13 -0
  106. data/sig/mindee/product/us/us_mail/us_mail_v2_document.rbs +20 -0
  107. data/sig/mindee/product/{eu/license_plate/license_plate_v1_page.rbs → us/us_mail/us_mail_v2_page.rbs} +5 -5
  108. data/sig/mindee/product/us/us_mail/us_mail_v2_recipient_address.rbs +22 -0
  109. data/sig/mindee/product/us/us_mail/us_mail_v2_recipient_addresses.rbs +15 -0
  110. data/sig/mindee/product/us/us_mail/us_mail_v2_sender_address.rbs +18 -0
  111. data/sig/mindee/product/us/us_mail/us_mail_v3_recipient_addresses.rbs +1 -1
  112. metadata +39 -28
  113. data/docs/localized_products/license_plates_v1.md +0 -112
  114. data/lib/mindee/product/eu/license_plate/license_plate_v1_document.rb +0 -37
  115. data/sig/mindee/product/eu/license_plate/license_plate_v1.rbs +0 -13
  116. data/sig/mindee/product/eu/license_plate/license_plate_v1_document.rbs +0 -15
@@ -0,0 +1,48 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'invoice_splitter_v1_invoice_page_group'
4
+
5
+ module Mindee
6
+ module Product
7
+ module InvoiceSplitter
8
+ # List of page groups. Each group represents a single invoice within a multi-invoice document.
9
+ class InvoiceSplitterV1InvoicePageGroups < Array
10
+ # Entries.
11
+ # @return [Array<InvoiceSplitterV1InvoicePageGroup>]
12
+ attr_reader :entries
13
+
14
+ # @param prediction [Array]
15
+ # @param page_id [Integer, nil]
16
+ def initialize(prediction, page_id)
17
+ entries = prediction.map do |entry|
18
+ InvoiceSplitter::InvoiceSplitterV1InvoicePageGroup.new(entry, page_id)
19
+ end
20
+ super(entries)
21
+ end
22
+
23
+ # Creates a line of rST table-compliant string separators.
24
+ # @param char [String] Character to use as a separator.
25
+ # @return [String]
26
+ def self.line_items_separator(char)
27
+ out_str = String.new
28
+ out_str << "+#{char * 74}"
29
+ out_str
30
+ end
31
+
32
+ # @return [String]
33
+ def to_s
34
+ return '' if empty?
35
+
36
+ lines = map do |entry|
37
+ "\n #{entry.to_table_line}\n#{self.class.line_items_separator('-')}"
38
+ end.join
39
+ out_str = String.new
40
+ out_str << ("\n#{self.class.line_items_separator('-')}\n ")
41
+ out_str << ' | Page Indexes '
42
+ out_str << (" |\n#{self.class.line_items_separator('=')}")
43
+ out_str + lines
44
+ end
45
+ end
46
+ end
47
+ end
48
+ end
@@ -6,15 +6,19 @@ require_relative 'invoice_splitter_v1_document'
6
6
  module Mindee
7
7
  module Product
8
8
  module InvoiceSplitter
9
- # Invoice Splitter V1 page.
9
+ # Invoice Splitter API version 1.2 page data.
10
10
  class InvoiceSplitterV1Page < Mindee::Parsing::Common::Page
11
11
  # @param prediction [Hash]
12
12
  def initialize(prediction)
13
13
  super
14
- @prediction = InvoiceSplitterV1PagePrediction.new(
15
- prediction['prediction'],
16
- prediction['id']
17
- )
14
+ @prediction = if prediction['prediction'].empty?
15
+ nil
16
+ else
17
+ InvoiceSplitterV1PagePrediction.new(
18
+ prediction['prediction'],
19
+ prediction['id']
20
+ )
21
+ end
18
22
  end
19
23
  end
20
24
 
@@ -9,31 +9,31 @@ module Mindee
9
9
  # Receipt API version 5.3 document data.
10
10
  class ReceiptV5Document < Mindee::Parsing::Common::Prediction
11
11
  include Mindee::Parsing::Standard
12
- # The purchase category among predefined classes.
12
+ # The purchase category of the receipt.
13
13
  # @return [Mindee::Parsing::Standard::ClassificationField]
14
14
  attr_reader :category
15
15
  # The date the purchase was made.
16
16
  # @return [Mindee::Parsing::Standard::DateField]
17
17
  attr_reader :date
18
- # One of: 'CREDIT CARD RECEIPT', 'EXPENSE RECEIPT'.
18
+ # The type of receipt: EXPENSE RECEIPT or CREDIT CARD RECEIPT.
19
19
  # @return [Mindee::Parsing::Standard::ClassificationField]
20
20
  attr_reader :document_type
21
- # List of line item details.
21
+ # List of all line items on the receipt.
22
22
  # @return [Mindee::Product::Receipt::ReceiptV5LineItems]
23
23
  attr_reader :line_items
24
- # The locale detected on the document.
24
+ # The locale of the document.
25
25
  # @return [Mindee::Parsing::Standard::LocaleField]
26
26
  attr_reader :locale
27
27
  # The receipt number or identifier.
28
28
  # @return [Mindee::Parsing::Standard::StringField]
29
29
  attr_reader :receipt_number
30
- # The purchase subcategory among predefined classes for transport and food.
30
+ # The purchase subcategory of the receipt for transport and food.
31
31
  # @return [Mindee::Parsing::Standard::ClassificationField]
32
32
  attr_reader :subcategory
33
33
  # The address of the supplier or merchant.
34
34
  # @return [Mindee::Parsing::Standard::StringField]
35
35
  attr_reader :supplier_address
36
- # List of company registrations associated to the supplier.
36
+ # List of company registration numbers associated to the supplier.
37
37
  # @return [Array<Mindee::Parsing::Standard::CompanyRegistrationField>]
38
38
  attr_reader :supplier_company_registrations
39
39
  # The name of the supplier or merchant.
@@ -42,7 +42,7 @@ module Mindee
42
42
  # The phone number of the supplier or merchant.
43
43
  # @return [Mindee::Parsing::Standard::StringField]
44
44
  attr_reader :supplier_phone_number
45
- # List of tax lines information.
45
+ # The list of taxes present on the receipt.
46
46
  # @return [Mindee::Parsing::Standard::Taxes]
47
47
  attr_reader :taxes
48
48
  # The time the purchase was made.
@@ -57,7 +57,7 @@ module Mindee
57
57
  # The net amount paid: does not include taxes, fees, and discounts.
58
58
  # @return [Mindee::Parsing::Standard::AmountField]
59
59
  attr_reader :total_net
60
- # The total amount of taxes.
60
+ # The sum of all taxes.
61
61
  # @return [Mindee::Parsing::Standard::AmountField]
62
62
  attr_reader :total_tax
63
63
 
@@ -5,7 +5,7 @@ require_relative '../../parsing'
5
5
  module Mindee
6
6
  module Product
7
7
  module Receipt
8
- # List of line item details.
8
+ # List of all line items on the receipt.
9
9
  class ReceiptV5LineItem < Mindee::Parsing::Standard::FeatureField
10
10
  include Mindee::Parsing::Standard
11
11
  # The item description.
@@ -5,7 +5,7 @@ require_relative 'receipt_v5_line_item'
5
5
  module Mindee
6
6
  module Product
7
7
  module Receipt
8
- # List of line item details.
8
+ # List of all line items on the receipt.
9
9
  class ReceiptV5LineItems < Array
10
10
  # Entries.
11
11
  # @return [Array<ReceiptV5LineItem>]
@@ -7,7 +7,7 @@ module Mindee
7
7
  module Product
8
8
  module US
9
9
  module HealthcareCard
10
- # Healthcare Card API version 1.0 document data.
10
+ # Healthcare Card API version 1.1 document data.
11
11
  class HealthcareCardV1Document < Mindee::Parsing::Common::Prediction
12
12
  include Mindee::Parsing::Standard
13
13
  # The name of the company that provides the healthcare plan.
@@ -7,7 +7,7 @@ module Mindee
7
7
  module Product
8
8
  module US
9
9
  module HealthcareCard
10
- # Healthcare Card API version 1.0 page data.
10
+ # Healthcare Card API version 1.1 page data.
11
11
  class HealthcareCardV1Page < Mindee::Parsing::Common::Page
12
12
  # @param prediction [Hash]
13
13
  def initialize(prediction)
@@ -1,28 +1,28 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative '../../../parsing'
4
- require_relative 'license_plate_v1_document'
5
- require_relative 'license_plate_v1_page'
4
+ require_relative 'us_mail_v2_document'
5
+ require_relative 'us_mail_v2_page'
6
6
 
7
7
  module Mindee
8
8
  module Product
9
- module EU
10
- # License Plate module.
11
- module LicensePlate
12
- # License Plate API version 1 inference prediction.
13
- class LicensePlateV1 < Mindee::Parsing::Common::Inference
14
- @endpoint_name = 'license_plates'
15
- @endpoint_version = '1'
16
- @has_async = false
17
- @has_sync = true
9
+ module US
10
+ # US Mail module.
11
+ module UsMail
12
+ # US Mail API version 2 inference prediction.
13
+ class UsMailV2 < Mindee::Parsing::Common::Inference
14
+ @endpoint_name = 'us_mail'
15
+ @endpoint_version = '2'
16
+ @has_async = true
17
+ @has_sync = false
18
18
 
19
19
  # @param prediction [Hash]
20
20
  def initialize(prediction)
21
21
  super
22
- @prediction = LicensePlateV1Document.new(prediction['prediction'], nil)
22
+ @prediction = UsMailV2Document.new(prediction['prediction'], nil)
23
23
  @pages = []
24
24
  prediction['pages'].each do |page|
25
- @pages.push(LicensePlateV1Page.new(page))
25
+ @pages.push(UsMailV2Page.new(page))
26
26
  end
27
27
  end
28
28
 
@@ -0,0 +1,105 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../../../parsing'
4
+ require_relative 'us_mail_v2_sender_address'
5
+ require_relative 'us_mail_v2_recipient_addresses'
6
+
7
+ module Mindee
8
+ module Product
9
+ module US
10
+ module UsMail
11
+ # US Mail API version 2.0 document data.
12
+ class UsMailV2Document < Mindee::Parsing::Common::Prediction
13
+ include Mindee::Parsing::Standard
14
+ # The addresses of the recipients.
15
+ # @return [Mindee::Product::US::UsMail::UsMailV2RecipientAddresses]
16
+ attr_reader :recipient_addresses
17
+ # The names of the recipients.
18
+ # @return [Array<Mindee::Parsing::Standard::StringField>]
19
+ attr_reader :recipient_names
20
+ # The address of the sender.
21
+ # @return [Mindee::Product::US::UsMail::UsMailV2SenderAddress]
22
+ attr_reader :sender_address
23
+ # The name of the sender.
24
+ # @return [Mindee::Parsing::Standard::StringField]
25
+ attr_reader :sender_name
26
+
27
+ # @param prediction [Hash]
28
+ # @param page_id [Integer, nil]
29
+ def initialize(prediction, page_id)
30
+ super
31
+ @recipient_addresses = Product::US::UsMail::UsMailV2RecipientAddresses.new(
32
+ prediction['recipient_addresses'], page_id
33
+ )
34
+ @recipient_names = [] # : Array[Parsing::Standard::StringField]
35
+ prediction['recipient_names'].each do |item|
36
+ @recipient_names.push(Parsing::Standard::StringField.new(item, page_id))
37
+ end
38
+ @sender_address = Product::US::UsMail::UsMailV2SenderAddress.new(
39
+ prediction['sender_address'],
40
+ page_id
41
+ )
42
+ @sender_name = Parsing::Standard::StringField.new(
43
+ prediction['sender_name'],
44
+ page_id
45
+ )
46
+ end
47
+
48
+ # @return [String]
49
+ def to_s
50
+ sender_address = @sender_address.to_s
51
+ recipient_names = @recipient_names.join("\n #{' ' * 17}")
52
+ recipient_addresses = recipient_addresses_to_s
53
+ out_str = String.new
54
+ out_str << "\n:Sender Name: #{@sender_name}".rstrip
55
+ out_str << "\n:Sender Address:"
56
+ out_str << sender_address
57
+ out_str << "\n:Recipient Names: #{recipient_names}".rstrip
58
+ out_str << "\n:Recipient Addresses:"
59
+ out_str << recipient_addresses
60
+ out_str[1..].to_s
61
+ end
62
+
63
+ private
64
+
65
+ # @param char [String]
66
+ # @return [String]
67
+ def recipient_addresses_separator(char)
68
+ out_str = String.new
69
+ out_str << ' '
70
+ out_str << "+#{char * 17}"
71
+ out_str << "+#{char * 37}"
72
+ out_str << "+#{char * 19}"
73
+ out_str << "+#{char * 13}"
74
+ out_str << "+#{char * 24}"
75
+ out_str << "+#{char * 7}"
76
+ out_str << "+#{char * 27}"
77
+ out_str << '+'
78
+ out_str
79
+ end
80
+
81
+ # @return [String]
82
+ def recipient_addresses_to_s
83
+ return '' if @recipient_addresses.empty?
84
+
85
+ line_items = @recipient_addresses.map(&:to_table_line).join("\n#{recipient_addresses_separator('-')}\n ")
86
+ out_str = String.new
87
+ out_str << "\n#{recipient_addresses_separator('-')}"
88
+ out_str << "\n |"
89
+ out_str << ' City |'
90
+ out_str << ' Complete Address |'
91
+ out_str << ' Is Address Change |'
92
+ out_str << ' Postal Code |'
93
+ out_str << ' Private Mailbox Number |'
94
+ out_str << ' State |'
95
+ out_str << ' Street |'
96
+ out_str << "\n#{recipient_addresses_separator('=')}"
97
+ out_str << "\n #{line_items}"
98
+ out_str << "\n#{recipient_addresses_separator('-')}"
99
+ out_str
100
+ end
101
+ end
102
+ end
103
+ end
104
+ end
105
+ end
@@ -1,21 +1,21 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative '../../../parsing'
4
- require_relative 'license_plate_v1_document'
4
+ require_relative 'us_mail_v2_document'
5
5
 
6
6
  module Mindee
7
7
  module Product
8
- module EU
9
- module LicensePlate
10
- # License Plate API version 1.1 page data.
11
- class LicensePlateV1Page < Mindee::Parsing::Common::Page
8
+ module US
9
+ module UsMail
10
+ # US Mail API version 2.0 page data.
11
+ class UsMailV2Page < Mindee::Parsing::Common::Page
12
12
  # @param prediction [Hash]
13
13
  def initialize(prediction)
14
14
  super
15
15
  @prediction = if prediction['prediction'].empty?
16
16
  nil
17
17
  else
18
- LicensePlateV1PagePrediction.new(
18
+ UsMailV2PagePrediction.new(
19
19
  prediction['prediction'],
20
20
  prediction['id']
21
21
  )
@@ -23,8 +23,8 @@ module Mindee
23
23
  end
24
24
  end
25
25
 
26
- # License Plate V1 page prediction.
27
- class LicensePlateV1PagePrediction < LicensePlateV1Document
26
+ # US Mail V2 page prediction.
27
+ class UsMailV2PagePrediction < UsMailV2Document
28
28
  # @return [String]
29
29
  def to_s
30
30
  out_str = String.new
@@ -0,0 +1,105 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../../../parsing'
4
+
5
+ module Mindee
6
+ module Product
7
+ module US
8
+ module UsMail
9
+ # The addresses of the recipients.
10
+ class UsMailV2RecipientAddress < Mindee::Parsing::Standard::FeatureField
11
+ include Mindee::Parsing::Standard
12
+ # The city of the recipient's address.
13
+ # @return [String]
14
+ attr_reader :city
15
+ # The complete address of the recipient.
16
+ # @return [String]
17
+ attr_reader :complete
18
+ # Indicates if the recipient's address is a change of address.
19
+ # @return [bool]
20
+ attr_reader :is_address_change
21
+ # The postal code of the recipient's address.
22
+ # @return [String]
23
+ attr_reader :postal_code
24
+ # The private mailbox number of the recipient's address.
25
+ # @return [String]
26
+ attr_reader :private_mailbox_number
27
+ # Second part of the ISO 3166-2 code, consisting of two letters indicating the US State.
28
+ # @return [String]
29
+ attr_reader :state
30
+ # The street of the recipient's address.
31
+ # @return [String]
32
+ attr_reader :street
33
+
34
+ # @param prediction [Hash]
35
+ # @param page_id [Integer, nil]
36
+ def initialize(prediction, page_id)
37
+ super
38
+ @city = prediction['city']
39
+ @complete = prediction['complete']
40
+ @is_address_change = prediction['is_address_change']
41
+ @postal_code = prediction['postal_code']
42
+ @private_mailbox_number = prediction['private_mailbox_number']
43
+ @state = prediction['state']
44
+ @street = prediction['street']
45
+ @page_id = page_id
46
+ end
47
+
48
+ # @return [Hash]
49
+ def printable_values
50
+ printable = {}
51
+ printable[:city] = format_for_display(@city)
52
+ printable[:complete] = format_for_display(@complete)
53
+ printable[:is_address_change] = format_for_display(@is_address_change)
54
+ printable[:postal_code] = format_for_display(@postal_code)
55
+ printable[:private_mailbox_number] = format_for_display(@private_mailbox_number)
56
+ printable[:state] = format_for_display(@state)
57
+ printable[:street] = format_for_display(@street)
58
+ printable
59
+ end
60
+
61
+ # @return [Hash]
62
+ def table_printable_values
63
+ printable = {}
64
+ printable[:city] = format_for_display(@city, 15)
65
+ printable[:complete] = format_for_display(@complete, 35)
66
+ printable[:is_address_change] = format_for_display(@is_address_change, nil)
67
+ printable[:postal_code] = format_for_display(@postal_code, nil)
68
+ printable[:private_mailbox_number] = format_for_display(@private_mailbox_number, nil)
69
+ printable[:state] = format_for_display(@state, nil)
70
+ printable[:street] = format_for_display(@street, 25)
71
+ printable
72
+ end
73
+
74
+ # @return [String]
75
+ def to_table_line
76
+ printable = table_printable_values
77
+ out_str = String.new
78
+ out_str << format('| %- 16s', printable[:city])
79
+ out_str << format('| %- 36s', printable[:complete])
80
+ out_str << format('| %- 18s', printable[:is_address_change])
81
+ out_str << format('| %- 12s', printable[:postal_code])
82
+ out_str << format('| %- 23s', printable[:private_mailbox_number])
83
+ out_str << format('| %- 6s', printable[:state])
84
+ out_str << format('| %- 26s', printable[:street])
85
+ out_str << '|'
86
+ end
87
+
88
+ # @return [String]
89
+ def to_s
90
+ printable = printable_values
91
+ out_str = String.new
92
+ out_str << "\n :City: #{printable[:city]}"
93
+ out_str << "\n :Complete Address: #{printable[:complete]}"
94
+ out_str << "\n :Is Address Change: #{printable[:is_address_change]}"
95
+ out_str << "\n :Postal Code: #{printable[:postal_code]}"
96
+ out_str << "\n :Private Mailbox Number: #{printable[:private_mailbox_number]}"
97
+ out_str << "\n :State: #{printable[:state]}"
98
+ out_str << "\n :Street: #{printable[:street]}"
99
+ out_str
100
+ end
101
+ end
102
+ end
103
+ end
104
+ end
105
+ end
@@ -0,0 +1,63 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'us_mail_v2_sender_address'
4
+ require_relative 'us_mail_v2_recipient_address'
5
+
6
+ module Mindee
7
+ module Product
8
+ module US
9
+ module UsMail
10
+ # The addresses of the recipients.
11
+ class UsMailV2RecipientAddresses < Array
12
+ # Entries.
13
+ # @return [Array<UsMailV2RecipientAddress>]
14
+ attr_reader :entries
15
+
16
+ # @param prediction [Array]
17
+ # @param page_id [Integer, nil]
18
+ def initialize(prediction, page_id)
19
+ entries = prediction.map do |entry|
20
+ UsMail::UsMailV2RecipientAddress.new(entry, page_id)
21
+ end
22
+ super(entries)
23
+ end
24
+
25
+ # Creates a line of rST table-compliant string separators.
26
+ # @param char [String] Character to use as a separator.
27
+ # @return [String]
28
+ def self.line_items_separator(char)
29
+ out_str = String.new
30
+ out_str << "+#{char * 17}"
31
+ out_str << "+#{char * 37}"
32
+ out_str << "+#{char * 19}"
33
+ out_str << "+#{char * 13}"
34
+ out_str << "+#{char * 24}"
35
+ out_str << "+#{char * 7}"
36
+ out_str << "+#{char * 27}"
37
+ out_str
38
+ end
39
+
40
+ # @return [String]
41
+ def to_s
42
+ return '' if empty?
43
+
44
+ lines = map do |entry|
45
+ "\n #{entry.to_table_line}\n#{self.class.line_items_separator('-')}"
46
+ end.join
47
+ out_str = String.new
48
+ out_str << ("\n#{self.class.line_items_separator('-')}\n ")
49
+ out_str << ' | City '
50
+ out_str << ' | Complete Address '
51
+ out_str << ' | Is Address Change'
52
+ out_str << ' | Postal Code'
53
+ out_str << ' | Private Mailbox Number'
54
+ out_str << ' | State'
55
+ out_str << ' | Street '
56
+ out_str << (" |\n#{self.class.line_items_separator('=')}")
57
+ out_str + lines
58
+ end
59
+ end
60
+ end
61
+ end
62
+ end
63
+ end
@@ -0,0 +1,66 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../../../parsing'
4
+
5
+ module Mindee
6
+ module Product
7
+ module US
8
+ module UsMail
9
+ # The address of the sender.
10
+ class UsMailV2SenderAddress < Mindee::Parsing::Standard::FeatureField
11
+ include Mindee::Parsing::Standard
12
+ # The city of the sender's address.
13
+ # @return [String]
14
+ attr_reader :city
15
+ # The complete address of the sender.
16
+ # @return [String]
17
+ attr_reader :complete
18
+ # The postal code of the sender's address.
19
+ # @return [String]
20
+ attr_reader :postal_code
21
+ # Second part of the ISO 3166-2 code, consisting of two letters indicating the US State.
22
+ # @return [String]
23
+ attr_reader :state
24
+ # The street of the sender's address.
25
+ # @return [String]
26
+ attr_reader :street
27
+
28
+ # @param prediction [Hash]
29
+ # @param page_id [Integer, nil]
30
+ def initialize(prediction, page_id)
31
+ super
32
+ @city = prediction['city']
33
+ @complete = prediction['complete']
34
+ @postal_code = prediction['postal_code']
35
+ @state = prediction['state']
36
+ @street = prediction['street']
37
+ @page_id = page_id
38
+ end
39
+
40
+ # @return [Hash]
41
+ def printable_values
42
+ printable = {}
43
+ printable[:city] = format_for_display(@city)
44
+ printable[:complete] = format_for_display(@complete)
45
+ printable[:postal_code] = format_for_display(@postal_code)
46
+ printable[:state] = format_for_display(@state)
47
+ printable[:street] = format_for_display(@street)
48
+ printable
49
+ end
50
+
51
+ # @return [String]
52
+ def to_s
53
+ printable = printable_values
54
+ out_str = String.new
55
+ out_str << "\n :City: #{printable[:city]}"
56
+ out_str << "\n :Complete Address: #{printable[:complete]}"
57
+ out_str << "\n :Postal Code: #{printable[:postal_code]}"
58
+ out_str << "\n :State: #{printable[:state]}"
59
+ out_str << "\n :Street: #{printable[:street]}"
60
+ out_str
61
+ end
62
+ end
63
+ end
64
+ end
65
+ end
66
+ end
@@ -6,22 +6,21 @@ require_relative 'product/business_card/business_card_v1'
6
6
  require_relative 'product/cropper/cropper_v1'
7
7
  require_relative 'product/delivery_note/delivery_note_v1'
8
8
  require_relative 'product/driver_license/driver_license_v1'
9
- require_relative 'product/eu/license_plate/license_plate_v1'
9
+ require_relative 'product/financial_document/financial_document_v1'
10
10
  require_relative 'product/fr/bank_account_details/bank_account_details_v1'
11
11
  require_relative 'product/fr/bank_account_details/bank_account_details_v2'
12
12
  require_relative 'product/fr/bank_statement/bank_statement_v2'
13
13
  require_relative 'product/fr/carte_grise/carte_grise_v1'
14
- require_relative 'product/fr/id_card/id_card_v1'
15
- require_relative 'product/fr/id_card/id_card_v2'
16
14
  require_relative 'product/fr/energy_bill/energy_bill_v1'
17
15
  require_relative 'product/fr/health_card/health_card_v1'
16
+ require_relative 'product/fr/id_card/id_card_v1'
17
+ require_relative 'product/fr/id_card/id_card_v2'
18
18
  require_relative 'product/fr/payslip/payslip_v2'
19
19
  require_relative 'product/fr/payslip/payslip_v3'
20
- require_relative 'product/financial_document/financial_document_v1'
21
20
  require_relative 'product/ind/indian_passport/indian_passport_v1'
21
+ require_relative 'product/international_id/international_id_v2'
22
22
  require_relative 'product/invoice/invoice_v4'
23
23
  require_relative 'product/invoice_splitter/invoice_splitter_v1'
24
- require_relative 'product/international_id/international_id_v2'
25
24
  require_relative 'product/multi_receipts_detector/multi_receipts_detector_v1'
26
25
  require_relative 'product/nutrition_facts_label/nutrition_facts_label_v1'
27
26
  require_relative 'product/passport/passport_v1'
@@ -30,5 +29,6 @@ require_relative 'product/resume/resume_v1'
30
29
  require_relative 'product/universal/universal'
31
30
  require_relative 'product/us/bank_check/bank_check_v1'
32
31
  require_relative 'product/us/healthcare_card/healthcare_card_v1'
32
+ require_relative 'product/us/us_mail/us_mail_v2'
33
33
  require_relative 'product/us/us_mail/us_mail_v3'
34
34
  require_relative 'product/us/w9/w9_v1'
@@ -3,7 +3,7 @@
3
3
  # Mindee
4
4
  module Mindee
5
5
  # Current version.
6
- VERSION = '4.0.0'
6
+ VERSION = '4.1.2'
7
7
 
8
8
  # Finds and return the current platform.
9
9
  # @return [Symbol, Hash[Symbol | String, Regexp], Nil?]