Class: DataSift::AccountIdentityToken

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

Overview

Class for accessing DataSift’s Account API Identity Tokens

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(identity_id = '', service = '', token = '') ⇒ Object

Creates a new Identity Token

Parameters:

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

    ID of the Identity for which you are creating a token

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

    The service this token will be used to access. For example; ‘facebook’

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

    The token provided by the PYLON data provider

Returns:

  • (Object)

    API reponse object



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

def create(identity_id = '', service = '', token = '')
  fail BadParametersError, 'identity_id is required' if identity_id.empty?
  fail BadParametersError, 'service is required' if service.empty?
  fail BadParametersError, 'token is required' if token.empty?
  params = {
    service: service,
    token: token
  }

  DataSift.request(:POST, "account/identity/#{identity_id}/token", @config, params)
end

#delete(identity_id = '', service = '') ⇒ Object

Deletes a specific Token by Identity and Service

Parameters:

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

    ID of the Identity for which you wish to delete a token

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

    Service from which you wish to delete a token

Returns:

  • (Object)

    API response object



79
80
81
82
83
84
# File 'lib/account_identity_token.rb', line 79

def delete(identity_id = '', service = '')
  fail BadParametersError, 'identity_id is required' if identity_id.empty?
  fail BadParametersError, 'service is required' if service.empty?

  DataSift.request(:DELETE, "account/identity/#{identity_id}/token/#{service}", @config)
end

#get(identity_id = '', service = '') ⇒ Object

Get a Token for a given Identity and Service

Parameters:

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

    ID of the Identity you wish to return tokens for

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

    Name of the service you are retreiving tokens for

Returns:

  • (Object)

    API reponse object



31
32
33
34
35
36
# File 'lib/account_identity_token.rb', line 31

def get(identity_id = '', service = '')
  fail BadParametersError, 'identity_id is required' if identity_id.empty?
  fail BadParametersError, 'service is required' if service.empty?

  DataSift.request(:GET, "account/identity/#{identity_id}/token/#{service}", @config)
end

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

Returns a list of Tokens for a given Identity

Parameters:

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

    ID of the Identity we are fetching Tokens for

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

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

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

    (Optional) Which page of results to return

Returns:

  • (Object)

    API reponse object



45
46
47
48
49
50
51
52
# File 'lib/account_identity_token.rb', line 45

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

  DataSift.request(:GET, "account/identity/#{identity_id}/token", @config, params)
end

#update(identity_id = '', service = '', token = '') ⇒ Object

Updates a specific Token by Identity ID and Service

Parameters:

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

    ID of the Identity you are updating a token for

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

    The service this token will be used to access. For example; ‘facebook’

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

    The token provided by the PYLON data provider

Returns:

  • (Object)

    API reponse object



62
63
64
65
66
67
68
69
70
71
# File 'lib/account_identity_token.rb', line 62

def update(identity_id = '', service = '', token = '')
  fail BadParametersError, 'identity_id is required' if identity_id.empty?
  fail BadParametersError, 'service is required' if service.empty?
  fail BadParametersError, 'token is required' if token.empty?
  params = {
    token: token
  }

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