mindee 3.12.0 → 3.13.0

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 (124) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +1 -1
  3. data/CHANGELOG.md +18 -0
  4. data/README.md +23 -23
  5. data/Rakefile +5 -0
  6. data/docs/bank_account_details_v2.md +5 -1
  7. data/docs/bank_check_v1.md +6 -2
  8. data/docs/bank_statement_fr_v1.md +3 -0
  9. data/docs/barcode_reader_v1.md +5 -1
  10. data/docs/bill_of_lading_v1.md +202 -0
  11. data/docs/carte_grise_v1.md +5 -1
  12. data/docs/carte_vitale_v1.md +5 -1
  13. data/docs/code_samples/bill_of_lading_v1_async.txt +19 -0
  14. data/docs/code_samples/energy_bill_fra_v1_async.txt +19 -0
  15. data/docs/code_samples/invoices_v4_async.txt +19 -0
  16. data/docs/code_samples/nutrition_facts_v1_async.txt +19 -0
  17. data/docs/code_samples/payslip_fra_v2_async.txt +19 -0
  18. data/docs/cropper_v1.md +6 -2
  19. data/docs/custom_v1.md +5 -3
  20. data/docs/energy_bill_fra_v1.md +249 -0
  21. data/docs/eu_driver_license_v1.md +6 -2
  22. data/docs/expense_receipts_v5.md +26 -1
  23. data/docs/financial_document_v1.md +29 -1
  24. data/docs/generated_v1.md +3 -0
  25. data/docs/getting_started.md +3 -0
  26. data/docs/idcard_fr_v2.md +15 -2
  27. data/docs/international_id_v2.md +13 -1
  28. data/docs/invoice_splitter_v1.md +16 -13
  29. data/docs/invoices_v4.md +54 -21
  30. data/docs/license_plates_v1.md +5 -1
  31. data/docs/multi_receipts_detector_v1.md +5 -1
  32. data/docs/nutrition_facts_v1.md +295 -0
  33. data/docs/passport_v1.md +5 -1
  34. data/docs/payslip_fra_v2.md +218 -0
  35. data/docs/proof_of_address_v1.md +5 -1
  36. data/docs/resume_v1.md +24 -1
  37. data/docs/us_driver_license_v1.md +6 -2
  38. data/docs/us_healthcare_cards_v1.md +5 -1
  39. data/docs/us_mail_v2.md +5 -1
  40. data/docs/us_w9_v1.md +6 -2
  41. data/examples/auto_invoice_splitter_extraction.rb +43 -0
  42. data/lib/mindee/client.rb +20 -8
  43. data/lib/mindee/{image_extraction → extraction}/common/image_extractor.rb +2 -4
  44. data/lib/mindee/{image_extraction → extraction}/common.rb +1 -0
  45. data/lib/mindee/extraction/pdf_extractor/extracted_pdf.rb +55 -0
  46. data/lib/mindee/extraction/pdf_extractor/pdf_extractor.rb +111 -0
  47. data/lib/mindee/extraction/pdf_extractor.rb +4 -0
  48. data/lib/mindee/extraction/tax_extractor/tax_extractor.rb +322 -0
  49. data/lib/mindee/extraction/tax_extractor.rb +1 -320
  50. data/lib/mindee/extraction.rb +3 -0
  51. data/lib/mindee/http/endpoint.rb +18 -6
  52. data/lib/mindee/parsing/common/api_response.rb +1 -1
  53. data/lib/mindee/parsing/common/document.rb +31 -1
  54. data/lib/mindee/parsing/common/extras/cropper_extra.rb +29 -0
  55. data/lib/mindee/parsing/common/extras/extras.rb +50 -0
  56. data/lib/mindee/parsing/common/extras/full_text_ocr_extra.rb +32 -0
  57. data/lib/mindee/parsing/common/extras.rb +5 -0
  58. data/lib/mindee/parsing/common/page.rb +5 -0
  59. data/lib/mindee/parsing/standard/base_field.rb +1 -0
  60. data/lib/mindee/product/bill_of_lading/bill_of_lading_v1.rb +39 -0
  61. data/lib/mindee/product/bill_of_lading/bill_of_lading_v1_carrier.rb +52 -0
  62. data/lib/mindee/product/bill_of_lading/bill_of_lading_v1_carrier_item.rb +95 -0
  63. data/lib/mindee/product/bill_of_lading/bill_of_lading_v1_consignee.rb +58 -0
  64. data/lib/mindee/product/bill_of_lading/bill_of_lading_v1_document.rb +136 -0
  65. data/lib/mindee/product/bill_of_lading/bill_of_lading_v1_notify_party.rb +58 -0
  66. data/lib/mindee/product/bill_of_lading/bill_of_lading_v1_page.rb +32 -0
  67. data/lib/mindee/product/bill_of_lading/bill_of_lading_v1_shipper.rb +58 -0
  68. data/lib/mindee/product/financial_document/financial_document_v1_line_item.rb +15 -1
  69. data/lib/mindee/product/fr/bank_account_details/bank_account_details_v2_bban.rb +4 -15
  70. data/lib/mindee/product/fr/energy_bill/energy_bill_v1.rb +41 -0
  71. data/lib/mindee/product/fr/energy_bill/energy_bill_v1_document.rb +235 -0
  72. data/lib/mindee/product/fr/energy_bill/energy_bill_v1_energy_consumer.rb +48 -0
  73. data/lib/mindee/product/fr/energy_bill/energy_bill_v1_energy_supplier.rb +48 -0
  74. data/lib/mindee/product/fr/energy_bill/energy_bill_v1_energy_usage.rb +97 -0
  75. data/lib/mindee/product/fr/energy_bill/energy_bill_v1_meter_detail.rb +54 -0
  76. data/lib/mindee/product/fr/energy_bill/energy_bill_v1_page.rb +34 -0
  77. data/lib/mindee/product/fr/energy_bill/energy_bill_v1_subscription.rb +97 -0
  78. data/lib/mindee/product/fr/energy_bill/energy_bill_v1_taxes_and_contribution.rb +97 -0
  79. data/lib/mindee/product/fr/payslip/payslip_v2.rb +41 -0
  80. data/lib/mindee/product/fr/payslip/payslip_v2_bank_account_detail.rb +54 -0
  81. data/lib/mindee/product/fr/payslip/payslip_v2_document.rb +128 -0
  82. data/lib/mindee/product/fr/payslip/payslip_v2_employee.rb +78 -0
  83. data/lib/mindee/product/fr/payslip/payslip_v2_employer.rb +78 -0
  84. data/lib/mindee/product/fr/payslip/payslip_v2_employment.rb +72 -0
  85. data/lib/mindee/product/fr/payslip/payslip_v2_page.rb +34 -0
  86. data/lib/mindee/product/fr/payslip/payslip_v2_pay_detail.rb +100 -0
  87. data/lib/mindee/product/fr/payslip/payslip_v2_pay_period.rb +66 -0
  88. data/lib/mindee/product/fr/payslip/payslip_v2_pto.rb +56 -0
  89. data/lib/mindee/product/fr/payslip/payslip_v2_salary_detail.rb +81 -0
  90. data/lib/mindee/product/invoice/invoice_v4_line_item.rb +15 -1
  91. data/lib/mindee/product/invoice_splitter/invoice_splitter_v1_document.rb +1 -1
  92. data/lib/mindee/product/nutrition_facts_label/nutrition_facts_label_v1.rb +39 -0
  93. data/lib/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_added_sugar.rb +52 -0
  94. data/lib/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_calorie.rb +52 -0
  95. data/lib/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_cholesterol.rb +52 -0
  96. data/lib/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_dietary_fiber.rb +52 -0
  97. data/lib/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_document.rb +173 -0
  98. data/lib/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_nutrient.rb +87 -0
  99. data/lib/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_page.rb +32 -0
  100. data/lib/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_protein.rb +52 -0
  101. data/lib/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_saturated_fat.rb +52 -0
  102. data/lib/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_serving_size.rb +46 -0
  103. data/lib/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_sodium.rb +58 -0
  104. data/lib/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_total_carbohydrate.rb +52 -0
  105. data/lib/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_total_fat.rb +52 -0
  106. data/lib/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_total_sugar.rb +52 -0
  107. data/lib/mindee/product/nutrition_facts_label/nutrition_facts_label_v1_trans_fat.rb +52 -0
  108. data/lib/mindee/product/receipt/receipt_v5_line_item.rb +11 -1
  109. data/lib/mindee/product/resume/resume_v1_certificate.rb +11 -1
  110. data/lib/mindee/product/resume/resume_v1_education.rb +14 -1
  111. data/lib/mindee/product/resume/resume_v1_language.rb +9 -1
  112. data/lib/mindee/product/resume/resume_v1_professional_experience.rb +15 -1
  113. data/lib/mindee/product/resume/resume_v1_social_networks_url.rb +9 -1
  114. data/lib/mindee/product/us/healthcare_card/healthcare_card_v1_copay.rb +9 -1
  115. data/lib/mindee/product/us/us_mail/us_mail_v2_recipient_address.rb +14 -1
  116. data/lib/mindee/product/us/us_mail/us_mail_v2_sender_address.rb +5 -17
  117. data/lib/mindee/product.rb +5 -1
  118. data/lib/mindee/version.rb +1 -1
  119. metadata +70 -9
  120. data/lib/mindee/image_extraction.rb +0 -4
  121. /data/lib/mindee/{image_extraction → extraction}/common/extracted_image.rb +0 -0
  122. /data/lib/mindee/{image_extraction → extraction}/multi_receipts_extractor/multi_receipts_extractor.rb +0 -0
  123. /data/lib/mindee/{image_extraction → extraction}/multi_receipts_extractor.rb +0 -0
  124. /data/lib/mindee/extraction/{ocr_extractor.rb → tax_extractor/ocr_extractor.rb} +0 -0
@@ -0,0 +1,52 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../../parsing'
4
+
5
+ module Mindee
6
+ module Product
7
+ module BillOfLading
8
+ # The shipping company responsible for transporting the goods.
9
+ class BillOfLadingV1Carrier < Mindee::Parsing::Standard::FeatureField
10
+ include Mindee::Parsing::Standard
11
+ # The name of the carrier.
12
+ # @return [String]
13
+ attr_reader :name
14
+ # The professional number of the carrier.
15
+ # @return [String]
16
+ attr_reader :professional_number
17
+ # The Standard Carrier Alpha Code (SCAC) of the carrier.
18
+ # @return [String]
19
+ attr_reader :scac
20
+
21
+ # @param prediction [Hash]
22
+ # @param page_id [Integer, nil]
23
+ def initialize(prediction, page_id)
24
+ super(prediction, page_id)
25
+ @name = prediction['name']
26
+ @professional_number = prediction['professional_number']
27
+ @scac = prediction['scac']
28
+ @page_id = page_id
29
+ end
30
+
31
+ # @return [Hash]
32
+ def printable_values
33
+ printable = {}
34
+ printable[:name] = format_for_display(@name)
35
+ printable[:professional_number] = format_for_display(@professional_number)
36
+ printable[:scac] = format_for_display(@scac)
37
+ printable
38
+ end
39
+
40
+ # @return [String]
41
+ def to_s
42
+ printable = printable_values
43
+ out_str = String.new
44
+ out_str << "\n :Name: #{printable[:name]}"
45
+ out_str << "\n :Professional Number: #{printable[:professional_number]}"
46
+ out_str << "\n :SCAC: #{printable[:scac]}"
47
+ out_str
48
+ end
49
+ end
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,95 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../../parsing'
4
+
5
+ module Mindee
6
+ module Product
7
+ module BillOfLading
8
+ # The goods being shipped.
9
+ class BillOfLadingV1CarrierItem < Mindee::Parsing::Standard::FeatureField
10
+ include Mindee::Parsing::Standard
11
+ # A description of the item.
12
+ # @return [String]
13
+ attr_reader :description
14
+ # The gross weight of the item.
15
+ # @return [Float]
16
+ attr_reader :gross_weight
17
+ # The measurement of the item.
18
+ # @return [Float]
19
+ attr_reader :measurement
20
+ # The unit of measurement for the measurement.
21
+ # @return [String]
22
+ attr_reader :measurement_unit
23
+ # The quantity of the item being shipped.
24
+ # @return [Float]
25
+ attr_reader :quantity
26
+ # The unit of measurement for weights.
27
+ # @return [String]
28
+ attr_reader :weight_unit
29
+
30
+ # @param prediction [Hash]
31
+ # @param page_id [Integer, nil]
32
+ def initialize(prediction, page_id)
33
+ super(prediction, page_id)
34
+ @description = prediction['description']
35
+ @gross_weight = prediction['gross_weight']
36
+ @measurement = prediction['measurement']
37
+ @measurement_unit = prediction['measurement_unit']
38
+ @quantity = prediction['quantity']
39
+ @weight_unit = prediction['weight_unit']
40
+ @page_id = page_id
41
+ end
42
+
43
+ # @return [Hash]
44
+ def printable_values
45
+ printable = {}
46
+ printable[:description] = format_for_display(@description)
47
+ printable[:gross_weight] = @gross_weight.nil? ? '' : Field.float_to_string(@gross_weight)
48
+ printable[:measurement] = @measurement.nil? ? '' : Field.float_to_string(@measurement)
49
+ printable[:measurement_unit] = format_for_display(@measurement_unit)
50
+ printable[:quantity] = @quantity.nil? ? '' : Field.float_to_string(@quantity)
51
+ printable[:weight_unit] = format_for_display(@weight_unit)
52
+ printable
53
+ end
54
+
55
+ # @return [Hash]
56
+ def table_printable_values
57
+ printable = {}
58
+ printable[:description] = format_for_display(@description, 36)
59
+ printable[:gross_weight] = @gross_weight.nil? ? '' : Field.float_to_string(@gross_weight)
60
+ printable[:measurement] = @measurement.nil? ? '' : Field.float_to_string(@measurement)
61
+ printable[:measurement_unit] = format_for_display(@measurement_unit, nil)
62
+ printable[:quantity] = @quantity.nil? ? '' : Field.float_to_string(@quantity)
63
+ printable[:weight_unit] = format_for_display(@weight_unit, nil)
64
+ printable
65
+ end
66
+
67
+ # @return [String]
68
+ def to_table_line
69
+ printable = table_printable_values
70
+ out_str = String.new
71
+ out_str << format('| %- 37s', printable[:description])
72
+ out_str << format('| %- 13s', printable[:gross_weight])
73
+ out_str << format('| %- 12s', printable[:measurement])
74
+ out_str << format('| %- 17s', printable[:measurement_unit])
75
+ out_str << format('| %- 9s', printable[:quantity])
76
+ out_str << format('| %- 12s', printable[:weight_unit])
77
+ out_str << '|'
78
+ end
79
+
80
+ # @return [String]
81
+ def to_s
82
+ printable = printable_values
83
+ out_str = String.new
84
+ out_str << "\n :Description: #{printable[:description]}"
85
+ out_str << "\n :Gross Weight: #{printable[:gross_weight]}"
86
+ out_str << "\n :Measurement: #{printable[:measurement]}"
87
+ out_str << "\n :Measurement Unit: #{printable[:measurement_unit]}"
88
+ out_str << "\n :Quantity: #{printable[:quantity]}"
89
+ out_str << "\n :Weight Unit: #{printable[:weight_unit]}"
90
+ out_str
91
+ end
92
+ end
93
+ end
94
+ end
95
+ end
@@ -0,0 +1,58 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../../parsing'
4
+
5
+ module Mindee
6
+ module Product
7
+ module BillOfLading
8
+ # The party to whom the goods are being shipped.
9
+ class BillOfLadingV1Consignee < Mindee::Parsing::Standard::FeatureField
10
+ include Mindee::Parsing::Standard
11
+ # The address of the consignee.
12
+ # @return [String]
13
+ attr_reader :address
14
+ # The email of the shipper.
15
+ # @return [String]
16
+ attr_reader :email
17
+ # The name of the consignee.
18
+ # @return [String]
19
+ attr_reader :name
20
+ # The phone number of the consignee.
21
+ # @return [String]
22
+ attr_reader :phone
23
+
24
+ # @param prediction [Hash]
25
+ # @param page_id [Integer, nil]
26
+ def initialize(prediction, page_id)
27
+ super(prediction, page_id)
28
+ @address = prediction['address']
29
+ @email = prediction['email']
30
+ @name = prediction['name']
31
+ @phone = prediction['phone']
32
+ @page_id = page_id
33
+ end
34
+
35
+ # @return [Hash]
36
+ def printable_values
37
+ printable = {}
38
+ printable[:address] = format_for_display(@address)
39
+ printable[:email] = format_for_display(@email)
40
+ printable[:name] = format_for_display(@name)
41
+ printable[:phone] = format_for_display(@phone)
42
+ printable
43
+ end
44
+
45
+ # @return [String]
46
+ def to_s
47
+ printable = printable_values
48
+ out_str = String.new
49
+ out_str << "\n :Address: #{printable[:address]}"
50
+ out_str << "\n :Email: #{printable[:email]}"
51
+ out_str << "\n :Name: #{printable[:name]}"
52
+ out_str << "\n :Phone: #{printable[:phone]}"
53
+ out_str
54
+ end
55
+ end
56
+ end
57
+ end
58
+ end
@@ -0,0 +1,136 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../../parsing'
4
+ require_relative 'bill_of_lading_v1_shipper'
5
+ require_relative 'bill_of_lading_v1_consignee'
6
+ require_relative 'bill_of_lading_v1_notify_party'
7
+ require_relative 'bill_of_lading_v1_carrier'
8
+ require_relative 'bill_of_lading_v1_carrier_item'
9
+
10
+ module Mindee
11
+ module Product
12
+ module BillOfLading
13
+ # Bill of Lading API version 1.1 document data.
14
+ class BillOfLadingV1Document < Mindee::Parsing::Common::Prediction
15
+ include Mindee::Parsing::Standard
16
+ # A unique identifier assigned to a Bill of Lading document.
17
+ # @return [Mindee::Parsing::Standard::StringField]
18
+ attr_reader :bill_of_lading_number
19
+ # The shipping company responsible for transporting the goods.
20
+ # @return [Mindee::Product::BillOfLading::BillOfLadingV1Carrier]
21
+ attr_reader :carrier
22
+ # The goods being shipped.
23
+ # @return [Array<Mindee::Product::BillOfLading::BillOfLadingV1CarrierItem>]
24
+ attr_reader :carrier_items
25
+ # The party to whom the goods are being shipped.
26
+ # @return [Mindee::Product::BillOfLading::BillOfLadingV1Consignee]
27
+ attr_reader :consignee
28
+ # The date when the bill of lading is issued.
29
+ # @return [Mindee::Parsing::Standard::DateField]
30
+ attr_reader :date_of_issue
31
+ # The date when the vessel departs from the port of loading.
32
+ # @return [Mindee::Parsing::Standard::DateField]
33
+ attr_reader :departure_date
34
+ # The party to be notified of the arrival of the goods.
35
+ # @return [Mindee::Product::BillOfLading::BillOfLadingV1NotifyParty]
36
+ attr_reader :notify_party
37
+ # The place where the goods are to be delivered.
38
+ # @return [Mindee::Parsing::Standard::StringField]
39
+ attr_reader :place_of_delivery
40
+ # The port where the goods are unloaded from the vessel.
41
+ # @return [Mindee::Parsing::Standard::StringField]
42
+ attr_reader :port_of_discharge
43
+ # The port where the goods are loaded onto the vessel.
44
+ # @return [Mindee::Parsing::Standard::StringField]
45
+ attr_reader :port_of_loading
46
+ # The party responsible for shipping the goods.
47
+ # @return [Mindee::Product::BillOfLading::BillOfLadingV1Shipper]
48
+ attr_reader :shipper
49
+
50
+ # @param prediction [Hash]
51
+ # @param page_id [Integer, nil]
52
+ def initialize(prediction, page_id)
53
+ super()
54
+ @bill_of_lading_number = StringField.new(prediction['bill_of_lading_number'], page_id)
55
+ @carrier = BillOfLadingV1Carrier.new(prediction['carrier'], page_id)
56
+ @carrier_items = []
57
+ prediction['carrier_items'].each do |item|
58
+ @carrier_items.push(BillOfLadingV1CarrierItem.new(item, page_id))
59
+ end
60
+ @consignee = BillOfLadingV1Consignee.new(prediction['consignee'], page_id)
61
+ @date_of_issue = DateField.new(prediction['date_of_issue'], page_id)
62
+ @departure_date = DateField.new(prediction['departure_date'], page_id)
63
+ @notify_party = BillOfLadingV1NotifyParty.new(prediction['notify_party'], page_id)
64
+ @place_of_delivery = StringField.new(prediction['place_of_delivery'], page_id)
65
+ @port_of_discharge = StringField.new(prediction['port_of_discharge'], page_id)
66
+ @port_of_loading = StringField.new(prediction['port_of_loading'], page_id)
67
+ @shipper = BillOfLadingV1Shipper.new(prediction['shipper'], page_id)
68
+ end
69
+
70
+ # @return [String]
71
+ def to_s
72
+ shipper = @shipper.to_s
73
+ consignee = @consignee.to_s
74
+ notify_party = @notify_party.to_s
75
+ carrier = @carrier.to_s
76
+ carrier_items = carrier_items_to_s
77
+ out_str = String.new
78
+ out_str << "\n:Bill of Lading Number: #{@bill_of_lading_number}".rstrip
79
+ out_str << "\n:Shipper:"
80
+ out_str << shipper
81
+ out_str << "\n:Consignee:"
82
+ out_str << consignee
83
+ out_str << "\n:Notify Party:"
84
+ out_str << notify_party
85
+ out_str << "\n:Carrier:"
86
+ out_str << carrier
87
+ out_str << "\n:Items:"
88
+ out_str << carrier_items
89
+ out_str << "\n:Port of Loading: #{@port_of_loading}".rstrip
90
+ out_str << "\n:Port of Discharge: #{@port_of_discharge}".rstrip
91
+ out_str << "\n:Place of Delivery: #{@place_of_delivery}".rstrip
92
+ out_str << "\n:Date of issue: #{@date_of_issue}".rstrip
93
+ out_str << "\n:Departure Date: #{@departure_date}".rstrip
94
+ out_str[1..].to_s
95
+ end
96
+
97
+ private
98
+
99
+ # @param char [String]
100
+ # @return [String]
101
+ def carrier_items_separator(char)
102
+ out_str = String.new
103
+ out_str << ' '
104
+ out_str << "+#{char * 38}"
105
+ out_str << "+#{char * 14}"
106
+ out_str << "+#{char * 13}"
107
+ out_str << "+#{char * 18}"
108
+ out_str << "+#{char * 10}"
109
+ out_str << "+#{char * 13}"
110
+ out_str << '+'
111
+ out_str
112
+ end
113
+
114
+ # @return [String]
115
+ def carrier_items_to_s
116
+ return '' if @carrier_items.empty?
117
+
118
+ line_items = @carrier_items.map(&:to_table_line).join("\n#{carrier_items_separator('-')}\n ")
119
+ out_str = String.new
120
+ out_str << "\n#{carrier_items_separator('-')}"
121
+ out_str << "\n |"
122
+ out_str << ' Description |'
123
+ out_str << ' Gross Weight |'
124
+ out_str << ' Measurement |'
125
+ out_str << ' Measurement Unit |'
126
+ out_str << ' Quantity |'
127
+ out_str << ' Weight Unit |'
128
+ out_str << "\n#{carrier_items_separator('=')}"
129
+ out_str << "\n #{line_items}"
130
+ out_str << "\n#{carrier_items_separator('-')}"
131
+ out_str
132
+ end
133
+ end
134
+ end
135
+ end
136
+ end
@@ -0,0 +1,58 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../../parsing'
4
+
5
+ module Mindee
6
+ module Product
7
+ module BillOfLading
8
+ # The party to be notified of the arrival of the goods.
9
+ class BillOfLadingV1NotifyParty < Mindee::Parsing::Standard::FeatureField
10
+ include Mindee::Parsing::Standard
11
+ # The address of the notify party.
12
+ # @return [String]
13
+ attr_reader :address
14
+ # The email of the shipper.
15
+ # @return [String]
16
+ attr_reader :email
17
+ # The name of the notify party.
18
+ # @return [String]
19
+ attr_reader :name
20
+ # The phone number of the notify party.
21
+ # @return [String]
22
+ attr_reader :phone
23
+
24
+ # @param prediction [Hash]
25
+ # @param page_id [Integer, nil]
26
+ def initialize(prediction, page_id)
27
+ super(prediction, page_id)
28
+ @address = prediction['address']
29
+ @email = prediction['email']
30
+ @name = prediction['name']
31
+ @phone = prediction['phone']
32
+ @page_id = page_id
33
+ end
34
+
35
+ # @return [Hash]
36
+ def printable_values
37
+ printable = {}
38
+ printable[:address] = format_for_display(@address)
39
+ printable[:email] = format_for_display(@email)
40
+ printable[:name] = format_for_display(@name)
41
+ printable[:phone] = format_for_display(@phone)
42
+ printable
43
+ end
44
+
45
+ # @return [String]
46
+ def to_s
47
+ printable = printable_values
48
+ out_str = String.new
49
+ out_str << "\n :Address: #{printable[:address]}"
50
+ out_str << "\n :Email: #{printable[:email]}"
51
+ out_str << "\n :Name: #{printable[:name]}"
52
+ out_str << "\n :Phone: #{printable[:phone]}"
53
+ out_str
54
+ end
55
+ end
56
+ end
57
+ end
58
+ end
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../../parsing'
4
+ require_relative 'bill_of_lading_v1_document'
5
+
6
+ module Mindee
7
+ module Product
8
+ module BillOfLading
9
+ # Bill of Lading API version 1.1 page data.
10
+ class BillOfLadingV1Page < Mindee::Parsing::Common::Page
11
+ # @param prediction [Hash]
12
+ def initialize(prediction)
13
+ super(prediction)
14
+ @prediction = BillOfLadingV1PagePrediction.new(
15
+ prediction['prediction'],
16
+ prediction['id']
17
+ )
18
+ end
19
+ end
20
+
21
+ # Bill of Lading V1 page prediction.
22
+ class BillOfLadingV1PagePrediction < BillOfLadingV1Document
23
+ # @return [String]
24
+ def to_s
25
+ out_str = String.new
26
+ out_str << "\n#{super}"
27
+ out_str
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,58 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../../parsing'
4
+
5
+ module Mindee
6
+ module Product
7
+ module BillOfLading
8
+ # The party responsible for shipping the goods.
9
+ class BillOfLadingV1Shipper < Mindee::Parsing::Standard::FeatureField
10
+ include Mindee::Parsing::Standard
11
+ # The address of the shipper.
12
+ # @return [String]
13
+ attr_reader :address
14
+ # The email of the shipper.
15
+ # @return [String]
16
+ attr_reader :email
17
+ # The name of the shipper.
18
+ # @return [String]
19
+ attr_reader :name
20
+ # The phone number of the shipper.
21
+ # @return [String]
22
+ attr_reader :phone
23
+
24
+ # @param prediction [Hash]
25
+ # @param page_id [Integer, nil]
26
+ def initialize(prediction, page_id)
27
+ super(prediction, page_id)
28
+ @address = prediction['address']
29
+ @email = prediction['email']
30
+ @name = prediction['name']
31
+ @phone = prediction['phone']
32
+ @page_id = page_id
33
+ end
34
+
35
+ # @return [Hash]
36
+ def printable_values
37
+ printable = {}
38
+ printable[:address] = format_for_display(@address)
39
+ printable[:email] = format_for_display(@email)
40
+ printable[:name] = format_for_display(@name)
41
+ printable[:phone] = format_for_display(@phone)
42
+ printable
43
+ end
44
+
45
+ # @return [String]
46
+ def to_s
47
+ printable = printable_values
48
+ out_str = String.new
49
+ out_str << "\n :Address: #{printable[:address]}"
50
+ out_str << "\n :Email: #{printable[:email]}"
51
+ out_str << "\n :Name: #{printable[:name]}"
52
+ out_str << "\n :Phone: #{printable[:phone]}"
53
+ out_str
54
+ end
55
+ end
56
+ end
57
+ end
58
+ end
@@ -50,6 +50,20 @@ module Mindee
50
50
 
51
51
  # @return [Hash]
52
52
  def printable_values
53
+ printable = {}
54
+ printable[:description] = format_for_display(@description)
55
+ printable[:product_code] = format_for_display(@product_code)
56
+ printable[:quantity] = @quantity.nil? ? '' : Field.float_to_string(@quantity)
57
+ printable[:tax_amount] = @tax_amount.nil? ? '' : Field.float_to_string(@tax_amount)
58
+ printable[:tax_rate] = @tax_rate.nil? ? '' : Field.float_to_string(@tax_rate)
59
+ printable[:total_amount] = @total_amount.nil? ? '' : Field.float_to_string(@total_amount)
60
+ printable[:unit_measure] = format_for_display(@unit_measure)
61
+ printable[:unit_price] = @unit_price.nil? ? '' : Field.float_to_string(@unit_price)
62
+ printable
63
+ end
64
+
65
+ # @return [Hash]
66
+ def table_printable_values
53
67
  printable = {}
54
68
  printable[:description] = format_for_display(@description, 36)
55
69
  printable[:product_code] = format_for_display(@product_code, nil)
@@ -64,7 +78,7 @@ module Mindee
64
78
 
65
79
  # @return [String]
66
80
  def to_table_line
67
- printable = printable_values
81
+ printable = table_printable_values
68
82
  out_str = String.new
69
83
  out_str << format('| %- 37s', printable[:description])
70
84
  out_str << format('| %- 13s', printable[:product_code])
@@ -36,24 +36,13 @@ module Mindee
36
36
  # @return [Hash]
37
37
  def printable_values
38
38
  printable = {}
39
- printable[:bban_bank_code] = format_for_display(@bban_bank_code, nil)
40
- printable[:bban_branch_code] = format_for_display(@bban_branch_code, nil)
41
- printable[:bban_key] = format_for_display(@bban_key, nil)
42
- printable[:bban_number] = format_for_display(@bban_number, nil)
39
+ printable[:bban_bank_code] = format_for_display(@bban_bank_code)
40
+ printable[:bban_branch_code] = format_for_display(@bban_branch_code)
41
+ printable[:bban_key] = format_for_display(@bban_key)
42
+ printable[:bban_number] = format_for_display(@bban_number)
43
43
  printable
44
44
  end
45
45
 
46
- # @return [String]
47
- def to_table_line
48
- printable = printable_values
49
- out_str = String.new
50
- out_str << format('| %- 10s', printable[:bban_bank_code])
51
- out_str << format('| %- 12s', printable[:bban_branch_code])
52
- out_str << format('| %- 4s', printable[:bban_key])
53
- out_str << format('| %- 15s', printable[:bban_number])
54
- out_str << '|'
55
- end
56
-
57
46
  # @return [String]
58
47
  def to_s
59
48
  printable = printable_values
@@ -0,0 +1,41 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../../../parsing'
4
+ require_relative 'energy_bill_v1_document'
5
+ require_relative 'energy_bill_v1_page'
6
+
7
+ module Mindee
8
+ module Product
9
+ module FR
10
+ # Energy Bill module.
11
+ module EnergyBill
12
+ # Energy Bill API version 1 inference prediction.
13
+ class EnergyBillV1 < Mindee::Parsing::Common::Inference
14
+ @endpoint_name = 'energy_bill_fra'
15
+ @endpoint_version = '1'
16
+
17
+ # @param prediction [Hash]
18
+ def initialize(prediction)
19
+ super
20
+ @prediction = EnergyBillV1Document.new(prediction['prediction'], nil)
21
+ @pages = []
22
+ prediction['pages'].each do |page|
23
+ if page.key?('prediction') && !page['prediction'].nil? && !page['prediction'].empty?
24
+ @pages.push(EnergyBillV1Page.new(page))
25
+ end
26
+ end
27
+ end
28
+
29
+ class << self
30
+ # Name of the endpoint for this product.
31
+ # @return [String]
32
+ attr_reader :endpoint_name
33
+ # Version for this product.
34
+ # @return [String]
35
+ attr_reader :endpoint_version
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end