Class: DataSift::AccountIdentityLimit

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

Overview

Class for accessing DataSift’s Account API Identity Limits

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 = '', total_allowance = nil, analyze_queries = nil) ⇒ Object

Creates a Limit for an Identity

Parameters:

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

    ID of the Identity for which you are creating a limit

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

    The service this limit will apply to. For example; ‘facebook’

  • total_allowance (Integer) (defaults to: nil)

    (Optional) The daily interaction limit for this Identity

  • analyze_queries (Integer) (defaults to: nil)

    (Optional) The hourly analysis query limit for this Identity

Returns:

  • (Object)

    API reponse object



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

def create(identity_id = '', service = '', total_allowance = nil, analyze_queries = nil)
  fail BadParametersError, 'identity_id is required' if identity_id.empty?
  fail BadParametersError, 'service is required' if service.empty?
  fail BadParametersError, 'Must set total_allowance or analyze_queries' if
    total_allowance.nil? && analyze_queries.nil?
  params = { service: service }
  params[:total_allowance] = total_allowance unless total_allowance.nil?
  params[:analyze_queries] = analyze_queries unless analyze_queries.nil?

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

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

Removes a Service Limit for an Identity

Parameters:

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

    ID of the Identity for which you wish to remove the Limit

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

    Service from which you wish to remove the Limit

Returns:

  • (Object)

    API response object



83
84
85
86
87
88
# File 'lib/account_identity_limit.rb', line 83

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}/limit/#{service}", @config)
end

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

Get the Limit for a given Identity and Service

Parameters:

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

    ID of the Identity you wish to return limits for

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

    Name of the service you are retreiving limits for

Returns:

  • (Object)

    API reponse object



32
33
34
35
36
37
# File 'lib/account_identity_limit.rb', line 32

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}/limit/#{service}", @config)
end

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

Returns a list Identities and their Limits for a given Service

Parameters:

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

    ID of the Identity we are fetching Limits for

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

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

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

    (Optional) Which page of results to return

Returns:

  • (Object)

    API reponse object



46
47
48
49
50
51
52
53
54
# File 'lib/account_identity_limit.rb', line 46

def list(service = '', per_page = '', page = '')
  fail BadParametersError, 'service is required' if service.empty?

  params = {}
  params[:per_page] = per_page unless per_page.empty?
  params[:page] = page unless page.empty?

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

#update(identity_id = '', service = '', total_allowance = nil, analyze_queries = nil) ⇒ Object

Updates a Limit for an Identity by Service

Parameters:

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

    ID of the Identity for which you are updating a limit

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

    The service this limit will apply to. For example; ‘facebook’

  • total_allowance (Integer) (defaults to: nil)

    (Optional) The daily interaction limit for this Identity

  • analyze_queries (Integer) (defaults to: nil)

    (Optional) The hourly analysis query limit for this Identity

Returns:

  • (Object)

    API reponse object



65
66
67
68
69
70
71
72
73
74
75
# File 'lib/account_identity_limit.rb', line 65

def update(identity_id = '', service = '', total_allowance = nil, analyze_queries = nil)
  fail BadParametersError, 'identity_id is required' if identity_id.empty?
  fail BadParametersError, 'service is required' if service.empty?
  fail BadParametersError, 'Must set total_allowance or analyze_queries' if
    total_allowance.nil? && analyze_queries.nil?
  params = {}
  params[:total_allowance] = total_allowance unless total_allowance.nil?
  params[:analyze_queries] = analyze_queries unless analyze_queries.nil?

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