Class: DataSift::Client
- Inherits:
-
ApiResource
- Object
- ApiResource
- DataSift::Client
- Defined in:
- lib/datasift.rb
Overview
All API requests must be made by a Client object
Constant Summary
Constants inherited from ApiResource
ApiResource::TLSv1, 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 Attribute Summary collapse
-
#account ⇒ Object
readonly
Returns the value of attribute account.
-
#account_identity ⇒ Object
readonly
Returns the value of attribute account_identity.
-
#account_identity_limit ⇒ Object
readonly
Returns the value of attribute account_identity_limit.
-
#account_identity_token ⇒ Object
readonly
Returns the value of attribute account_identity_token.
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#historics ⇒ Object
readonly
Returns the value of attribute historics.
-
#historics_preview ⇒ Object
readonly
Returns the value of attribute historics_preview.
-
#managed_source ⇒ Object
readonly
Returns the value of attribute managed_source.
-
#managed_source_auth ⇒ Object
readonly
Returns the value of attribute managed_source_auth.
-
#managed_source_resource ⇒ Object
readonly
Returns the value of attribute managed_source_resource.
-
#odp ⇒ Object
readonly
Returns the value of attribute odp.
-
#push ⇒ Object
readonly
Returns the value of attribute push.
-
#pylon ⇒ Object
readonly
Returns the value of attribute pylon.
-
#task ⇒ Object
readonly
Returns the value of attribute task.
Instance Method Summary collapse
-
#balance ⇒ Object
Determine your credit balance or DPU balance.
-
#compile(csdl) ⇒ Object
Compile CSDL code.
-
#dpu(hash = '', historics_id = '') ⇒ Object
Calculate the DPU cost of running a filter, or Historics query.
-
#initialize(config) ⇒ Client
constructor
A new instance of Client.
-
#pull(id, size = 20_971_520, cursor = '') ⇒ Object
Collect a batch of interactions from a push queue.
-
#usage(period = :hour) ⇒ Object
Check the number of objects processed for a given time period.
-
#valid?(csdl, boolResponse = true) ⇒ Boolean
Checks if the syntax of the given CSDL is valid.
Methods inherited from ApiResource
Methods included from DataSift
Constructor Details
#initialize(config) ⇒ Client
Returns a new instance of Client.
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/datasift.rb', line 67 def initialize(config) raise InvalidConfigError.new('Config cannot be nil') if config.nil? if !config.key?(:username) || !config.key?(:api_key) raise InvalidConfigError.new('A valid username and API key are required. ' + 'You can check your API credentials at https://app.datasift.com/settings') end @config = config @historics = DataSift::Historics.new(config) @push = DataSift::Push.new(config) @managed_source = DataSift::ManagedSource.new(config) @managed_source_resource = DataSift::ManagedSourceResource.new(config) @managed_source_auth = DataSift::ManagedSourceAuth.new(config) @historics_preview = DataSift::HistoricsPreview.new(config) @pylon = DataSift::Pylon.new(config) @task = DataSift::Task.new(config) @account = DataSift::Account.new(config) @account_identity = DataSift::AccountIdentity.new(config) @account_identity_token = DataSift::AccountIdentityToken.new(config) @account_identity_limit = DataSift::AccountIdentityLimit.new(config) @odp = DataSift::Odp.new(config) end |
Instance Attribute Details
#account ⇒ Object (readonly)
Returns the value of attribute account.
90 91 92 |
# File 'lib/datasift.rb', line 90 def account @account end |
#account_identity ⇒ Object (readonly)
Returns the value of attribute account_identity.
90 91 92 |
# File 'lib/datasift.rb', line 90 def account_identity @account_identity end |
#account_identity_limit ⇒ Object (readonly)
Returns the value of attribute account_identity_limit.
90 91 92 |
# File 'lib/datasift.rb', line 90 def account_identity_limit @account_identity_limit end |
#account_identity_token ⇒ Object (readonly)
Returns the value of attribute account_identity_token.
90 91 92 |
# File 'lib/datasift.rb', line 90 def account_identity_token @account_identity_token end |
#config ⇒ Object (readonly)
Returns the value of attribute config.
90 91 92 |
# File 'lib/datasift.rb', line 90 def config @config end |
#historics ⇒ Object (readonly)
Returns the value of attribute historics.
90 91 92 |
# File 'lib/datasift.rb', line 90 def historics @historics end |
#historics_preview ⇒ Object (readonly)
Returns the value of attribute historics_preview.
90 91 92 |
# File 'lib/datasift.rb', line 90 def historics_preview @historics_preview end |
#managed_source ⇒ Object (readonly)
Returns the value of attribute managed_source.
90 91 92 |
# File 'lib/datasift.rb', line 90 def managed_source @managed_source end |
#managed_source_auth ⇒ Object (readonly)
Returns the value of attribute managed_source_auth.
90 91 92 |
# File 'lib/datasift.rb', line 90 def managed_source_auth @managed_source_auth end |
#managed_source_resource ⇒ Object (readonly)
Returns the value of attribute managed_source_resource.
90 91 92 |
# File 'lib/datasift.rb', line 90 def managed_source_resource @managed_source_resource end |
#odp ⇒ Object (readonly)
Returns the value of attribute odp.
90 91 92 |
# File 'lib/datasift.rb', line 90 def odp @odp end |
#push ⇒ Object (readonly)
Returns the value of attribute push.
90 91 92 |
# File 'lib/datasift.rb', line 90 def push @push end |
#pylon ⇒ Object (readonly)
Returns the value of attribute pylon.
90 91 92 |
# File 'lib/datasift.rb', line 90 def pylon @pylon end |
#task ⇒ Object (readonly)
Returns the value of attribute task.
90 91 92 |
# File 'lib/datasift.rb', line 90 def task @task end |
Instance Method Details
#balance ⇒ Object
Determine your credit balance or DPU balance.
143 144 145 |
# File 'lib/datasift.rb', line 143 def balance DataSift.request(:POST, 'balance', @config) end |
#compile(csdl) ⇒ Object
Compile CSDL code.
108 109 110 111 |
# File 'lib/datasift.rb', line 108 def compile(csdl) requires({ :csdl => csdl }) DataSift.request(:POST, 'compile', @config, :csdl => csdl ) end |
#dpu(hash = '', historics_id = '') ⇒ Object
Calculate the DPU cost of running a filter, or Historics query
127 128 129 130 131 132 133 134 135 136 137 138 |
# File 'lib/datasift.rb', line 127 def dpu(hash = '', historics_id = '') fail ArgumentError, 'Must pass a filter hash or Historics ID' if hash.empty? && historics_id.empty? fail ArgumentError, 'Must only pass hash or Historics ID; not both' unless hash.empty? || historics_id.empty? params = {} params.merge!(hash: hash) unless hash.empty? params.merge!(historics_id: historics_id) unless historics_id.empty? DataSift.request(:POST, 'dpu', @config, params) end |
#pull(id, size = 20_971_520, cursor = '') ⇒ Object
Collect a batch of interactions from a push queue
155 156 157 158 |
# File 'lib/datasift.rb', line 155 def pull(id, size = 20_971_520, cursor='') DataSift.request(:POST, 'pull', @config, { :id => id, :size => size, :cursor => cursor }) end |
#usage(period = :hour) ⇒ Object
Check the number of objects processed for a given time period
117 118 119 |
# File 'lib/datasift.rb', line 117 def usage(period = :hour) DataSift.request(:POST, 'usage', @config, :period => period ) end |
#valid?(csdl, boolResponse = true) ⇒ Boolean
Checks if the syntax of the given CSDL is valid
whether the CSDL is valid, otherwise the full response object is returned
98 99 100 101 102 |
# File 'lib/datasift.rb', line 98 def valid?(csdl, boolResponse = true) requires({ :csdl => csdl }) res = DataSift.request(:POST, 'validate', @config, :csdl => csdl ) boolResponse ? res[:http][:status] == 200 : res end |