Class: Retab::WorkflowReviews

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

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ WorkflowReviews

Returns a new instance of WorkflowReviews.



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

def initialize(client)
  @client = client
end

Instance Method Details

#approve(review_id:, version_id:, request_options: {}) ⇒ Retab::SubmitDecisionResponse

Approve Review Route

Parameters:

  • review_id (String)
  • version_id (String)

    Exact content-addressed key of the version to approve.

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

    (see Retab::Types::RequestOptions)

Returns:



101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
# File 'lib/retab/workflow_reviews.rb', line 101

def approve(
  review_id:,
  version_id:,
  request_options: {}
)
  body = {
    'version_id' => version_id
  }
  response = @client.request(
    method: :post,
    path: "/v1/workflows/reviews/#{Retab::Util.encode_path(review_id)}/approve",
    auth: true,
    body: body,
    request_options: request_options
  )
  result = Retab::SubmitDecisionResponse.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(review_id:, request_options: {}) ⇒ Retab::Review

Get Review Route

Parameters:

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

    (see Retab::Types::RequestOptions)

Returns:



81
82
83
84
85
86
87
88
89
90
91
92
93
94
# File 'lib/retab/workflow_reviews.rb', line 81

def get(
  review_id:,
  request_options: {}
)
  response = @client.request(
    method: :get,
    path: "/v1/workflows/reviews/#{Retab::Util.encode_path(review_id)}",
    auth: true,
    request_options: request_options
  )
  result = Retab::Review.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(workflow_id: nil, run_id: nil, block_id: nil, step_id: nil, iteration_key: nil, decision_status: 'pending', before: nil, after: nil, limit: 50, request_options: {}) ⇒ Retab::Types::ListStruct<Retab::Review>

List Reviews Route

Parameters:

  • workflow_id (String, nil) (defaults to: nil)
  • run_id (String, nil) (defaults to: nil)
  • block_id (String, nil) (defaults to: nil)
  • step_id (String, nil) (defaults to: nil)
  • iteration_key (String, nil) (defaults to: nil)
  • decision_status (Retab::Types::ReviewDecisionStatus, nil) (defaults to: 'pending')

    Filter by decision state: pending, approved, rejected, decided, or all.

  • before (String, nil) (defaults to: nil)

    Cursor: only return reviews that appear before this review id in the result order. Use list_metadata.before from the previous page.

  • after (String, nil) (defaults to: nil)

    Cursor: only return reviews that appear after this review id in the result order. Use list_metadata.after from the previous page.

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

    (see Retab::Types::RequestOptions)

Returns:



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
# File 'lib/retab/workflow_reviews.rb', line 25

def list(
  workflow_id: nil,
  run_id: nil,
  block_id: nil,
  step_id: nil,
  iteration_key: nil,
  decision_status: 'pending',
  before: nil,
  after: nil,
  limit: 50,
  request_options: {}
)
  params = {
    'workflow_id' => workflow_id,
    'run_id' => run_id,
    'block_id' => block_id,
    'step_id' => step_id,
    'iteration_key' => iteration_key,
    'decision_status' => decision_status,
    'before' => before,
    'after' => after,
    'limit' => limit
  }.compact
  response = @client.request(
    method: :get,
    path: '/v1/workflows/reviews',
    auth: true,
    params: params,
    request_options: request_options
  )
  fetch_next = ->(cursor) {
    list(
      workflow_id: workflow_id,
      run_id: run_id,
      block_id: block_id,
      step_id: step_id,
      iteration_key: iteration_key,
      decision_status: decision_status,
      before: before,
      after: cursor,
      limit: limit,
      request_options: request_options
    )
  }
  Retab::Types::ListStruct.from_response(
    response,
    model: Retab::Review,
    filters: { workflow_id: workflow_id, run_id: run_id, block_id: block_id, step_id: step_id, iteration_key: iteration_key, decision_status: decision_status, before: before, limit: limit },
    fetch_next: fetch_next
  )
end

#reject(review_id:, version_id:, reason:, request_options: {}) ⇒ Retab::SubmitDecisionResponse

Reject Review Route

Parameters:

  • review_id (String)
  • version_id (String)

    Exact content-addressed key of the version to reject.

  • reason (String)

    Required, non-empty rejection reason.

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

    (see Retab::Types::RequestOptions)

Returns:



127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
# File 'lib/retab/workflow_reviews.rb', line 127

def reject(
  review_id:,
  version_id:,
  reason:,
  request_options: {}
)
  body = {
    'version_id' => version_id,
    'reason' => reason
  }
  response = @client.request(
    method: :post,
    path: "/v1/workflows/reviews/#{Retab::Util.encode_path(review_id)}/reject",
    auth: true,
    body: body,
    request_options: request_options
  )
  result = Retab::SubmitDecisionResponse.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