Class: Retab::WorkflowReviewVersions

Inherits:
Object
  • Object
show all
Defined in:
lib/retab/workflow_review_versions.rb

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ WorkflowReviewVersions

Returns a new instance of WorkflowReviewVersions.



9
10
11
# File 'lib/retab/workflow_review_versions.rb', line 9

def initialize(client)
  @client = client
end

Instance Method Details

#create(review_id:, parent_id:, snapshot:, note: nil, request_options: {}) ⇒ Retab::ReviewVersion

Create Review Version Route

Parameters:

  • review_id (String)
  • parent_id (String)
  • snapshot (Hash{String => Object})

    The full reviewed snapshot to store as an immutable version. The object must match the gated block type: extract uses the raw output object; classifier uses string; split uses [{‘name’: string, ‘pages’: positive sorted int}; for_each uses [{‘key’: string, ‘pages’: positive sorted int}. The server validates the shape and stores the exact submitted object when valid.

  • note (String, nil) (defaults to: nil)
  • request_options (Hash) (defaults to: {})

    (see Retab::Types::RequestOptions)

Returns:



64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# File 'lib/retab/workflow_review_versions.rb', line 64

def create(
  review_id:,
  parent_id:,
  snapshot:,
  note: nil,
  request_options: {}
)
  body = {
    'review_id' => review_id,
    'parent_id' => parent_id,
    'snapshot' => snapshot,
    'note' => note
  }.compact
  response = @client.request(
    method: :post,
    path: '/v1/workflows/reviews/versions',
    auth: true,
    body: body,
    request_options: request_options
  )
  result = Retab::ReviewVersion.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

#get(version_id:, request_options: {}) ⇒ Retab::ReviewVersion

Get Review Version Route

Parameters:

  • version_id (String)
  • request_options (Hash) (defaults to: {})

    (see Retab::Types::RequestOptions)

Returns:



93
94
95
96
97
98
99
100
101
102
103
104
105
106
# File 'lib/retab/workflow_review_versions.rb', line 93

def get(
  version_id:,
  request_options: {}
)
  response = @client.request(
    method: :get,
    path: "/v1/workflows/reviews/versions/#{Retab::Util.encode_path(version_id)}",
    auth: true,
    request_options: request_options
  )
  result = Retab::ReviewVersion.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(review_id:, before: nil, after: nil, limit: 50, request_options: {}) ⇒ Retab::Types::ListStruct<Retab::ReviewVersion>

List Review Versions Route

Parameters:

  • review_id (String)

    Required: the review whose versions to list.

  • before (String, nil) (defaults to: nil)
  • after (String, nil) (defaults to: nil)
  • limit (Integer, nil) (defaults to: 50)
  • request_options (Hash) (defaults to: {})

    (see Retab::Types::RequestOptions)

Returns:



20
21
22
23
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
# File 'lib/retab/workflow_review_versions.rb', line 20

def list(
  review_id:,
  before: nil,
  after: nil,
  limit: 50,
  request_options: {}
)
  params = {
    'review_id' => review_id,
    'before' => before,
    'after' => after,
    'limit' => limit
  }.compact
  response = @client.request(
    method: :get,
    path: '/v1/workflows/reviews/versions',
    auth: true,
    params: params,
    request_options: request_options
  )
  fetch_next = ->(cursor) {
    list(
      review_id: review_id,
      before: before,
      after: cursor,
      limit: limit,
      request_options: request_options
    )
  }
  Retab::Types::ListStruct.from_response(
    response,
    model: Retab::ReviewVersion,
    filters: { review_id: review_id, before: before, limit: limit },
    fetch_next: fetch_next
  )
end