Class: ModerationAPI::Resources::Actions

Inherits:
Object
  • Object
show all
Defined in:
lib/moderation_api/resources/actions.rb,
lib/moderation_api/resources/actions/execute.rb

Defined Under Namespace

Classes: Execute

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Actions

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Actions.

Parameters:



166
167
168
169
# File 'lib/moderation_api/resources/actions.rb', line 166

def initialize(client:)
  @client = client
  @execute = ModerationAPI::Resources::Actions::Execute.new(client: client)
end

Instance Attribute Details

#executeModerationAPI::Resources::Actions::Execute (readonly)



7
8
9
# File 'lib/moderation_api/resources/actions.rb', line 7

def execute
  @execute
end

Instance Method Details

#create(name:, built_in: nil, description: nil, filter_in_queue_ids: nil, free_text: nil, key: nil, position: nil, possible_values: nil, queue_behaviour: nil, type: nil, value_required: nil, request_options: {}) ⇒ ModerationAPI::Models::ActionCreateResponse

Some parameter documentations has been truncated, see Models::ActionCreateParams for more details.

Create an action.

Parameters:

Returns:

See Also:



43
44
45
46
47
48
49
50
51
52
# File 'lib/moderation_api/resources/actions.rb', line 43

def create(params)
  parsed, options = ModerationAPI::ActionCreateParams.dump_request(params)
  @client.request(
    method: :post,
    path: "actions",
    body: parsed,
    model: ModerationAPI::Models::ActionCreateResponse,
    options: options
  )
end

#delete(id, request_options: {}) ⇒ ModerationAPI::Models::ActionDeleteResponse

Delete an action and all of its webhooks.

Parameters:

Returns:

See Also:



154
155
156
157
158
159
160
161
# File 'lib/moderation_api/resources/actions.rb', line 154

def delete(id, params = {})
  @client.request(
    method: :delete,
    path: ["actions/%1$s", id],
    model: ModerationAPI::Models::ActionDeleteResponse,
    options: params[:request_options]
  )
end

#list(queue_id: nil, request_options: {}) ⇒ Array<ModerationAPI::Models::ActionListResponseItem>

List all available moderation actions for the authenticated organization.

Parameters:

Returns:

See Also:



131
132
133
134
135
136
137
138
139
140
141
# File 'lib/moderation_api/resources/actions.rb', line 131

def list(params = {})
  parsed, options = ModerationAPI::ActionListParams.dump_request(params)
  query = ModerationAPI::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: "actions",
    query: query.transform_keys(queue_id: "queueId"),
    model: ModerationAPI::Internal::Type::ArrayOf[ModerationAPI::Models::ActionListResponseItem],
    options: options
  )
end

#retrieve(id, request_options: {}) ⇒ ModerationAPI::Models::ActionRetrieveResponse

Get an action by ID.

Parameters:

Returns:

See Also:



65
66
67
68
69
70
71
72
# File 'lib/moderation_api/resources/actions.rb', line 65

def retrieve(id, params = {})
  @client.request(
    method: :get,
    path: ["actions/%1$s", id],
    model: ModerationAPI::Models::ActionRetrieveResponse,
    options: params[:request_options]
  )
end

#update(id, built_in: nil, description: nil, filter_in_queue_ids: nil, free_text: nil, key: nil, name: nil, position: nil, possible_values: nil, queue_behaviour: nil, type: nil, value_required: nil, request_options: {}) ⇒ ModerationAPI::Models::ActionUpdateResponse

Some parameter documentations has been truncated, see Models::ActionUpdateParams for more details.

Update an action.

Parameters:

  • id (String)

    The ID of the action to update.

  • built_in (Boolean, nil)

    Whether the action is a built-in action or a custom one.

  • description (String, nil)

    The description of the action.

  • filter_in_queue_ids (Array<String>)

    The IDs of the queues the action is available in.

  • free_text (Boolean)

    Whether the action allows any text to be entered as a value or if it must be one

  • key (String, nil)

    User defined key of the action.

  • name (String)

    The name of the action.

  • position (Symbol, ModerationAPI::Models::ActionUpdateParams::Position)

    Show the action in all queues, selected queues or no queues (to use via API only

  • possible_values (Array<ModerationAPI::Models::ActionUpdateParams::PossibleValue>)

    The possible values of the action. The user will be prompted to select one of th

  • queue_behaviour (Symbol, ModerationAPI::Models::ActionUpdateParams::QueueBehaviour)

    Whether the action resolves and removes the item, unresolves and re-add it to th

  • type (Symbol, ModerationAPI::Models::ActionUpdateParams::Type, nil)

    The type of the action.

  • value_required (Boolean)

    Whether the action requires a value to be executed.

  • request_options (ModerationAPI::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



110
111
112
113
114
115
116
117
118
119
# File 'lib/moderation_api/resources/actions.rb', line 110

def update(id, params = {})
  parsed, options = ModerationAPI::ActionUpdateParams.dump_request(params)
  @client.request(
    method: :put,
    path: ["actions/%1$s", id],
    body: parsed,
    model: ModerationAPI::Models::ActionUpdateResponse,
    options: options
  )
end