Class: Retab::Splits
- Inherits:
-
Object
- Object
- Retab::Splits
- Defined in:
- lib/retab/splits.rb
Instance Method Summary collapse
-
#create(document:, subdocuments:, model: nil, instructions: nil, n_consensus: nil, bust_cache: nil, background: nil, request_options: {}) ⇒ Retab::Split
Create Split.
-
#create_reconstruct(document:, subdocuments:, request_options: {}) ⇒ Retab::ReconstructResponse
Reconstruct Split.
-
#create_split_cancel(split_id:, request_options: {}) ⇒ Retab::Split
Cancel Split.
-
#delete(split_id:, request_options: {}) ⇒ void
Delete Split.
-
#get(split_id:, include_output: true, request_options: {}) ⇒ Retab::Split
Get Split.
-
#initialize(client) ⇒ Splits
constructor
A new instance of Splits.
-
#list(before: nil, after: nil, limit: 10, order: "desc", filename: nil, status: nil, from_date: nil, to_date: nil, request_options: {}) ⇒ Retab::PaginatedList<Retab::Split>
List Splits.
Constructor Details
#initialize(client) ⇒ Splits
Returns a new instance of Splits.
9 10 11 |
# File 'lib/retab/splits.rb', line 9 def initialize(client) @client = client end |
Instance Method Details
#create(document:, subdocuments:, model: nil, instructions: nil, n_consensus: nil, bust_cache: nil, background: nil, request_options: {}) ⇒ Retab::Split
Create Split
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 |
# File 'lib/retab/splits.rb', line 91 def create( document:, subdocuments:, model: nil, instructions: nil, n_consensus: nil, bust_cache: nil, background: nil, request_options: {} ) document = Retab::MimeData.coerce(document, client: @client) unless document.nil? body = { "document" => document, "subdocuments" => subdocuments, "model" => model, "instructions" => instructions, "n_consensus" => n_consensus, "bust_cache" => bust_cache, "background" => background }.compact response = @client.request( method: :post, path: "/v1/splits", auth: true, body: body, request_options: ) result = Retab::Split.new(response.body) result.last_response = Retab::Types::ApiResponse.new( http_status: response.code.to_i, http_headers: response.each_header.to_h, request_id: response["x-request-id"] ) result end |
#create_reconstruct(document:, subdocuments:, request_options: {}) ⇒ Retab::ReconstructResponse
Reconstruct Split
132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 |
# File 'lib/retab/splits.rb', line 132 def create_reconstruct( document:, subdocuments:, request_options: {} ) body = { "document" => document, "subdocuments" => subdocuments } response = @client.request( method: :post, path: "/v1/splits/reconstruct", auth: true, body: body, request_options: ) result = Retab::ReconstructResponse.new(response.body) result.last_response = Retab::Types::ApiResponse.new( http_status: response.code.to_i, http_headers: response.each_header.to_h, request_id: response["x-request-id"] ) result end |
#create_split_cancel(split_id:, request_options: {}) ⇒ Retab::Split
Cancel Split
207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 |
# File 'lib/retab/splits.rb', line 207 def create_split_cancel( split_id:, request_options: {} ) response = @client.request( method: :post, path: "/v1/splits/#{Retab::Util.encode_path(split_id)}/cancel", auth: true, request_options: ) result = Retab::Split.new(response.body) result.last_response = Retab::Types::ApiResponse.new( http_status: response.code.to_i, http_headers: response.each_header.to_h, request_id: response["x-request-id"] ) result end |
#delete(split_id:, request_options: {}) ⇒ void
This method returns an undefined value.
Delete Split
190 191 192 193 194 195 196 197 198 199 200 201 |
# File 'lib/retab/splits.rb', line 190 def delete( split_id:, request_options: {} ) @client.request( method: :delete, path: "/v1/splits/#{Retab::Util.encode_path(split_id)}", auth: true, request_options: ) nil end |
#get(split_id:, include_output: true, request_options: {}) ⇒ Retab::Split
Get Split
162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 |
# File 'lib/retab/splits.rb', line 162 def get( split_id:, include_output: true, request_options: {} ) params = { "include_output" => include_output }.compact response = @client.request( method: :get, path: "/v1/splits/#{Retab::Util.encode_path(split_id)}", auth: true, params: params, request_options: ) result = Retab::Split.new(response.body) result.last_response = Retab::Types::ApiResponse.new( http_status: response.code.to_i, http_headers: response.each_header.to_h, request_id: response["x-request-id"] ) result end |
#list(before: nil, after: nil, limit: 10, order: "desc", filename: nil, status: nil, from_date: nil, to_date: nil, request_options: {}) ⇒ Retab::PaginatedList<Retab::Split>
List Splits
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/retab/splits.rb', line 24 def list( before: nil, after: nil, limit: 10, order: "desc", filename: nil, status: nil, from_date: nil, to_date: nil, request_options: {} ) params = { "before" => before, "after" => after, "limit" => limit, "order" => order, "filename" => filename, "status" => status, "from_date" => from_date, "to_date" => to_date }.compact response = @client.request( method: :get, path: "/v1/splits", auth: true, params: params, request_options: ) fetch_next = -> (cursor) { list( before: before, after: cursor, limit: limit, order: order, filename: filename, status: status, from_date: from_date, to_date: to_date, request_options: ) } Retab::PaginatedList.from_response( response, model: Retab::Split, filters: { before: before, limit: limit, order: order, filename: filename, status: status, from_date: from_date, to_date: to_date }, fetch_next: fetch_next ) end |