From bb578bcdf3dffc307f8b3df0b3bb1506cfbe1f46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ianar=C3=A9=20S=C3=A9vi?= Date: Fri, 26 Sep 2025 12:44:42 +0200 Subject: [PATCH] :coffin: remove obsolete US Mail V2 --- .github/workflows/_publish-guide.yml | 14 +-- docs/code_samples/us_mail_v2_async.txt | 24 ---- lib/mindee/product.rb | 1 - lib/mindee/product/us/us_mail/us_mail_v2.rb | 47 -------- .../product/us/us_mail/us_mail_v2_document.rb | 105 ------------------ .../product/us/us_mail/us_mail_v2_page.rb | 38 ------- .../us_mail/us_mail_v2_recipient_address.rb | 105 ------------------ .../us_mail/us_mail_v2_recipient_addresses.rb | 63 ----------- .../us/us_mail/us_mail_v2_sender_address.rb | 66 ----------- sig/mindee/product/us/us_mail/us_mail_v2.rbs | 13 --- .../us/us_mail/us_mail_v2_document.rbs | 20 ---- .../product/us/us_mail/us_mail_v2_page.rbs | 17 --- .../us_mail/us_mail_v2_recipient_address.rbs | 22 ---- .../us_mail_v2_recipient_addresses.rbs | 15 --- .../us/us_mail/us_mail_v2_sender_address.rbs | 18 --- spec/product/us/us_mail_v2_spec.rb | 32 ------ 16 files changed, 3 insertions(+), 597 deletions(-) delete mode 100644 docs/code_samples/us_mail_v2_async.txt delete mode 100644 lib/mindee/product/us/us_mail/us_mail_v2.rb delete mode 100644 lib/mindee/product/us/us_mail/us_mail_v2_document.rb delete mode 100644 lib/mindee/product/us/us_mail/us_mail_v2_page.rb delete mode 100644 lib/mindee/product/us/us_mail/us_mail_v2_recipient_address.rb delete mode 100644 lib/mindee/product/us/us_mail/us_mail_v2_recipient_addresses.rb delete mode 100644 lib/mindee/product/us/us_mail/us_mail_v2_sender_address.rb delete mode 100644 sig/mindee/product/us/us_mail/us_mail_v2.rbs delete mode 100644 sig/mindee/product/us/us_mail/us_mail_v2_document.rbs delete mode 100644 sig/mindee/product/us/us_mail/us_mail_v2_page.rbs delete mode 100644 sig/mindee/product/us/us_mail/us_mail_v2_recipient_address.rbs delete mode 100644 sig/mindee/product/us/us_mail/us_mail_v2_recipient_addresses.rbs delete mode 100644 sig/mindee/product/us/us_mail/us_mail_v2_sender_address.rbs delete mode 100644 spec/product/us/us_mail_v2_spec.rb diff --git a/.github/workflows/_publish-guide.yml b/.github/workflows/_publish-guide.yml index c6ed92768..27f801a2c 100644 --- a/.github/workflows/_publish-guide.yml +++ b/.github/workflows/_publish-guide.yml @@ -1,4 +1,4 @@ -name: Publish Guide to readme.com +name: Publish Guide on: workflow_call: @@ -6,13 +6,5 @@ on: jobs: sync: - runs-on: ubuntu-latest - steps: - - name: Checkout this repo - uses: actions/checkout@v4 - - # Run GitHub Action to sync docs in `documentation` directory - - name: GitHub Action - uses: readmeio/rdme@v8 - with: - rdme: docs ./docs --key=${{ secrets.README_API_KEY }} --version=1.0 + uses: mindee/client-lib-actions/.github/workflows/publish-guide.yml@main + secrets: inherit diff --git a/docs/code_samples/us_mail_v2_async.txt b/docs/code_samples/us_mail_v2_async.txt deleted file mode 100644 index e0fe16424..000000000 --- a/docs/code_samples/us_mail_v2_async.txt +++ /dev/null @@ -1,24 +0,0 @@ -# -# Install the Ruby client library by running: -# gem install mindee -# - -require 'mindee' - -# Init a new client -mindee_client = Mindee::Client.new(api_key: 'my-api-key') - -# Load a file from disk -input_source = mindee_client.source_from_path('/path/to/the/file.ext') - -# Parse the file -result = mindee_client.parse( - input_source, - Mindee::Product::US::UsMail::UsMailV2 -) - -# Print a full summary of the parsed data in RST format -puts result.document - -# Print the document-level parsed data -# puts result.document.inference.prediction diff --git a/lib/mindee/product.rb b/lib/mindee/product.rb index 24f114626..489b76cee 100644 --- a/lib/mindee/product.rb +++ b/lib/mindee/product.rb @@ -29,5 +29,4 @@ require_relative 'product/universal/universal' require_relative 'product/us/bank_check/bank_check_v1' require_relative 'product/us/healthcare_card/healthcare_card_v1' -require_relative 'product/us/us_mail/us_mail_v2' require_relative 'product/us/us_mail/us_mail_v3' diff --git a/lib/mindee/product/us/us_mail/us_mail_v2.rb b/lib/mindee/product/us/us_mail/us_mail_v2.rb deleted file mode 100644 index d25acadac..000000000 --- a/lib/mindee/product/us/us_mail/us_mail_v2.rb +++ /dev/null @@ -1,47 +0,0 @@ -# frozen_string_literal: true - -require_relative '../../../parsing' -require_relative 'us_mail_v2_document' -require_relative 'us_mail_v2_page' - -module Mindee - module Product - module US - # US Mail module. - module UsMail - # US Mail API version 2 inference prediction. - class UsMailV2 < Mindee::Parsing::Common::Inference - @endpoint_name = 'us_mail' - @endpoint_version = '2' - @has_async = true - @has_sync = false - - # @param prediction [Hash] - def initialize(prediction) - super - @prediction = UsMailV2Document.new(prediction['prediction'], nil) - @pages = [] - prediction['pages'].each do |page| - @pages.push(UsMailV2Page.new(page)) - end - end - - class << self - # Name of the endpoint for this product. - # @return [String] - attr_reader :endpoint_name - # Version for this product. - # @return [String] - attr_reader :endpoint_version - # Whether this product has access to an asynchronous endpoint. - # @return [bool] - attr_reader :has_async - # Whether this product has access to synchronous endpoint. - # @return [bool] - attr_reader :has_sync - end - end - end - end - end -end diff --git a/lib/mindee/product/us/us_mail/us_mail_v2_document.rb b/lib/mindee/product/us/us_mail/us_mail_v2_document.rb deleted file mode 100644 index 29b9bd867..000000000 --- a/lib/mindee/product/us/us_mail/us_mail_v2_document.rb +++ /dev/null @@ -1,105 +0,0 @@ -# frozen_string_literal: true - -require_relative '../../../parsing' -require_relative 'us_mail_v2_sender_address' -require_relative 'us_mail_v2_recipient_addresses' - -module Mindee - module Product - module US - module UsMail - # US Mail API version 2.0 document data. - class UsMailV2Document < Mindee::Parsing::Common::Prediction - include Mindee::Parsing::Standard - # The addresses of the recipients. - # @return [Mindee::Product::US::UsMail::UsMailV2RecipientAddresses] - attr_reader :recipient_addresses - # The names of the recipients. - # @return [Array] - attr_reader :recipient_names - # The address of the sender. - # @return [Mindee::Product::US::UsMail::UsMailV2SenderAddress] - attr_reader :sender_address - # The name of the sender. - # @return [Mindee::Parsing::Standard::StringField] - attr_reader :sender_name - - # @param prediction [Hash] - # @param page_id [Integer, nil] - def initialize(prediction, page_id) - super - @recipient_addresses = Product::US::UsMail::UsMailV2RecipientAddresses.new( - prediction['recipient_addresses'], page_id - ) - @recipient_names = [] # : Array[Parsing::Standard::StringField] - prediction['recipient_names'].each do |item| - @recipient_names.push(Parsing::Standard::StringField.new(item, page_id)) - end - @sender_address = Product::US::UsMail::UsMailV2SenderAddress.new( - prediction['sender_address'], - page_id - ) - @sender_name = Parsing::Standard::StringField.new( - prediction['sender_name'], - page_id - ) - end - - # @return [String] - def to_s - sender_address = @sender_address.to_s - recipient_names = @recipient_names.join("\n #{' ' * 17}") - recipient_addresses = recipient_addresses_to_s - out_str = String.new - out_str << "\n:Sender Name: #{@sender_name}".rstrip - out_str << "\n:Sender Address:" - out_str << sender_address - out_str << "\n:Recipient Names: #{recipient_names}".rstrip - out_str << "\n:Recipient Addresses:" - out_str << recipient_addresses - out_str[1..].to_s - end - - private - - # @param char [String] - # @return [String] - def recipient_addresses_separator(char) - out_str = String.new - out_str << ' ' - out_str << "+#{char * 17}" - out_str << "+#{char * 37}" - out_str << "+#{char * 19}" - out_str << "+#{char * 13}" - out_str << "+#{char * 24}" - out_str << "+#{char * 7}" - out_str << "+#{char * 27}" - out_str << '+' - out_str - end - - # @return [String] - def recipient_addresses_to_s - return '' if @recipient_addresses.empty? - - line_items = @recipient_addresses.map(&:to_table_line).join("\n#{recipient_addresses_separator('-')}\n ") - out_str = String.new - out_str << "\n#{recipient_addresses_separator('-')}" - out_str << "\n |" - out_str << ' City |' - out_str << ' Complete Address |' - out_str << ' Is Address Change |' - out_str << ' Postal Code |' - out_str << ' Private Mailbox Number |' - out_str << ' State |' - out_str << ' Street |' - out_str << "\n#{recipient_addresses_separator('=')}" - out_str << "\n #{line_items}" - out_str << "\n#{recipient_addresses_separator('-')}" - out_str - end - end - end - end - end -end diff --git a/lib/mindee/product/us/us_mail/us_mail_v2_page.rb b/lib/mindee/product/us/us_mail/us_mail_v2_page.rb deleted file mode 100644 index b3d3596e0..000000000 --- a/lib/mindee/product/us/us_mail/us_mail_v2_page.rb +++ /dev/null @@ -1,38 +0,0 @@ -# frozen_string_literal: true - -require_relative '../../../parsing' -require_relative 'us_mail_v2_document' - -module Mindee - module Product - module US - module UsMail - # US Mail API version 2.0 page data. - class UsMailV2Page < Mindee::Parsing::Common::Page - # @param prediction [Hash] - def initialize(prediction) - super - @prediction = if prediction['prediction'].empty? - nil - else - UsMailV2PagePrediction.new( - prediction['prediction'], - prediction['id'] - ) - end - end - end - - # US Mail V2 page prediction. - class UsMailV2PagePrediction < UsMailV2Document - # @return [String] - def to_s - out_str = String.new - out_str << "\n#{super}" - out_str - end - end - end - end - end -end diff --git a/lib/mindee/product/us/us_mail/us_mail_v2_recipient_address.rb b/lib/mindee/product/us/us_mail/us_mail_v2_recipient_address.rb deleted file mode 100644 index 9248a52b1..000000000 --- a/lib/mindee/product/us/us_mail/us_mail_v2_recipient_address.rb +++ /dev/null @@ -1,105 +0,0 @@ -# frozen_string_literal: true - -require_relative '../../../parsing' - -module Mindee - module Product - module US - module UsMail - # The addresses of the recipients. - class UsMailV2RecipientAddress < Mindee::Parsing::Standard::FeatureField - include Mindee::Parsing::Standard - # The city of the recipient's address. - # @return [String] - attr_reader :city - # The complete address of the recipient. - # @return [String] - attr_reader :complete - # Indicates if the recipient's address is a change of address. - # @return [bool] - attr_reader :is_address_change - # The postal code of the recipient's address. - # @return [String] - attr_reader :postal_code - # The private mailbox number of the recipient's address. - # @return [String] - attr_reader :private_mailbox_number - # Second part of the ISO 3166-2 code, consisting of two letters indicating the US State. - # @return [String] - attr_reader :state - # The street of the recipient's address. - # @return [String] - attr_reader :street - - # @param prediction [Hash] - # @param page_id [Integer, nil] - def initialize(prediction, page_id) - super - @city = prediction['city'] - @complete = prediction['complete'] - @is_address_change = prediction['is_address_change'] - @postal_code = prediction['postal_code'] - @private_mailbox_number = prediction['private_mailbox_number'] - @state = prediction['state'] - @street = prediction['street'] - @page_id = page_id - end - - # @return [Hash] - def printable_values - printable = {} - printable[:city] = format_for_display(@city) - printable[:complete] = format_for_display(@complete) - printable[:is_address_change] = format_for_display(@is_address_change) - printable[:postal_code] = format_for_display(@postal_code) - printable[:private_mailbox_number] = format_for_display(@private_mailbox_number) - printable[:state] = format_for_display(@state) - printable[:street] = format_for_display(@street) - printable - end - - # @return [Hash] - def table_printable_values - printable = {} - printable[:city] = format_for_display(@city, 15) - printable[:complete] = format_for_display(@complete, 35) - printable[:is_address_change] = format_for_display(@is_address_change, nil) - printable[:postal_code] = format_for_display(@postal_code, nil) - printable[:private_mailbox_number] = format_for_display(@private_mailbox_number, nil) - printable[:state] = format_for_display(@state, nil) - printable[:street] = format_for_display(@street, 25) - printable - end - - # @return [String] - def to_table_line - printable = table_printable_values - out_str = String.new - out_str << format('| %- 16s', printable[:city]) - out_str << format('| %- 36s', printable[:complete]) - out_str << format('| %- 18s', printable[:is_address_change]) - out_str << format('| %- 12s', printable[:postal_code]) - out_str << format('| %- 23s', printable[:private_mailbox_number]) - out_str << format('| %- 6s', printable[:state]) - out_str << format('| %- 26s', printable[:street]) - out_str << '|' - end - - # @return [String] - def to_s - printable = printable_values - out_str = String.new - out_str << "\n :City: #{printable[:city]}" - out_str << "\n :Complete Address: #{printable[:complete]}" - out_str << "\n :Is Address Change: #{printable[:is_address_change]}" - out_str << "\n :Postal Code: #{printable[:postal_code]}" - out_str << "\n :Private Mailbox Number: #{printable[:private_mailbox_number]}" - out_str << "\n :State: #{printable[:state]}" - out_str << "\n :Street: #{printable[:street]}" - out_str - end - end - end - end - end -end diff --git a/lib/mindee/product/us/us_mail/us_mail_v2_recipient_addresses.rb b/lib/mindee/product/us/us_mail/us_mail_v2_recipient_addresses.rb deleted file mode 100644 index d6ef30ea4..000000000 --- a/lib/mindee/product/us/us_mail/us_mail_v2_recipient_addresses.rb +++ /dev/null @@ -1,63 +0,0 @@ -# frozen_string_literal: true - -require_relative 'us_mail_v2_sender_address' -require_relative 'us_mail_v2_recipient_address' - -module Mindee - module Product - module US - module UsMail - # The addresses of the recipients. - class UsMailV2RecipientAddresses < Array - # Entries. - # @return [Array] - attr_reader :entries - - # @param prediction [Array] - # @param page_id [Integer, nil] - def initialize(prediction, page_id) - entries = prediction.map do |entry| - UsMail::UsMailV2RecipientAddress.new(entry, page_id) - end - super(entries) - end - - # Creates a line of rST table-compliant string separators. - # @param char [String] Character to use as a separator. - # @return [String] - def self.line_items_separator(char) - out_str = String.new - out_str << "+#{char * 17}" - out_str << "+#{char * 37}" - out_str << "+#{char * 19}" - out_str << "+#{char * 13}" - out_str << "+#{char * 24}" - out_str << "+#{char * 7}" - out_str << "+#{char * 27}" - out_str - end - - # @return [String] - def to_s - return '' if empty? - - lines = map do |entry| - "\n #{entry.to_table_line}\n#{self.class.line_items_separator('-')}" - end.join - out_str = String.new - out_str << "\n#{self.class.line_items_separator('-')}\n " - out_str << ' | City ' - out_str << ' | Complete Address ' - out_str << ' | Is Address Change' - out_str << ' | Postal Code' - out_str << ' | Private Mailbox Number' - out_str << ' | State' - out_str << ' | Street ' - out_str << " |\n#{self.class.line_items_separator('=')}" - out_str + lines - end - end - end - end - end -end diff --git a/lib/mindee/product/us/us_mail/us_mail_v2_sender_address.rb b/lib/mindee/product/us/us_mail/us_mail_v2_sender_address.rb deleted file mode 100644 index 414390805..000000000 --- a/lib/mindee/product/us/us_mail/us_mail_v2_sender_address.rb +++ /dev/null @@ -1,66 +0,0 @@ -# frozen_string_literal: true - -require_relative '../../../parsing' - -module Mindee - module Product - module US - module UsMail - # The address of the sender. - class UsMailV2SenderAddress < Mindee::Parsing::Standard::FeatureField - include Mindee::Parsing::Standard - # The city of the sender's address. - # @return [String] - attr_reader :city - # The complete address of the sender. - # @return [String] - attr_reader :complete - # The postal code of the sender's address. - # @return [String] - attr_reader :postal_code - # Second part of the ISO 3166-2 code, consisting of two letters indicating the US State. - # @return [String] - attr_reader :state - # The street of the sender's address. - # @return [String] - attr_reader :street - - # @param prediction [Hash] - # @param page_id [Integer, nil] - def initialize(prediction, page_id) - super - @city = prediction['city'] - @complete = prediction['complete'] - @postal_code = prediction['postal_code'] - @state = prediction['state'] - @street = prediction['street'] - @page_id = page_id - end - - # @return [Hash] - def printable_values - printable = {} - printable[:city] = format_for_display(@city) - printable[:complete] = format_for_display(@complete) - printable[:postal_code] = format_for_display(@postal_code) - printable[:state] = format_for_display(@state) - printable[:street] = format_for_display(@street) - printable - end - - # @return [String] - def to_s - printable = printable_values - out_str = String.new - out_str << "\n :City: #{printable[:city]}" - out_str << "\n :Complete Address: #{printable[:complete]}" - out_str << "\n :Postal Code: #{printable[:postal_code]}" - out_str << "\n :State: #{printable[:state]}" - out_str << "\n :Street: #{printable[:street]}" - out_str - end - end - end - end - end -end diff --git a/sig/mindee/product/us/us_mail/us_mail_v2.rbs b/sig/mindee/product/us/us_mail/us_mail_v2.rbs deleted file mode 100644 index 7a15ab2e6..000000000 --- a/sig/mindee/product/us/us_mail/us_mail_v2.rbs +++ /dev/null @@ -1,13 +0,0 @@ -# lib/mindee/product/../us_mail/us_mail_v2.rb - -module Mindee - module Product - module US - module UsMail - class UsMailV2 < Parsing::Common::Inference - def initialize: (Hash[String | Symbol, untyped]) -> void - end - end - end - end -end diff --git a/sig/mindee/product/us/us_mail/us_mail_v2_document.rbs b/sig/mindee/product/us/us_mail/us_mail_v2_document.rbs deleted file mode 100644 index 9e47d1f1e..000000000 --- a/sig/mindee/product/us/us_mail/us_mail_v2_document.rbs +++ /dev/null @@ -1,20 +0,0 @@ -# lib/mindee/product/../us_mail/us_mail_v2_document.rb - -module Mindee - module Product - module US - module UsMail - class UsMailV2Document < Parsing::Common::Prediction - def initialize: (Hash[String | Symbol, untyped], Integer?) -> void - def recipient_addresses: -> (Product::US::UsMail::UsMailV2RecipientAddresses) - def recipient_names: -> (Array[Parsing::Standard::StringField]) - def sender_address: -> (Product::US::UsMail::UsMailV2SenderAddress) - def sender_name: -> (Parsing::Standard::StringField) - def recipient_addresses_separator: (String) -> String - def recipient_addresses_to_s: -> String - def to_s: -> String - end - end - end - end -end diff --git a/sig/mindee/product/us/us_mail/us_mail_v2_page.rbs b/sig/mindee/product/us/us_mail/us_mail_v2_page.rbs deleted file mode 100644 index 03e6f9884..000000000 --- a/sig/mindee/product/us/us_mail/us_mail_v2_page.rbs +++ /dev/null @@ -1,17 +0,0 @@ -# lib/mindee/product/../us_mail/us_mail_v2_page.rb - -module Mindee - module Product - module US - module UsMail - class UsMailV2Page < Parsing::Common::Page - def initialize: (Hash[String | Symbol, untyped]) -> void - end - class UsMailV2PagePrediction < UsMailV2Document - def initialize: (Hash[String | Symbol, untyped], Integer?) -> void - def to_s: -> String - end - end - end - end -end diff --git a/sig/mindee/product/us/us_mail/us_mail_v2_recipient_address.rbs b/sig/mindee/product/us/us_mail/us_mail_v2_recipient_address.rbs deleted file mode 100644 index 03885a4ec..000000000 --- a/sig/mindee/product/us/us_mail/us_mail_v2_recipient_address.rbs +++ /dev/null @@ -1,22 +0,0 @@ -module Mindee - module Product - module US - module UsMail - class UsMailV2RecipientAddress < Parsing::Standard::FeatureField - def initialize: (Hash[String | Symbol, untyped], Integer?) -> void - def city: -> String - def complete: -> String - def is_address_change: -> bool - def postal_code: -> String - def private_mailbox_number: -> String - def state: -> String - def street: -> String - def printable_values: -> Hash[String | Symbol, untyped] - def table_printable_values: -> Hash[String | Symbol, untyped] - def to_table_line: -> String - def to_s: -> String - end - end - end - end -end diff --git a/sig/mindee/product/us/us_mail/us_mail_v2_recipient_addresses.rbs b/sig/mindee/product/us/us_mail/us_mail_v2_recipient_addresses.rbs deleted file mode 100644 index 13f510027..000000000 --- a/sig/mindee/product/us/us_mail/us_mail_v2_recipient_addresses.rbs +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -module Mindee - module Product - module US - module UsMail - class UsMailV2RecipientAddresses < Array[UsMailV2RecipientAddress] - def initialize: (Array[untyped], Integer?) -> void - def self.line_items_separator: (String) -> String - def to_s: -> String - end - end - end - end -end diff --git a/sig/mindee/product/us/us_mail/us_mail_v2_sender_address.rbs b/sig/mindee/product/us/us_mail/us_mail_v2_sender_address.rbs deleted file mode 100644 index b6c4958fc..000000000 --- a/sig/mindee/product/us/us_mail/us_mail_v2_sender_address.rbs +++ /dev/null @@ -1,18 +0,0 @@ -module Mindee - module Product - module US - module UsMail - class UsMailV2SenderAddress < Parsing::Standard::FeatureField - def initialize: (Hash[String | Symbol, untyped], Integer?) -> void - def city: -> String - def complete: -> String - def postal_code: -> String - def state: -> String - def street: -> String - def printable_values: -> Hash[String | Symbol, untyped] - def to_s: -> String - end - end - end - end -end diff --git a/spec/product/us/us_mail_v2_spec.rb b/spec/product/us/us_mail_v2_spec.rb deleted file mode 100644 index c560b813f..000000000 --- a/spec/product/us/us_mail_v2_spec.rb +++ /dev/null @@ -1,32 +0,0 @@ -# frozen_string_literal: true - -require 'json' -require 'mindee/product' -require 'mindee/parsing' - -require_relative '../../data' - -DIR_US_US_MAIL_V2 = File.join(DATA_DIR, 'products', 'us_mail', 'response_v2').freeze - -describe Mindee::Product::US::UsMail::UsMailV2 do - context 'A US Mail V2' do - it 'should load an empty document prediction' do - response = load_json(DIR_US_US_MAIL_V2, 'empty.json') - inference = Mindee::Parsing::Common::Document.new( - Mindee::Product::US::UsMail::UsMailV2, - response['document'] - ).inference - expect(inference.product.type).to eq('standard') - end - - it 'should load a complete document prediction' do - to_string = read_file(DIR_US_US_MAIL_V2, 'summary_full.rst') - response = load_json(DIR_US_US_MAIL_V2, 'complete.json') - document = Mindee::Parsing::Common::Document.new( - Mindee::Product::US::UsMail::UsMailV2, - response['document'] - ) - expect(document.to_s).to eq(to_string) - end - end -end