Class: ModerationAPI::Resources::Authors

Inherits:
Object
  • Object
show all
Defined in:
lib/moderation_api/resources/authors.rb

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Authors

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 Authors.

Parameters:



175
176
177
# File 'lib/moderation_api/resources/authors.rb', line 175

def initialize(client:)
  @client = client
end

Instance Method Details

#create(external_id:, email: nil, external_link: nil, first_seen: nil, last_seen: nil, manual_trust_level: nil, metadata: nil, name: nil, profile_picture: nil, request_options: {}) ⇒ ModerationAPI::Models::AuthorCreateResponse

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

Create a new author. Typically not needed as authors are created automatically when content is moderated.

Parameters:

  • external_id (String)

    External ID of the user, typically the ID of the author in your database.

  • email (String, nil)

    Author email address

  • external_link (String, nil)

    URL of the author’s external profile

  • first_seen (Float)

    Timestamp when author first appeared

  • last_seen (Float)

    Timestamp of last activity

  • manual_trust_level (Float, nil)
  • metadata (ModerationAPI::Models::AuthorCreateParams::Metadata)

    Additional metadata provided by your system. We recommend including any relevant

  • name (String, nil)

    Author name or identifier

  • profile_picture (String, nil)

    URL of the author’s profile picture

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

Returns:

See Also:



37
38
39
40
41
42
43
44
45
46
# File 'lib/moderation_api/resources/authors.rb', line 37

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

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

Delete a specific author

Parameters:

Returns:

See Also:



163
164
165
166
167
168
169
170
# File 'lib/moderation_api/resources/authors.rb', line 163

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

#list(content_types: nil, last_active_date: nil, member_since_date: nil, page_number: nil, page_size: nil, sort_by: nil, sort_direction: nil, request_options: {}) ⇒ ModerationAPI::Models::AuthorListResponse

Get a paginated list of authors with their activity metrics and reputation

Parameters:

Returns:

See Also:



133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
# File 'lib/moderation_api/resources/authors.rb', line 133

def list(params = {})
  parsed, options = ModerationAPI::AuthorListParams.dump_request(params)
  query = ModerationAPI::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: "authors",
    query: query.transform_keys(
      content_types: "contentTypes",
      last_active_date: "lastActiveDate",
      member_since_date: "memberSinceDate",
      page_number: "pageNumber",
      page_size: "pageSize",
      sort_by: "sortBy",
      sort_direction: "sortDirection"
    ),
    model: ModerationAPI::Models::AuthorListResponse,
    options: options
  )
end

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

Get detailed information about a specific author including historical data and analysis

Parameters:

  • id (String)

    Either external ID or the ID assigned by moderation API.

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

Returns:

See Also:



60
61
62
63
64
65
66
67
# File 'lib/moderation_api/resources/authors.rb', line 60

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

#update(id, email: nil, external_link: nil, first_seen: nil, last_seen: nil, manual_trust_level: nil, metadata: nil, name: nil, profile_picture: nil, request_options: {}) ⇒ ModerationAPI::Models::AuthorUpdateResponse

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

Update the details of a specific author

Parameters:

  • id (String)

    Either external ID or the ID assigned by moderation API.

  • email (String, nil)

    Author email address

  • external_link (String, nil)

    URL of the author’s external profile

  • first_seen (Float)

    Timestamp when author first appeared

  • last_seen (Float)

    Timestamp of last activity

  • manual_trust_level (Float, nil)
  • metadata (ModerationAPI::Models::AuthorUpdateParams::Metadata)

    Additional metadata provided by your system. We recommend including any relevant

  • name (String, nil)

    Author name or identifier

  • profile_picture (String, nil)

    URL of the author’s profile picture

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

Returns:

See Also:



99
100
101
102
103
104
105
106
107
108
# File 'lib/moderation_api/resources/authors.rb', line 99

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