Class: DataSift::AccountIdentity

Inherits:
ApiResource show all
Defined in:
lib/account_identity.rb

Overview

Class for accessing DataSift’s Account API Identities

Constant Summary

Constants inherited from ApiResource

DataSift::ApiResource::TLSv1, DataSift::ApiResource::TLSv1_2

Constants included from DataSift

APPLICATION_JSON, DELETE, DETECT_DEAD_SOCKETS, GET, HEAD, IS_WINDOWS, KNOWN_SOCKETS, SOCKET_DETECTOR_TIMEOUT, VERSION, X_ANALYSIS_TASKS_QUEUED, X_ANALYSIS_TASKS_QUEUE_LIMIT, X_INSIGHT_TASKS_QUEUED, X_INSIGHT_TASKS_QUEUE_LIMIT, X_RATELIMIT_COST, X_RATELIMIT_LIMIT, X_RATELIMIT_REMAINING, X_TASKS_QUEUED, X_TASKS_QUEUE_LIMIT

Instance Method Summary collapse

Methods inherited from ApiResource

#initialize, #requires

Methods included from DataSift

#build_path, request

Constructor Details

This class inherits a constructor from DataSift::ApiResource

Instance Method Details

#create(label = '', status = 'active', master = '') ⇒ Object

Creates a new Identity

Parameters:

  • label (String) (defaults to: '')

    A unique identifier for this Identity

  • status (String) (defaults to: 'active')

    (Optional, Default: “active”) What status this Identity currently has. Possible values are ‘active’ and ‘disabled’

  • master (Boolean) (defaults to: '')

    (Optional, Default: false) Whether this is the master Identity for your account

Returns:

  • (Object)

    API reponse object



13
14
15
16
17
18
19
20
21
# File 'lib/account_identity.rb', line 13

def create(label = '', status = 'active', master = '')
  fail ArgumentError, 'label is missing' if label.empty?

  params = { label: label }
  params.merge!(status: status) unless status.empty?
  params.merge!(master: master) if [TrueClass, FalseClass].include?(master.class)

  DataSift.request(:POST, 'account/identity', @config, params)
end

#delete(id) ⇒ Object

Deletes a specific Identity by ID

Parameters:

  • id (String)

    ID of the Identity you wish to delete

Returns:

  • (Object)

    API response object



69
70
71
# File 'lib/account_identity.rb', line 69

def delete(id)
  DataSift.request(:DELETE, "account/identity/#{id}", @config)
end

#get(id) ⇒ Object

Gets a specific Identity by ID

Parameters:

  • id (String)

    ID of the Identity you wish to return

Returns:

  • (Object)

    API reponse object



27
28
29
# File 'lib/account_identity.rb', line 27

def get(id)
  DataSift.request(:GET, "account/identity/#{id}", @config)
end

#list(label = '', per_page = '', page = '') ⇒ Object

Returns a list of Identities

Parameters:

  • label (String) (defaults to: '')

    (Optional) Search by a given Identity label

  • per_page (Integer) (defaults to: '')

    (Optional) How many Identities should be returned per page of results

  • page (Integer) (defaults to: '')

    (Optional) Which page of results to return

Returns:

  • (Object)

    API reponse object



38
39
40
41
42
43
44
45
# File 'lib/account_identity.rb', line 38

def list(label = '', per_page = '', page = '')
  params = {}
  params.merge!(label: label) unless label.empty?
  params.merge!(per_page: per_page) unless per_page.empty?
  params.merge!(page: page) unless page.empty?

  DataSift.request(:GET, 'account/identity', @config, params)
end

#update(id = '', label = '', status = '', master = '') ⇒ Object

Updates a specific Identity by ID

Parameters:

  • id (String) (defaults to: '')

    ID of the Identity you are updating

  • label (String) (defaults to: '')

    (Optional) New label value

  • status (String) (defaults to: '')

    (Optional) New status for this Identity

  • master (Boolean) (defaults to: '')

    (Optional) Whether this Identity should be master

Returns:

  • (Object)

    API reponse object



54
55
56
57
58
59
60
61
62
63
# File 'lib/account_identity.rb', line 54

def update(id = '', label = '', status = '', master = '')
  fail ArgumentError, 'id is missing' if id.empty?

  params = {}
  params.merge!(label: label) unless label.empty?
  params.merge!(status: status) unless status.empty?
  params.merge!(master: master) if [TrueClass, FalseClass].include?(master.class)

  DataSift.request(:PUT, "account/identity/#{id}", @config, params)
end