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:



118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
# File 'lib/retab/workflow_reviews.rb', line 118

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:



94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
# File 'lib/retab/workflow_reviews.rb', line 94

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::PaginatedList<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:



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
80
81
82
83
84
85
86
87
88
# File 'lib/retab/workflow_reviews.rb', line 29

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::PaginatedList.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:



148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
# File 'lib/retab/workflow_reviews.rb', line 148

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

#versionsObject



13
14
15
# File 'lib/retab/workflow_reviews.rb', line 13

def versions
  @versions ||= Retab::WorkflowReviewVersions.new(@client)
end