Class: Retab::WorkflowTests

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

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ WorkflowTests

Returns a new instance of WorkflowTests.



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

def initialize(client)
  @client = client
end

Instance Method Details

#create(workflow_id:, target:, source:, assertion:, name: nil, request_options: {}) ⇒ Retab::WorkflowTest

Create Test

Parameters:

Returns:



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

def create(
  workflow_id:,
  target:,
  source:,
  assertion:,
  name: nil,
  request_options: {}
)
  body = {
    'workflow_id' => workflow_id,
    'target' => target,
    'source' => source,
    'name' => name,
    'assertion' => assertion
  }.compact
  response = @client.request(
    method: :post,
    path: '/v1/workflows/tests',
    auth: true,
    body: body,
    request_options: request_options
  )
  result = Retab::WorkflowTest.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(test_id:, request_options: {}) ⇒ void

This method returns an undefined value.

Delete Test

Parameters:

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

    (see Retab::Types::RequestOptions)



133
134
135
136
137
138
139
140
141
142
143
144
# File 'lib/retab/workflow_tests.rb', line 133

def delete(
  test_id:,
  request_options: {}
)
  response = @client.request(
    method: :delete,
    path: "/v1/workflows/tests/#{Retab::Util.encode_path(test_id)}",
    auth: true,
    request_options: request_options
  )
  nil
end

#get(test_id:, request_options: {}) ⇒ Retab::WorkflowTest

Get Test

Parameters:

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

    (see Retab::Types::RequestOptions)

Returns:



83
84
85
86
87
88
89
90
91
92
93
94
95
96
# File 'lib/retab/workflow_tests.rb', line 83

def get(
  test_id:,
  request_options: {}
)
  response = @client.request(
    method: :get,
    path: "/v1/workflows/tests/#{Retab::Util.encode_path(test_id)}",
    auth: true,
    request_options: request_options
  )
  result = Retab::WorkflowTest.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:, target_block_id: nil, limit: 50, request_options: {}) ⇒ Retab::Types::ListStruct<Retab::WorkflowTest>

List Tests

Parameters:

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

    (see Retab::Types::RequestOptions)

Returns:



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/retab/workflow_tests.rb', line 19

def list(
  workflow_id:,
  target_block_id: nil,
  limit: 50,
  request_options: {}
)
  params = {
    'workflow_id' => workflow_id,
    'target_block_id' => target_block_id,
    'limit' => limit
  }.compact
  response = @client.request(
    method: :get,
    path: '/v1/workflows/tests',
    auth: true,
    params: params,
    request_options: request_options
  )
  Retab::Types::ListStruct.from_response(
    response,
    model: Retab::WorkflowTest,
    filters: { workflow_id: workflow_id, target_block_id: target_block_id, limit: limit }
  )
end

#update(test_id:, name: nil, assertion: nil, source: nil, request_options: {}) ⇒ Retab::WorkflowTest

Update Test

Parameters:

Returns:



105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
# File 'lib/retab/workflow_tests.rb', line 105

def update(
  test_id:,
  name: nil,
  assertion: nil,
  source: nil,
  request_options: {}
)
  body = {
    'name' => name,
    'assertion' => assertion,
    'source' => source
  }.compact
  response = @client.request(
    method: :patch,
    path: "/v1/workflows/tests/#{Retab::Util.encode_path(test_id)}",
    auth: true,
    body: body,
    request_options: request_options
  )
  result = Retab::WorkflowTest.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