mindee 3.18.0 → 3.19.1
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.
- checksums.yaml +4 -4
 - data/CHANGELOG.md +11 -0
 - data/README.md +48 -0
 - data/docs/code_samples/us_mail_v3_async.txt +19 -0
 - data/docs/{us_mail_v2.md → us_mail_v3.md} +34 -12
 - data/lib/mindee/client.rb +2 -2
 - data/lib/mindee/parsing/common/document.rb +1 -2
 - data/lib/mindee/parsing/standard/boolean_field.rb +6 -0
 - data/lib/mindee/product/ind/indian_passport/indian_passport_v1_document.rb +1 -1
 - data/lib/mindee/product/ind/indian_passport/indian_passport_v1_page.rb +1 -1
 - data/lib/mindee/product/us/us_mail/us_mail_v3.rb +41 -0
 - data/lib/mindee/product/us/us_mail/us_mail_v3_document.rb +107 -0
 - data/lib/mindee/product/us/us_mail/us_mail_v3_page.rb +34 -0
 - data/lib/mindee/product/us/us_mail/us_mail_v3_recipient_address.rb +113 -0
 - data/lib/mindee/product/us/us_mail/us_mail_v3_sender_address.rb +66 -0
 - data/lib/mindee/product.rb +1 -0
 - data/lib/mindee/version.rb +1 -1
 - metadata +12 -6
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA256:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: bca81cfda2aa389c5892c16d68e78cb3204a029fe21265180e3de2478a6f8054
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 3004a181239a458018f90258efe35940d1c466a890f92d7f221248970a13a3eb
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: a2482ecc51f3259b7ffd0b45c4239ef42ba961a83c8c93bc50fe60503857e033d5397dc41ee3fb1defbcb5320ebb134a6aeba7c8b4ba31fa6255f5c7f95b632c
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 6f3d4b075a60c4e9ca8d01b5474568c4799df6584dc777b74489d2228d2c14d0009eca9def8f3ddda7e07527ab6fb79e80b6e9bee996025516a54256b0846b49
         
     | 
    
        data/CHANGELOG.md
    CHANGED
    
    | 
         @@ -1,5 +1,16 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            # Mindee Ruby API Library Changelog
         
     | 
| 
       2 
2 
     | 
    
         | 
| 
      
 3 
     | 
    
         
            +
            ## v3.19.1 - 2025-01-21
         
     | 
| 
      
 4 
     | 
    
         
            +
            ### Changes
         
     | 
| 
      
 5 
     | 
    
         
            +
            * :bug: fix extras failing at document level if missing from prediction
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
            ## v3.19.0 - 2025-01-14
         
     | 
| 
      
 9 
     | 
    
         
            +
            ### Changes
         
     | 
| 
      
 10 
     | 
    
         
            +
            * :sparkles: add support for US Mail V3
         
     | 
| 
      
 11 
     | 
    
         
            +
            * :recycle: increase async retry timers
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
       3 
14 
     | 
    
         
             
            ## v3.18.0 - 2024-12-13
         
     | 
| 
       4 
15 
     | 
    
         
             
            ### Changes
         
     | 
| 
       5 
16 
     | 
    
         
             
            * :sparkles: allow local downloading of remote sources
         
     | 
    
        data/README.md
    CHANGED
    
    | 
         @@ -162,6 +162,54 @@ Using the ruby bundler: 
     | 
|
| 
       162 
162 
     | 
    
         
             
            bundle exec ruby ./bin/mindee.rb invoice path/to/your/file.ext
         
     | 
| 
       163 
163 
     | 
    
         
             
            ```
         
     | 
| 
       164 
164 
     | 
    
         | 
| 
      
 165 
     | 
    
         
            +
             
     | 
| 
      
 166 
     | 
    
         
            +
            ### Enqueue and Parse a Webhook Response
         
     | 
| 
      
 167 
     | 
    
         
            +
            This is an optional way of handling asynchronous APIs.
         
     | 
| 
      
 168 
     | 
    
         
            +
             
     | 
| 
      
 169 
     | 
    
         
            +
            ```rb
         
     | 
| 
      
 170 
     | 
    
         
            +
            require 'mindee'
         
     | 
| 
      
 171 
     | 
    
         
            +
             
     | 
| 
      
 172 
     | 
    
         
            +
            # Init a new client
         
     | 
| 
      
 173 
     | 
    
         
            +
            mindee_client = Mindee::Client.new(api_key: 'my-api-key')
         
     | 
| 
      
 174 
     | 
    
         
            +
             
     | 
| 
      
 175 
     | 
    
         
            +
            # Load a file from disk
         
     | 
| 
      
 176 
     | 
    
         
            +
            input_source = mindee_client.source_from_path('/path/to/the/file.ext')
         
     | 
| 
      
 177 
     | 
    
         
            +
             
     | 
| 
      
 178 
     | 
    
         
            +
             
     | 
| 
      
 179 
     | 
    
         
            +
            # Parse the file
         
     | 
| 
      
 180 
     | 
    
         
            +
            enqueue_response = mindee_client.enqueue(
         
     | 
| 
      
 181 
     | 
    
         
            +
              input_source,
         
     | 
| 
      
 182 
     | 
    
         
            +
              Mindee::Product::InternationalId::InternationalIdV2
         
     | 
| 
      
 183 
     | 
    
         
            +
            )
         
     | 
| 
      
 184 
     | 
    
         
            +
             
     | 
| 
      
 185 
     | 
    
         
            +
            job_id = enqueue_response.job.id
         
     | 
| 
      
 186 
     | 
    
         
            +
             
     | 
| 
      
 187 
     | 
    
         
            +
            # Load the JSON string sent by the Mindee webhook POST callback.
         
     | 
| 
      
 188 
     | 
    
         
            +
            # Reading the callback data will vary greatly depending on your HTTP server.
         
     | 
| 
      
 189 
     | 
    
         
            +
            # This is therefore beyond the scope of this example.
         
     | 
| 
      
 190 
     | 
    
         
            +
             
     | 
| 
      
 191 
     | 
    
         
            +
            local_response = Mindee::Input::LocalResponse.new(request.body.string)
         
     | 
| 
      
 192 
     | 
    
         
            +
             
     | 
| 
      
 193 
     | 
    
         
            +
            # You can also use a File object as the input.
         
     | 
| 
      
 194 
     | 
    
         
            +
            # FILE_PATH = File.join('path', 'to', 'file.json').freeze
         
     | 
| 
      
 195 
     | 
    
         
            +
            # local_response = Mindee::Input::LocalResponse.new(FILE_PATH);
         
     | 
| 
      
 196 
     | 
    
         
            +
             
     | 
| 
      
 197 
     | 
    
         
            +
            # Optional: verify the HMAC signature.
         
     | 
| 
      
 198 
     | 
    
         
            +
            unless local_response.valid_hmac_signature?(my_secret_key, 'invalid signature')
         
     | 
| 
      
 199 
     | 
    
         
            +
              raise "Invalid HMAC signature!"
         
     | 
| 
      
 200 
     | 
    
         
            +
            end
         
     | 
| 
      
 201 
     | 
    
         
            +
             
     | 
| 
      
 202 
     | 
    
         
            +
             
     | 
| 
      
 203 
     | 
    
         
            +
            # Deserialize the response:
         
     | 
| 
      
 204 
     | 
    
         
            +
            result = mindee_client.load_prediction(
         
     | 
| 
      
 205 
     | 
    
         
            +
                    Mindee::Product::InternationalId::InternationalIdV2,
         
     | 
| 
      
 206 
     | 
    
         
            +
                    local_response
         
     | 
| 
      
 207 
     | 
    
         
            +
            )
         
     | 
| 
      
 208 
     | 
    
         
            +
             
     | 
| 
      
 209 
     | 
    
         
            +
            # Print a full summary of the parsed data in RST format
         
     | 
| 
      
 210 
     | 
    
         
            +
            puts result.document
         
     | 
| 
      
 211 
     | 
    
         
            +
            ```
         
     | 
| 
      
 212 
     | 
    
         
            +
             
     | 
| 
       165 
213 
     | 
    
         
             
            ## Further Reading
         
     | 
| 
       166 
214 
     | 
    
         | 
| 
       167 
215 
     | 
    
         
             
            There's more to it than that for those that need more features, or want to
         
     | 
| 
         @@ -0,0 +1,19 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'mindee'
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            # Init a new client
         
     | 
| 
      
 4 
     | 
    
         
            +
            mindee_client = Mindee::Client.new(api_key: 'my-api-key')
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
            # Load a file from disk
         
     | 
| 
      
 7 
     | 
    
         
            +
            input_source = mindee_client.source_from_path('/path/to/the/file.ext')
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
            # Parse the file
         
     | 
| 
      
 10 
     | 
    
         
            +
            result = mindee_client.enqueue_and_parse(
         
     | 
| 
      
 11 
     | 
    
         
            +
              input_source,
         
     | 
| 
      
 12 
     | 
    
         
            +
              Mindee::Product::US::UsMail::UsMailV3
         
     | 
| 
      
 13 
     | 
    
         
            +
            )
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
      
 15 
     | 
    
         
            +
            # Print a full summary of the parsed data in RST format
         
     | 
| 
      
 16 
     | 
    
         
            +
            puts result.document
         
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
            # Print the document-level parsed data
         
     | 
| 
      
 19 
     | 
    
         
            +
            # puts result.document.inference.prediction
         
     | 
| 
         @@ -22,7 +22,7 @@ input_source = mindee_client.source_from_path('/path/to/the/file.ext') 
     | 
|
| 
       22 
22 
     | 
    
         
             
            # Parse the file
         
     | 
| 
       23 
23 
     | 
    
         
             
            result = mindee_client.enqueue_and_parse(
         
     | 
| 
       24 
24 
     | 
    
         
             
              input_source,
         
     | 
| 
       25 
     | 
    
         
            -
              Mindee::Product::US::UsMail:: 
     | 
| 
      
 25 
     | 
    
         
            +
              Mindee::Product::US::UsMail::UsMailV3
         
     | 
| 
       26 
26 
     | 
    
         
             
            )
         
     | 
| 
       27 
27 
     | 
    
         | 
| 
       28 
28 
     | 
    
         
             
            # Print a full summary of the parsed data in RST format
         
     | 
| 
         @@ -35,7 +35,20 @@ puts result.document 
     | 
|
| 
       35 
35 
     | 
    
         | 
| 
       36 
36 
     | 
    
         
             
            **Output (RST):**
         
     | 
| 
       37 
37 
     | 
    
         
             
            ```rst
         
     | 
| 
       38 
     | 
    
         
            -
             
     | 
| 
      
 38 
     | 
    
         
            +
            ########
         
     | 
| 
      
 39 
     | 
    
         
            +
            Document
         
     | 
| 
      
 40 
     | 
    
         
            +
            ########
         
     | 
| 
      
 41 
     | 
    
         
            +
            :Mindee ID: f9c36f59-977d-4ddc-9f2d-31c294c456ac
         
     | 
| 
      
 42 
     | 
    
         
            +
            :Filename: default_sample.jpg
         
     | 
| 
      
 43 
     | 
    
         
            +
             
     | 
| 
      
 44 
     | 
    
         
            +
            Inference
         
     | 
| 
      
 45 
     | 
    
         
            +
            #########
         
     | 
| 
      
 46 
     | 
    
         
            +
            :Product: mindee/us_mail v3.0
         
     | 
| 
      
 47 
     | 
    
         
            +
            :Rotation applied: Yes
         
     | 
| 
      
 48 
     | 
    
         
            +
             
     | 
| 
      
 49 
     | 
    
         
            +
            Prediction
         
     | 
| 
      
 50 
     | 
    
         
            +
            ==========
         
     | 
| 
      
 51 
     | 
    
         
            +
            :Sender Name: company zed
         
     | 
| 
       39 
52 
     | 
    
         
             
            :Sender Address:
         
     | 
| 
       40 
53 
     | 
    
         
             
              :City: Dallas
         
     | 
| 
       41 
54 
     | 
    
         
             
              :Complete Address: 54321 Elm Street, Dallas, Texas 54321
         
     | 
| 
         @@ -44,11 +57,12 @@ puts result.document 
     | 
|
| 
       44 
57 
     | 
    
         
             
              :Street: 54321 Elm Street
         
     | 
| 
       45 
58 
     | 
    
         
             
            :Recipient Names: Jane Doe
         
     | 
| 
       46 
59 
     | 
    
         
             
            :Recipient Addresses:
         
     | 
| 
       47 
     | 
    
         
            -
               
     | 
| 
       48 
     | 
    
         
            -
              | City            | Complete Address                    | Is Address Change | Postal Code | Private Mailbox Number | State | Street                    |
         
     | 
| 
       49 
     | 
    
         
            -
               
     | 
| 
       50 
     | 
    
         
            -
              | Detroit         | 1234 Market Street PMB 4321, Det... | 
     | 
| 
       51 
     | 
    
         
            -
               
     | 
| 
      
 60 
     | 
    
         
            +
              +-----------------+-------------------------------------+-------------------+-------------+------------------------+-------+---------------------------+-----------------+
         
     | 
| 
      
 61 
     | 
    
         
            +
              | City            | Complete Address                    | Is Address Change | Postal Code | Private Mailbox Number | State | Street                    | Unit            |
         
     | 
| 
      
 62 
     | 
    
         
            +
              +=================+=====================================+===================+=============+========================+=======+===========================+=================+
         
     | 
| 
      
 63 
     | 
    
         
            +
              | Detroit         | 1234 Market Street PMB 4321, Det... | False             | 12345       | 4321                   | MI    | 1234 Market Street        |                 |
         
     | 
| 
      
 64 
     | 
    
         
            +
              +-----------------+-------------------------------------+-------------------+-------------+------------------------+-------+---------------------------+-----------------+
         
     | 
| 
      
 65 
     | 
    
         
            +
            :Return to Sender: False
         
     | 
| 
       52 
66 
     | 
    
         
             
            ```
         
     | 
| 
       53 
67 
     | 
    
         | 
| 
       54 
68 
     | 
    
         
             
            # Field Types
         
     | 
| 
         @@ -78,7 +92,7 @@ Fields which are specific to this product; they are not used in any other produc 
     | 
|
| 
       78 
92 
     | 
    
         
             
            ### Recipient Addresses Field
         
     | 
| 
       79 
93 
     | 
    
         
             
            The addresses of the recipients.
         
     | 
| 
       80 
94 
     | 
    
         | 
| 
       81 
     | 
    
         
            -
            A ` 
     | 
| 
      
 95 
     | 
    
         
            +
            A `UsMailV3RecipientAddress` implements the following attributes:
         
     | 
| 
       82 
96 
     | 
    
         | 
| 
       83 
97 
     | 
    
         
             
            * `city` (String): The city of the recipient's address.
         
     | 
| 
       84 
98 
     | 
    
         
             
            * `complete` (String): The complete address of the recipient.
         
     | 
| 
         @@ -87,12 +101,13 @@ A `UsMailV2RecipientAddress` implements the following attributes: 
     | 
|
| 
       87 
101 
     | 
    
         
             
            * `private_mailbox_number` (String): The private mailbox number of the recipient's address.
         
     | 
| 
       88 
102 
     | 
    
         
             
            * `state` (String): Second part of the ISO 3166-2 code, consisting of two letters indicating the US State.
         
     | 
| 
       89 
103 
     | 
    
         
             
            * `street` (String): The street of the recipient's address.
         
     | 
| 
      
 104 
     | 
    
         
            +
            * `unit` (String): The unit number of the recipient's address.
         
     | 
| 
       90 
105 
     | 
    
         
             
            Fields which are specific to this product; they are not used in any other product.
         
     | 
| 
       91 
106 
     | 
    
         | 
| 
       92 
107 
     | 
    
         
             
            ### Sender Address Field
         
     | 
| 
       93 
108 
     | 
    
         
             
            The address of the sender.
         
     | 
| 
       94 
109 
     | 
    
         | 
| 
       95 
     | 
    
         
            -
            A ` 
     | 
| 
      
 110 
     | 
    
         
            +
            A `UsMailV3SenderAddress` implements the following attributes:
         
     | 
| 
       96 
111 
     | 
    
         | 
| 
       97 
112 
     | 
    
         
             
            * `city` (String): The city of the sender's address.
         
     | 
| 
       98 
113 
     | 
    
         
             
            * `complete` (String): The complete address of the sender.
         
     | 
| 
         @@ -101,10 +116,17 @@ A `UsMailV2SenderAddress` implements the following attributes: 
     | 
|
| 
       101 
116 
     | 
    
         
             
            * `street` (String): The street of the sender's address.
         
     | 
| 
       102 
117 
     | 
    
         | 
| 
       103 
118 
     | 
    
         
             
            # Attributes
         
     | 
| 
       104 
     | 
    
         
            -
            The following fields are extracted for US Mail  
     | 
| 
      
 119 
     | 
    
         
            +
            The following fields are extracted for US Mail V3:
         
     | 
| 
      
 120 
     | 
    
         
            +
             
     | 
| 
      
 121 
     | 
    
         
            +
            ## Return to Sender
         
     | 
| 
      
 122 
     | 
    
         
            +
            **is_return_to_sender** ([BooleanField](#boolean-field)): Whether the mailing is marked as return to sender.
         
     | 
| 
      
 123 
     | 
    
         
            +
             
     | 
| 
      
 124 
     | 
    
         
            +
            ```rb
         
     | 
| 
      
 125 
     | 
    
         
            +
            puts result.document.inference.prediction.is_return_to_sender.value
         
     | 
| 
      
 126 
     | 
    
         
            +
            ```
         
     | 
| 
       105 
127 
     | 
    
         | 
| 
       106 
128 
     | 
    
         
             
            ## Recipient Addresses
         
     | 
| 
       107 
     | 
    
         
            -
            **recipient_addresses** (Array<[ 
     | 
| 
      
 129 
     | 
    
         
            +
            **recipient_addresses** (Array<[UsMailV3RecipientAddress](#recipient-addresses-field)>): The addresses of the recipients.
         
     | 
| 
       108 
130 
     | 
    
         | 
| 
       109 
131 
     | 
    
         
             
            ```rb
         
     | 
| 
       110 
132 
     | 
    
         
             
            for recipient_addresses_elem in result.document.inference.prediction.recipient_addresses do
         
     | 
| 
         @@ -122,7 +144,7 @@ end 
     | 
|
| 
       122 
144 
     | 
    
         
             
            ```
         
     | 
| 
       123 
145 
     | 
    
         | 
| 
       124 
146 
     | 
    
         
             
            ## Sender Address
         
     | 
| 
       125 
     | 
    
         
            -
            **sender_address** ([ 
     | 
| 
      
 147 
     | 
    
         
            +
            **sender_address** ([UsMailV3SenderAddress](#sender-address-field)): The address of the sender.
         
     | 
| 
       126 
148 
     | 
    
         | 
| 
       127 
149 
     | 
    
         
             
            ```rb
         
     | 
| 
       128 
150 
     | 
    
         
             
            puts result.document.inference.prediction.sender_address.value
         
     | 
    
        data/lib/mindee/client.rb
    CHANGED
    
    | 
         @@ -151,7 +151,7 @@ module Mindee 
     | 
|
| 
       151 
151 
     | 
    
         
             
                #  This performs a cropping operation on the server and will increase response time.
         
     | 
| 
       152 
152 
     | 
    
         
             
                # @param initial_delay_sec [Integer, Float] initial delay before polling. Defaults to 2.
         
     | 
| 
       153 
153 
     | 
    
         
             
                # @param delay_sec [Integer, Float] delay between polling attempts. Defaults to 1.5.
         
     | 
| 
       154 
     | 
    
         
            -
                # @param max_retries [Integer] maximum amount of retries. Defaults to  
     | 
| 
      
 154 
     | 
    
         
            +
                # @param max_retries [Integer] maximum amount of retries. Defaults to 80.
         
     | 
| 
       155 
155 
     | 
    
         
             
                # @return [Mindee::Parsing::Common::ApiResponse]
         
     | 
| 
       156 
156 
     | 
    
         
             
                def enqueue_and_parse(
         
     | 
| 
       157 
157 
     | 
    
         
             
                  input_source,
         
     | 
| 
         @@ -164,7 +164,7 @@ module Mindee 
     | 
|
| 
       164 
164 
     | 
    
         
             
                  cropper: false,
         
     | 
| 
       165 
165 
     | 
    
         
             
                  initial_delay_sec: 2,
         
     | 
| 
       166 
166 
     | 
    
         
             
                  delay_sec: 1.5,
         
     | 
| 
       167 
     | 
    
         
            -
                  max_retries:  
     | 
| 
      
 167 
     | 
    
         
            +
                  max_retries: 80
         
     | 
| 
       168 
168 
     | 
    
         
             
                )
         
     | 
| 
       169 
169 
     | 
    
         
             
                  enqueue_res = enqueue(
         
     | 
| 
       170 
170 
     | 
    
         
             
                    input_source,
         
     | 
| 
         @@ -61,8 +61,7 @@ module Mindee 
     | 
|
| 
       61 
61 
     | 
    
         
             
                    private
         
     | 
| 
       62 
62 
     | 
    
         | 
| 
       63 
63 
     | 
    
         
             
                    def inject_full_text_ocr(raw_prediction)
         
     | 
| 
       64 
     | 
    
         
            -
                      return unless raw_prediction.dig('inference', 'pages') 
     | 
| 
       65 
     | 
    
         
            -
                                    raw_prediction['inference']['pages'][0]['extras']['full_text_ocr']
         
     | 
| 
      
 64 
     | 
    
         
            +
                      return unless raw_prediction.dig('inference', 'pages', 0, 'extras', 'full_text_ocr')
         
     | 
| 
       66 
65 
     | 
    
         | 
| 
       67 
66 
     | 
    
         
             
                      full_text_ocr = String.new
         
     | 
| 
       68 
67 
     | 
    
         
             
                      raw_prediction.dig('inference', 'pages').each do |page|
         
     | 
| 
         @@ -6,7 +6,7 @@ module Mindee 
     | 
|
| 
       6 
6 
     | 
    
         
             
              module Product
         
     | 
| 
       7 
7 
     | 
    
         
             
                module IND
         
     | 
| 
       8 
8 
     | 
    
         
             
                  module IndianPassport
         
     | 
| 
       9 
     | 
    
         
            -
                    # Passport - India API version 1. 
     | 
| 
      
 9 
     | 
    
         
            +
                    # Passport - India API version 1.2 document data.
         
     | 
| 
       10 
10 
     | 
    
         
             
                    class IndianPassportV1Document < Mindee::Parsing::Common::Prediction
         
     | 
| 
       11 
11 
     | 
    
         
             
                      include Mindee::Parsing::Standard
         
     | 
| 
       12 
12 
     | 
    
         
             
                      # The first line of the address of the passport holder.
         
     | 
| 
         @@ -7,7 +7,7 @@ module Mindee 
     | 
|
| 
       7 
7 
     | 
    
         
             
              module Product
         
     | 
| 
       8 
8 
     | 
    
         
             
                module IND
         
     | 
| 
       9 
9 
     | 
    
         
             
                  module IndianPassport
         
     | 
| 
       10 
     | 
    
         
            -
                    # Passport - India API version 1. 
     | 
| 
      
 10 
     | 
    
         
            +
                    # Passport - India API version 1.2 page data.
         
     | 
| 
       11 
11 
     | 
    
         
             
                    class IndianPassportV1Page < Mindee::Parsing::Common::Page
         
     | 
| 
       12 
12 
     | 
    
         
             
                      # @param prediction [Hash]
         
     | 
| 
       13 
13 
     | 
    
         
             
                      def initialize(prediction)
         
     | 
| 
         @@ -0,0 +1,41 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            require_relative '../../../parsing'
         
     | 
| 
      
 4 
     | 
    
         
            +
            require_relative 'us_mail_v3_document'
         
     | 
| 
      
 5 
     | 
    
         
            +
            require_relative 'us_mail_v3_page'
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
            module Mindee
         
     | 
| 
      
 8 
     | 
    
         
            +
              module Product
         
     | 
| 
      
 9 
     | 
    
         
            +
                module US
         
     | 
| 
      
 10 
     | 
    
         
            +
                  # US Mail module.
         
     | 
| 
      
 11 
     | 
    
         
            +
                  module UsMail
         
     | 
| 
      
 12 
     | 
    
         
            +
                    # US Mail API version 3 inference prediction.
         
     | 
| 
      
 13 
     | 
    
         
            +
                    class UsMailV3 < Mindee::Parsing::Common::Inference
         
     | 
| 
      
 14 
     | 
    
         
            +
                      @endpoint_name = 'us_mail'
         
     | 
| 
      
 15 
     | 
    
         
            +
                      @endpoint_version = '3'
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
                      # @param prediction [Hash]
         
     | 
| 
      
 18 
     | 
    
         
            +
                      def initialize(prediction)
         
     | 
| 
      
 19 
     | 
    
         
            +
                        super
         
     | 
| 
      
 20 
     | 
    
         
            +
                        @prediction = UsMailV3Document.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(UsMailV3Page.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
         
     | 
| 
         @@ -0,0 +1,107 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            require_relative '../../../parsing'
         
     | 
| 
      
 4 
     | 
    
         
            +
            require_relative 'us_mail_v3_sender_address'
         
     | 
| 
      
 5 
     | 
    
         
            +
            require_relative 'us_mail_v3_recipient_address'
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
            module Mindee
         
     | 
| 
      
 8 
     | 
    
         
            +
              module Product
         
     | 
| 
      
 9 
     | 
    
         
            +
                module US
         
     | 
| 
      
 10 
     | 
    
         
            +
                  module UsMail
         
     | 
| 
      
 11 
     | 
    
         
            +
                    # US Mail API version 3.0 document data.
         
     | 
| 
      
 12 
     | 
    
         
            +
                    class UsMailV3Document < Mindee::Parsing::Common::Prediction
         
     | 
| 
      
 13 
     | 
    
         
            +
                      include Mindee::Parsing::Standard
         
     | 
| 
      
 14 
     | 
    
         
            +
                      # Whether the mailing is marked as return to sender.
         
     | 
| 
      
 15 
     | 
    
         
            +
                      # @return [Mindee::Parsing::Standard::BooleanField]
         
     | 
| 
      
 16 
     | 
    
         
            +
                      attr_reader :is_return_to_sender
         
     | 
| 
      
 17 
     | 
    
         
            +
                      # The addresses of the recipients.
         
     | 
| 
      
 18 
     | 
    
         
            +
                      # @return [Array<Mindee::Product::US::UsMail::UsMailV3RecipientAddress>]
         
     | 
| 
      
 19 
     | 
    
         
            +
                      attr_reader :recipient_addresses
         
     | 
| 
      
 20 
     | 
    
         
            +
                      # The names of the recipients.
         
     | 
| 
      
 21 
     | 
    
         
            +
                      # @return [Array<Mindee::Parsing::Standard::StringField>]
         
     | 
| 
      
 22 
     | 
    
         
            +
                      attr_reader :recipient_names
         
     | 
| 
      
 23 
     | 
    
         
            +
                      # The address of the sender.
         
     | 
| 
      
 24 
     | 
    
         
            +
                      # @return [Mindee::Product::US::UsMail::UsMailV3SenderAddress]
         
     | 
| 
      
 25 
     | 
    
         
            +
                      attr_reader :sender_address
         
     | 
| 
      
 26 
     | 
    
         
            +
                      # The name of the sender.
         
     | 
| 
      
 27 
     | 
    
         
            +
                      # @return [Mindee::Parsing::Standard::StringField]
         
     | 
| 
      
 28 
     | 
    
         
            +
                      attr_reader :sender_name
         
     | 
| 
      
 29 
     | 
    
         
            +
             
     | 
| 
      
 30 
     | 
    
         
            +
                      # @param prediction [Hash]
         
     | 
| 
      
 31 
     | 
    
         
            +
                      # @param page_id [Integer, nil]
         
     | 
| 
      
 32 
     | 
    
         
            +
                      def initialize(prediction, page_id)
         
     | 
| 
      
 33 
     | 
    
         
            +
                        super()
         
     | 
| 
      
 34 
     | 
    
         
            +
                        @is_return_to_sender = BooleanField.new(prediction['is_return_to_sender'], page_id)
         
     | 
| 
      
 35 
     | 
    
         
            +
                        @recipient_addresses = []
         
     | 
| 
      
 36 
     | 
    
         
            +
                        prediction['recipient_addresses'].each do |item|
         
     | 
| 
      
 37 
     | 
    
         
            +
                          @recipient_addresses.push(UsMailV3RecipientAddress.new(item, page_id))
         
     | 
| 
      
 38 
     | 
    
         
            +
                        end
         
     | 
| 
      
 39 
     | 
    
         
            +
                        @recipient_names = []
         
     | 
| 
      
 40 
     | 
    
         
            +
                        prediction['recipient_names'].each do |item|
         
     | 
| 
      
 41 
     | 
    
         
            +
                          @recipient_names.push(StringField.new(item, page_id))
         
     | 
| 
      
 42 
     | 
    
         
            +
                        end
         
     | 
| 
      
 43 
     | 
    
         
            +
                        @sender_address = UsMailV3SenderAddress.new(prediction['sender_address'], page_id)
         
     | 
| 
      
 44 
     | 
    
         
            +
                        @sender_name = StringField.new(prediction['sender_name'], page_id)
         
     | 
| 
      
 45 
     | 
    
         
            +
                      end
         
     | 
| 
      
 46 
     | 
    
         
            +
             
     | 
| 
      
 47 
     | 
    
         
            +
                      # @return [String]
         
     | 
| 
      
 48 
     | 
    
         
            +
                      def to_s
         
     | 
| 
      
 49 
     | 
    
         
            +
                        sender_address = @sender_address.to_s
         
     | 
| 
      
 50 
     | 
    
         
            +
                        recipient_names = @recipient_names.join("\n #{' ' * 17}")
         
     | 
| 
      
 51 
     | 
    
         
            +
                        recipient_addresses = recipient_addresses_to_s
         
     | 
| 
      
 52 
     | 
    
         
            +
                        out_str = String.new
         
     | 
| 
      
 53 
     | 
    
         
            +
                        out_str << "\n:Sender Name: #{@sender_name}".rstrip
         
     | 
| 
      
 54 
     | 
    
         
            +
                        out_str << "\n:Sender Address:"
         
     | 
| 
      
 55 
     | 
    
         
            +
                        out_str << sender_address
         
     | 
| 
      
 56 
     | 
    
         
            +
                        out_str << "\n:Recipient Names: #{recipient_names}".rstrip
         
     | 
| 
      
 57 
     | 
    
         
            +
                        out_str << "\n:Recipient Addresses:"
         
     | 
| 
      
 58 
     | 
    
         
            +
                        out_str << recipient_addresses
         
     | 
| 
      
 59 
     | 
    
         
            +
                        out_str << "\n:Return to Sender: #{@is_return_to_sender}".rstrip
         
     | 
| 
      
 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 << "+#{char * 17}"
         
     | 
| 
      
 78 
     | 
    
         
            +
                        out_str << '+'
         
     | 
| 
      
 79 
     | 
    
         
            +
                        out_str
         
     | 
| 
      
 80 
     | 
    
         
            +
                      end
         
     | 
| 
      
 81 
     | 
    
         
            +
             
     | 
| 
      
 82 
     | 
    
         
            +
                      # @return [String]
         
     | 
| 
      
 83 
     | 
    
         
            +
                      def recipient_addresses_to_s
         
     | 
| 
      
 84 
     | 
    
         
            +
                        return '' if @recipient_addresses.empty?
         
     | 
| 
      
 85 
     | 
    
         
            +
             
     | 
| 
      
 86 
     | 
    
         
            +
                        line_items = @recipient_addresses.map(&:to_table_line).join("\n#{recipient_addresses_separator('-')}\n  ")
         
     | 
| 
      
 87 
     | 
    
         
            +
                        out_str = String.new
         
     | 
| 
      
 88 
     | 
    
         
            +
                        out_str << "\n#{recipient_addresses_separator('-')}"
         
     | 
| 
      
 89 
     | 
    
         
            +
                        out_str << "\n  |"
         
     | 
| 
      
 90 
     | 
    
         
            +
                        out_str << ' City            |'
         
     | 
| 
      
 91 
     | 
    
         
            +
                        out_str << ' Complete Address                    |'
         
     | 
| 
      
 92 
     | 
    
         
            +
                        out_str << ' Is Address Change |'
         
     | 
| 
      
 93 
     | 
    
         
            +
                        out_str << ' Postal Code |'
         
     | 
| 
      
 94 
     | 
    
         
            +
                        out_str << ' Private Mailbox Number |'
         
     | 
| 
      
 95 
     | 
    
         
            +
                        out_str << ' State |'
         
     | 
| 
      
 96 
     | 
    
         
            +
                        out_str << ' Street                    |'
         
     | 
| 
      
 97 
     | 
    
         
            +
                        out_str << ' Unit            |'
         
     | 
| 
      
 98 
     | 
    
         
            +
                        out_str << "\n#{recipient_addresses_separator('=')}"
         
     | 
| 
      
 99 
     | 
    
         
            +
                        out_str << "\n  #{line_items}"
         
     | 
| 
      
 100 
     | 
    
         
            +
                        out_str << "\n#{recipient_addresses_separator('-')}"
         
     | 
| 
      
 101 
     | 
    
         
            +
                        out_str
         
     | 
| 
      
 102 
     | 
    
         
            +
                      end
         
     | 
| 
      
 103 
     | 
    
         
            +
                    end
         
     | 
| 
      
 104 
     | 
    
         
            +
                  end
         
     | 
| 
      
 105 
     | 
    
         
            +
                end
         
     | 
| 
      
 106 
     | 
    
         
            +
              end
         
     | 
| 
      
 107 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,34 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            require_relative '../../../parsing'
         
     | 
| 
      
 4 
     | 
    
         
            +
            require_relative 'us_mail_v3_document'
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
            module Mindee
         
     | 
| 
      
 7 
     | 
    
         
            +
              module Product
         
     | 
| 
      
 8 
     | 
    
         
            +
                module US
         
     | 
| 
      
 9 
     | 
    
         
            +
                  module UsMail
         
     | 
| 
      
 10 
     | 
    
         
            +
                    # US Mail API version 3.0 page data.
         
     | 
| 
      
 11 
     | 
    
         
            +
                    class UsMailV3Page < Mindee::Parsing::Common::Page
         
     | 
| 
      
 12 
     | 
    
         
            +
                      # @param prediction [Hash]
         
     | 
| 
      
 13 
     | 
    
         
            +
                      def initialize(prediction)
         
     | 
| 
      
 14 
     | 
    
         
            +
                        super(prediction)
         
     | 
| 
      
 15 
     | 
    
         
            +
                        @prediction = UsMailV3PagePrediction.new(
         
     | 
| 
      
 16 
     | 
    
         
            +
                          prediction['prediction'],
         
     | 
| 
      
 17 
     | 
    
         
            +
                          prediction['id']
         
     | 
| 
      
 18 
     | 
    
         
            +
                        )
         
     | 
| 
      
 19 
     | 
    
         
            +
                      end
         
     | 
| 
      
 20 
     | 
    
         
            +
                    end
         
     | 
| 
      
 21 
     | 
    
         
            +
             
     | 
| 
      
 22 
     | 
    
         
            +
                    # US Mail V3 page prediction.
         
     | 
| 
      
 23 
     | 
    
         
            +
                    class UsMailV3PagePrediction < UsMailV3Document
         
     | 
| 
      
 24 
     | 
    
         
            +
                      # @return [String]
         
     | 
| 
      
 25 
     | 
    
         
            +
                      def to_s
         
     | 
| 
      
 26 
     | 
    
         
            +
                        out_str = String.new
         
     | 
| 
      
 27 
     | 
    
         
            +
                        out_str << "\n#{super}"
         
     | 
| 
      
 28 
     | 
    
         
            +
                        out_str
         
     | 
| 
      
 29 
     | 
    
         
            +
                      end
         
     | 
| 
      
 30 
     | 
    
         
            +
                    end
         
     | 
| 
      
 31 
     | 
    
         
            +
                  end
         
     | 
| 
      
 32 
     | 
    
         
            +
                end
         
     | 
| 
      
 33 
     | 
    
         
            +
              end
         
     | 
| 
      
 34 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,113 @@ 
     | 
|
| 
      
 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 UsMailV3RecipientAddress < 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 [Boolean]
         
     | 
| 
      
 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 
     | 
    
         
            +
                      # The unit number of the recipient's address.
         
     | 
| 
      
 34 
     | 
    
         
            +
                      # @return [String]
         
     | 
| 
      
 35 
     | 
    
         
            +
                      attr_reader :unit
         
     | 
| 
      
 36 
     | 
    
         
            +
             
     | 
| 
      
 37 
     | 
    
         
            +
                      # @param prediction [Hash]
         
     | 
| 
      
 38 
     | 
    
         
            +
                      # @param page_id [Integer, nil]
         
     | 
| 
      
 39 
     | 
    
         
            +
                      def initialize(prediction, page_id)
         
     | 
| 
      
 40 
     | 
    
         
            +
                        super(prediction, page_id)
         
     | 
| 
      
 41 
     | 
    
         
            +
                        @city = prediction['city']
         
     | 
| 
      
 42 
     | 
    
         
            +
                        @complete = prediction['complete']
         
     | 
| 
      
 43 
     | 
    
         
            +
                        @is_address_change = prediction['is_address_change']
         
     | 
| 
      
 44 
     | 
    
         
            +
                        @postal_code = prediction['postal_code']
         
     | 
| 
      
 45 
     | 
    
         
            +
                        @private_mailbox_number = prediction['private_mailbox_number']
         
     | 
| 
      
 46 
     | 
    
         
            +
                        @state = prediction['state']
         
     | 
| 
      
 47 
     | 
    
         
            +
                        @street = prediction['street']
         
     | 
| 
      
 48 
     | 
    
         
            +
                        @unit = prediction['unit']
         
     | 
| 
      
 49 
     | 
    
         
            +
                        @page_id = page_id
         
     | 
| 
      
 50 
     | 
    
         
            +
                      end
         
     | 
| 
      
 51 
     | 
    
         
            +
             
     | 
| 
      
 52 
     | 
    
         
            +
                      # @return [Hash]
         
     | 
| 
      
 53 
     | 
    
         
            +
                      def printable_values
         
     | 
| 
      
 54 
     | 
    
         
            +
                        printable = {}
         
     | 
| 
      
 55 
     | 
    
         
            +
                        printable[:city] = format_for_display(@city)
         
     | 
| 
      
 56 
     | 
    
         
            +
                        printable[:complete] = format_for_display(@complete)
         
     | 
| 
      
 57 
     | 
    
         
            +
                        printable[:is_address_change] = format_for_display(@is_address_change)
         
     | 
| 
      
 58 
     | 
    
         
            +
                        printable[:postal_code] = format_for_display(@postal_code)
         
     | 
| 
      
 59 
     | 
    
         
            +
                        printable[:private_mailbox_number] = format_for_display(@private_mailbox_number)
         
     | 
| 
      
 60 
     | 
    
         
            +
                        printable[:state] = format_for_display(@state)
         
     | 
| 
      
 61 
     | 
    
         
            +
                        printable[:street] = format_for_display(@street)
         
     | 
| 
      
 62 
     | 
    
         
            +
                        printable[:unit] = format_for_display(@unit)
         
     | 
| 
      
 63 
     | 
    
         
            +
                        printable
         
     | 
| 
      
 64 
     | 
    
         
            +
                      end
         
     | 
| 
      
 65 
     | 
    
         
            +
             
     | 
| 
      
 66 
     | 
    
         
            +
                      # @return [Hash]
         
     | 
| 
      
 67 
     | 
    
         
            +
                      def table_printable_values
         
     | 
| 
      
 68 
     | 
    
         
            +
                        printable = {}
         
     | 
| 
      
 69 
     | 
    
         
            +
                        printable[:city] = format_for_display(@city, 15)
         
     | 
| 
      
 70 
     | 
    
         
            +
                        printable[:complete] = format_for_display(@complete, 35)
         
     | 
| 
      
 71 
     | 
    
         
            +
                        printable[:is_address_change] = format_for_display(@is_address_change, nil)
         
     | 
| 
      
 72 
     | 
    
         
            +
                        printable[:postal_code] = format_for_display(@postal_code, nil)
         
     | 
| 
      
 73 
     | 
    
         
            +
                        printable[:private_mailbox_number] = format_for_display(@private_mailbox_number, nil)
         
     | 
| 
      
 74 
     | 
    
         
            +
                        printable[:state] = format_for_display(@state, nil)
         
     | 
| 
      
 75 
     | 
    
         
            +
                        printable[:street] = format_for_display(@street, 25)
         
     | 
| 
      
 76 
     | 
    
         
            +
                        printable[:unit] = format_for_display(@unit, 15)
         
     | 
| 
      
 77 
     | 
    
         
            +
                        printable
         
     | 
| 
      
 78 
     | 
    
         
            +
                      end
         
     | 
| 
      
 79 
     | 
    
         
            +
             
     | 
| 
      
 80 
     | 
    
         
            +
                      # @return [String]
         
     | 
| 
      
 81 
     | 
    
         
            +
                      def to_table_line
         
     | 
| 
      
 82 
     | 
    
         
            +
                        printable = table_printable_values
         
     | 
| 
      
 83 
     | 
    
         
            +
                        out_str = String.new
         
     | 
| 
      
 84 
     | 
    
         
            +
                        out_str << format('| %- 16s', printable[:city])
         
     | 
| 
      
 85 
     | 
    
         
            +
                        out_str << format('| %- 36s', printable[:complete])
         
     | 
| 
      
 86 
     | 
    
         
            +
                        out_str << format('| %- 18s', printable[:is_address_change])
         
     | 
| 
      
 87 
     | 
    
         
            +
                        out_str << format('| %- 12s', printable[:postal_code])
         
     | 
| 
      
 88 
     | 
    
         
            +
                        out_str << format('| %- 23s', printable[:private_mailbox_number])
         
     | 
| 
      
 89 
     | 
    
         
            +
                        out_str << format('| %- 6s', printable[:state])
         
     | 
| 
      
 90 
     | 
    
         
            +
                        out_str << format('| %- 26s', printable[:street])
         
     | 
| 
      
 91 
     | 
    
         
            +
                        out_str << format('| %- 16s', printable[:unit])
         
     | 
| 
      
 92 
     | 
    
         
            +
                        out_str << '|'
         
     | 
| 
      
 93 
     | 
    
         
            +
                      end
         
     | 
| 
      
 94 
     | 
    
         
            +
             
     | 
| 
      
 95 
     | 
    
         
            +
                      # @return [String]
         
     | 
| 
      
 96 
     | 
    
         
            +
                      def to_s
         
     | 
| 
      
 97 
     | 
    
         
            +
                        printable = printable_values
         
     | 
| 
      
 98 
     | 
    
         
            +
                        out_str = String.new
         
     | 
| 
      
 99 
     | 
    
         
            +
                        out_str << "\n  :City: #{printable[:city]}"
         
     | 
| 
      
 100 
     | 
    
         
            +
                        out_str << "\n  :Complete Address: #{printable[:complete]}"
         
     | 
| 
      
 101 
     | 
    
         
            +
                        out_str << "\n  :Is Address Change: #{printable[:is_address_change]}"
         
     | 
| 
      
 102 
     | 
    
         
            +
                        out_str << "\n  :Postal Code: #{printable[:postal_code]}"
         
     | 
| 
      
 103 
     | 
    
         
            +
                        out_str << "\n  :Private Mailbox Number: #{printable[:private_mailbox_number]}"
         
     | 
| 
      
 104 
     | 
    
         
            +
                        out_str << "\n  :State: #{printable[:state]}"
         
     | 
| 
      
 105 
     | 
    
         
            +
                        out_str << "\n  :Street: #{printable[:street]}"
         
     | 
| 
      
 106 
     | 
    
         
            +
                        out_str << "\n  :Unit: #{printable[:unit]}"
         
     | 
| 
      
 107 
     | 
    
         
            +
                        out_str
         
     | 
| 
      
 108 
     | 
    
         
            +
                      end
         
     | 
| 
      
 109 
     | 
    
         
            +
                    end
         
     | 
| 
      
 110 
     | 
    
         
            +
                  end
         
     | 
| 
      
 111 
     | 
    
         
            +
                end
         
     | 
| 
      
 112 
     | 
    
         
            +
              end
         
     | 
| 
      
 113 
     | 
    
         
            +
            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 UsMailV3SenderAddress < 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(prediction, page_id)
         
     | 
| 
      
 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
         
     | 
    
        data/lib/mindee/product.rb
    CHANGED
    
    | 
         @@ -36,4 +36,5 @@ require_relative 'product/us/bank_check/bank_check_v1' 
     | 
|
| 
       36 
36 
     | 
    
         
             
            require_relative 'product/us/driver_license/driver_license_v1'
         
     | 
| 
       37 
37 
     | 
    
         
             
            require_relative 'product/us/healthcare_card/healthcare_card_v1'
         
     | 
| 
       38 
38 
     | 
    
         
             
            require_relative 'product/us/us_mail/us_mail_v2'
         
     | 
| 
      
 39 
     | 
    
         
            +
            require_relative 'product/us/us_mail/us_mail_v3'
         
     | 
| 
       39 
40 
     | 
    
         
             
            require_relative 'product/us/w9/w9_v1'
         
     | 
    
        data/lib/mindee/version.rb
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | 
         @@ -1,14 +1,14 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: mindee
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 3. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 3.19.1
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Mindee, SA
         
     | 
| 
       8 
     | 
    
         
            -
            autorequire: 
     | 
| 
      
 8 
     | 
    
         
            +
            autorequire:
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date:  
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2025-01-21 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: marcel
         
     | 
| 
         @@ -198,6 +198,7 @@ files: 
     | 
|
| 
       198 
198 
     | 
    
         
             
            - docs/code_samples/us_driver_license_v1.txt
         
     | 
| 
       199 
199 
     | 
    
         
             
            - docs/code_samples/us_healthcare_cards_v1_async.txt
         
     | 
| 
       200 
200 
     | 
    
         
             
            - docs/code_samples/us_mail_v2_async.txt
         
     | 
| 
      
 201 
     | 
    
         
            +
            - docs/code_samples/us_mail_v3_async.txt
         
     | 
| 
       201 
202 
     | 
    
         
             
            - docs/code_samples/us_w9_v1.txt
         
     | 
| 
       202 
203 
     | 
    
         
             
            - docs/code_samples/workflow_execution.txt
         
     | 
| 
       203 
204 
     | 
    
         
             
            - docs/cropper_v1.md
         
     | 
| 
         @@ -223,7 +224,7 @@ files: 
     | 
|
| 
       223 
224 
     | 
    
         
             
            - docs/payslip_fra_v3.md
         
     | 
| 
       224 
225 
     | 
    
         
             
            - docs/resume_v1.md
         
     | 
| 
       225 
226 
     | 
    
         
             
            - docs/us_healthcare_cards_v1.md
         
     | 
| 
       226 
     | 
    
         
            -
            - docs/ 
     | 
| 
      
 227 
     | 
    
         
            +
            - docs/us_mail_v3.md
         
     | 
| 
       227 
228 
     | 
    
         
             
            - docs/us_w9_v1.md
         
     | 
| 
       228 
229 
     | 
    
         
             
            - examples/auto_invoice_splitter_extraction.rb
         
     | 
| 
       229 
230 
     | 
    
         
             
            - examples/auto_multi_receipts_detector_extraction.rb
         
     | 
| 
         @@ -470,6 +471,11 @@ files: 
     | 
|
| 
       470 
471 
     | 
    
         
             
            - lib/mindee/product/us/us_mail/us_mail_v2_page.rb
         
     | 
| 
       471 
472 
     | 
    
         
             
            - lib/mindee/product/us/us_mail/us_mail_v2_recipient_address.rb
         
     | 
| 
       472 
473 
     | 
    
         
             
            - lib/mindee/product/us/us_mail/us_mail_v2_sender_address.rb
         
     | 
| 
      
 474 
     | 
    
         
            +
            - lib/mindee/product/us/us_mail/us_mail_v3.rb
         
     | 
| 
      
 475 
     | 
    
         
            +
            - lib/mindee/product/us/us_mail/us_mail_v3_document.rb
         
     | 
| 
      
 476 
     | 
    
         
            +
            - lib/mindee/product/us/us_mail/us_mail_v3_page.rb
         
     | 
| 
      
 477 
     | 
    
         
            +
            - lib/mindee/product/us/us_mail/us_mail_v3_recipient_address.rb
         
     | 
| 
      
 478 
     | 
    
         
            +
            - lib/mindee/product/us/us_mail/us_mail_v3_sender_address.rb
         
     | 
| 
       473 
479 
     | 
    
         
             
            - lib/mindee/product/us/w9/w9_v1.rb
         
     | 
| 
       474 
480 
     | 
    
         
             
            - lib/mindee/product/us/w9/w9_v1_document.rb
         
     | 
| 
       475 
481 
     | 
    
         
             
            - lib/mindee/product/us/w9/w9_v1_page.rb
         
     | 
| 
         @@ -483,7 +489,7 @@ metadata: 
     | 
|
| 
       483 
489 
     | 
    
         
             
              source_code_uri: https://github.com/mindee/mindee-api-ruby
         
     | 
| 
       484 
490 
     | 
    
         
             
              changelog_uri: https://github.com/mindee/mindee-api-ruby/blob/main/CHANGELOG.md
         
     | 
| 
       485 
491 
     | 
    
         
             
              rubygems_mfa_required: 'true'
         
     | 
| 
       486 
     | 
    
         
            -
            post_install_message: 
     | 
| 
      
 492 
     | 
    
         
            +
            post_install_message:
         
     | 
| 
       487 
493 
     | 
    
         
             
            rdoc_options: []
         
     | 
| 
       488 
494 
     | 
    
         
             
            require_paths:
         
     | 
| 
       489 
495 
     | 
    
         
             
            - lib
         
     | 
| 
         @@ -499,7 +505,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement 
     | 
|
| 
       499 
505 
     | 
    
         
             
                  version: '0'
         
     | 
| 
       500 
506 
     | 
    
         
             
            requirements: []
         
     | 
| 
       501 
507 
     | 
    
         
             
            rubygems_version: 3.1.6
         
     | 
| 
       502 
     | 
    
         
            -
            signing_key: 
     | 
| 
      
 508 
     | 
    
         
            +
            signing_key:
         
     | 
| 
       503 
509 
     | 
    
         
             
            specification_version: 4
         
     | 
| 
       504 
510 
     | 
    
         
             
            summary: Mindee API Helper Library for Ruby
         
     | 
| 
       505 
511 
     | 
    
         
             
            test_files: []
         
     |