datasift 3.1.5 → 3.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (98) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +3 -2
  3. data/.yardopts +4 -0
  4. data/CHANGELOG.md +23 -0
  5. data/Gemfile +13 -0
  6. data/README.md +17 -16
  7. data/VERSION +1 -1
  8. data/datasift.gemspec +8 -14
  9. data/examples/account_identity_eg.rb +48 -0
  10. data/examples/account_identity_limit_eg.rb +68 -0
  11. data/examples/account_identity_token_eg.rb +70 -0
  12. data/examples/auth.rb +4 -4
  13. data/examples/core_api_eg.rb +1 -2
  14. data/examples/historics_eg.rb +7 -1
  15. data/examples/pylon_eg.rb +116 -0
  16. data/lib/account.rb +6 -0
  17. data/lib/account_identity.rb +73 -0
  18. data/lib/account_identity_limit.rb +85 -0
  19. data/lib/account_identity_token.rb +86 -0
  20. data/lib/api/api_resource.rb +14 -5
  21. data/lib/cli.rb +306 -132
  22. data/lib/datasift.rb +82 -47
  23. data/lib/errors.rb +21 -5
  24. data/lib/historics.rb +71 -40
  25. data/lib/historics_preview.rb +25 -8
  26. data/lib/managed_source.rb +69 -25
  27. data/lib/managed_source_auth.rb +21 -6
  28. data/lib/managed_source_resource.rb +21 -6
  29. data/lib/push.rb +132 -65
  30. data/lib/pylon.rb +122 -0
  31. data/test/datasift/core_api_test.rb +116 -90
  32. data/test/datasift/historics_preview_api_test.rb +27 -58
  33. data/test/datasift/push_api_test.rb +156 -141
  34. data/test/fixtures/cassettes/core/after_historic_dpu.json +1 -0
  35. data/test/fixtures/cassettes/core/balance_get.json +1 -0
  36. data/test/fixtures/cassettes/core/before_dpu.json +1 -0
  37. data/test/fixtures/cassettes/core/before_historic_dpu.json +1 -0
  38. data/test/fixtures/cassettes/core/compile_success.json +1 -0
  39. data/test/fixtures/cassettes/core/dpu_get_cost.json +1 -0
  40. data/test/fixtures/cassettes/core/dpu_throw_badrequest.json +1 -0
  41. data/test/fixtures/cassettes/core/historic_dpu.json +1 -0
  42. data/test/fixtures/cassettes/core/usage_success.json +1 -0
  43. data/test/fixtures/cassettes/core/validate_invalid_hash.json +1 -0
  44. data/test/fixtures/cassettes/core/validate_success_bool.json +1 -0
  45. data/test/fixtures/cassettes/core/validate_success_hash.json +1 -0
  46. data/test/fixtures/cassettes/preview/before_preview_create.json +1 -0
  47. data/test/fixtures/cassettes/preview/before_preview_get.json +1 -0
  48. data/test/fixtures/cassettes/preview/preview_create_success.json +1 -0
  49. data/test/fixtures/cassettes/preview/preview_get_success.json +1 -0
  50. data/test/fixtures/cassettes/push/after_push_create.json +1 -0
  51. data/test/fixtures/cassettes/push/after_push_get.json +1 -0
  52. data/test/fixtures/cassettes/push/after_push_log.json +1 -0
  53. data/test/fixtures/cassettes/push/after_push_pause.json +1 -0
  54. data/test/fixtures/cassettes/push/after_push_resume.json +1 -0
  55. data/test/fixtures/cassettes/push/after_push_stop.json +1 -0
  56. data/test/fixtures/cassettes/push/after_push_update.json +1 -0
  57. data/test/fixtures/cassettes/push/before_push_create.json +1 -0
  58. data/test/fixtures/cassettes/push/before_push_delete.json +1 -0
  59. data/test/fixtures/cassettes/push/before_push_get.json +1 -0
  60. data/test/fixtures/cassettes/push/before_push_log.json +1 -0
  61. data/test/fixtures/cassettes/push/before_push_pause.json +1 -0
  62. data/test/fixtures/cassettes/push/before_push_resume.json +1 -0
  63. data/test/fixtures/cassettes/push/before_push_stop.json +1 -0
  64. data/test/fixtures/cassettes/push/before_push_update.json +1 -0
  65. data/test/fixtures/cassettes/push/push_create.json +1 -0
  66. data/test/fixtures/cassettes/push/push_delete.json +1 -0
  67. data/test/fixtures/cassettes/push/push_get_by_id.json +1 -0
  68. data/test/fixtures/cassettes/push/push_log_with_id.json +1 -0
  69. data/test/fixtures/cassettes/push/push_pause.json +1 -0
  70. data/test/fixtures/cassettes/push/push_resume.json +1 -0
  71. data/test/fixtures/cassettes/push/push_stop.json +1 -0
  72. data/test/fixtures/cassettes/push/push_update.json +1 -0
  73. data/test/fixtures/cassettes/push/push_validate.json +1 -0
  74. data/test/test_helper.rb +31 -1
  75. metadata +64 -104
  76. data/examples/dynamic_list_eg.rb +0 -74
  77. data/examples/dynamic_list_replace_eg.rb +0 -45
  78. data/lib/dynamic_list.rb +0 -66
  79. data/lib/dynamic_list_replace.rb +0 -45
  80. data/test/fixtures/balance.json +0 -1
  81. data/test/fixtures/compile_csdl_invalid.json +0 -1
  82. data/test/fixtures/compile_csdl_valid.json +0 -1
  83. data/test/fixtures/dpu_valid.json +0 -1
  84. data/test/fixtures/preview_create_valid.json +0 -1
  85. data/test/fixtures/preview_get_running.json +0 -1
  86. data/test/fixtures/preview_get_succeeded.json +0 -1
  87. data/test/fixtures/push_create_valid.json +0 -1
  88. data/test/fixtures/push_get_list_by_hash_valid.json +0 -1
  89. data/test/fixtures/push_get_list_by_historics_id_valid.json +0 -1
  90. data/test/fixtures/push_get_list_valid.json +0 -1
  91. data/test/fixtures/push_get_valid.json +0 -1
  92. data/test/fixtures/push_log_valid.json +0 -1
  93. data/test/fixtures/push_pause_valid.json +0 -1
  94. data/test/fixtures/push_stop_valid.json +0 -1
  95. data/test/fixtures/push_validate_valid.json +0 -1
  96. data/test/fixtures/usage_current.json +0 -1
  97. data/test/fixtures/validate_csdl_invalid.json +0 -1
  98. data/test/fixtures/validate_csdl_valid.json +0 -1
data/lib/datasift.rb CHANGED
@@ -16,8 +16,11 @@ require dir + '/managed_source'
16
16
  require dir + '/managed_source_auth'
17
17
  require dir + '/managed_source_resource'
18
18
  require dir + '/live_stream'
19
- require dir + '/dynamic_list'
20
- require dir + '/dynamic_list_replace'
19
+ require dir + '/pylon'
20
+ require dir + '/account'
21
+ require dir + '/account_identity'
22
+ require dir + '/account_identity_token'
23
+ require dir + '/account_identity_limit'
21
24
  #
22
25
  require 'rbconfig'
23
26
 
@@ -39,13 +42,13 @@ module DataSift
39
42
  end
40
43
  end
41
44
 
45
+ # All API requests must be made by a Client object
42
46
  class Client < ApiResource
43
- #+config+:: A hash containing configuration options for the client for e.g.
44
- # {username => 'some_user', api_key => 'ds_api_key', 'enable_ssl' => true, open_timeout => 30, timeout => 30}
47
+ # @param config [Hash] A hash containing configuration options for the
48
+ # client for e.g. { username: 'some_user', api_key: 'ds_api_key',
49
+ # enable_ssl: true, open_timeout: 30, timeout: 30 }
45
50
  def initialize(config)
46
- if config.nil?
47
- raise InvalidConfigError.new('Config cannot be nil')
48
- end
51
+ raise InvalidConfigError.new('Config cannot be nil') if config.nil?
49
52
  if !config.key?(:username) || !config.key?(:api_key)
50
53
  raise InvalidConfigError.new('A valid username and API key are required. ' +
51
54
  'You can check your API credentials at https://datasift.com/settings')
@@ -58,71 +61,97 @@ module DataSift
58
61
  @managed_source_resource = DataSift::ManagedSourceResource.new(config)
59
62
  @managed_source_auth = DataSift::ManagedSourceAuth.new(config)
60
63
  @historics_preview = DataSift::HistoricsPreview.new(config)
61
- @dynamic_list = DataSift::DynamicList.new(config)
62
- @dynamic_list_replace = DataSift::DynamicListReplace.new(config)
64
+ @pylon = DataSift::Pylon.new(config)
65
+ @account = DataSift::Account.new(config)
66
+ @account_identity = DataSift::AccountIdentity.new(config)
67
+ @account_identity_token = DataSift::AccountIdentityToken.new(config)
68
+ @account_identity_limit = DataSift::AccountIdentityLimit.new(config)
63
69
  end
64
70
 
65
71
  attr_reader :historics, :push, :managed_source, :managed_source_resource,
66
- :managed_source_auth, :historics_preview, :dynamic_list,
67
- :dynamic_list_replace
72
+ :managed_source_auth, :historics_preview, :pylon, :account,
73
+ :account_identity, :account_identity_token, :account_identity_limit
68
74
 
69
- ##
70
75
  # Checks if the syntax of the given CSDL is valid
71
- #+boolResponse+ If true then a boolean is returned indicating whether the
72
- # CSDL is valid, otherwise the response object itself is returned
76
+ #
77
+ # @param boolResponse [Boolean] If true a boolean is returned indicating
78
+ # whether the CSDL is valid, otherwise the full response object is returned
73
79
  def valid?(csdl, boolResponse = true)
74
80
  requires({ :csdl => csdl })
75
81
  res = DataSift.request(:POST, 'validate', @config, :csdl => csdl )
76
82
  boolResponse ? res[:http][:status] == 200 : res
77
83
  end
78
84
 
79
- ##
80
85
  # Compile CSDL code.
81
- #+csdl+:: The CSDL you wish to compile
86
+ #
87
+ # @param csdl [String] The CSDL you wish to compile
88
+ # @return [Object] API reponse object
82
89
  def compile(csdl)
83
90
  requires({ :csdl => csdl })
84
91
  DataSift.request(:POST, 'compile', @config, :csdl => csdl )
85
92
  end
86
93
 
87
- ##
88
- # Check the number of objects processed and delivered in a given period
89
- #+period+:: Can be "day", "hour", or "current", defaults to hour
94
+ # Check the number of objects processed for a given time period
95
+ #
96
+ # @param period [String] Can be "day", "hour", or "current"
97
+ # @return [Object] API reponse object
90
98
  def usage(period = :hour)
91
99
  DataSift.request(:POST, 'usage', @config, :period => period )
92
100
  end
93
101
 
94
- ##
95
- # Calculate the DPU cost of consuming a stream.
96
- def dpu(hash)
97
- requires ({ :hash => hash })
98
- DataSift.request(:POST, 'dpu', @config, :hash => hash )
102
+ # Calculate the DPU cost of running a filter, or Historics query
103
+ #
104
+ # @param hash [String] CSDL hash for which you wish to find the DPU cost
105
+ # @param historics_id [String] ID of Historics query for which you wish to
106
+ # find the DPU cost
107
+ # @return [Object] API reponse object
108
+ def dpu(hash = '', historics_id = '')
109
+ fail ArgumentError, 'Must pass a filter hash or Historics ID' if
110
+ hash.empty? && historics_id.empty?
111
+ fail ArgumentError, 'Must only pass hash or Historics ID; not both' unless
112
+ hash.empty? || historics_id.empty?
113
+
114
+ params = {}
115
+ params.merge!(hash: hash) unless hash.empty?
116
+ params.merge!(historics_id: historics_id) unless historics_id.empty?
117
+
118
+ DataSift.request(:POST, 'dpu', @config, params)
99
119
  end
100
120
 
101
- ##
102
121
  # Determine your credit balance or DPU balance.
122
+ #
123
+ # @return [Object] API reponse object
103
124
  def balance
104
125
  DataSift.request(:POST, 'balance', @config)
105
126
  end
106
127
 
107
- ##
108
128
  # Collect a batch of interactions from a push queue
109
- def pull(id, size = 20_971_520, cursor = '')
110
- DataSift.request(:POST, 'pull', @config, { :id => id, :size => size, :cursor => cursor })
129
+ #
130
+ # @param id [String] ID of the Push subscription you wish to pull data from
131
+ # @param size [Integer] Max size (bytes) of the data you can receive from a
132
+ # /pull API call
133
+ # @param cursor [String] A pointer into the Push queue associated with your
134
+ # last delivery
135
+ # @return [Object] API reponse object
136
+ def pull(id, size = 20_971_520, cursor='')
137
+ DataSift.request(:POST, 'pull', @config, { :id => id, :size => size,
138
+ :cursor => cursor })
111
139
  end
112
140
  end
113
141
 
114
142
  # Generates and executes an HTTP request from the params provided
115
- # Params:
116
- # +method+:: the HTTP method to use e.g. GET,POST
117
- # +path+:: the DataSift path relevant to the base URL of the API
118
- # +username+:: API username
119
- # +api_key+:: DS api key
120
- # +params+:: A hash representing the params to use in the request, if its a
121
- # GET, HEAD or DELETE request these params are used as query string params,
122
- # if not they become form url encoded params
123
- # +headers+:: any headers to pass to the API, Authorization header is
124
- # automatically included
125
- def self.request(method, path, config, params = {}, headers = {}, timeout = 30, open_timeout = 30, new_line_separated = false)
143
+ #
144
+ # @param method [Symbol] The HTTP method to use
145
+ # @param path [String] The DataSift path relevant to the base URL of the API
146
+ # @param config [Object] The config object containing user details
147
+ # @param params [Hash] A hash representing the params to use in the request
148
+ # @param headers [Hash] Any headers to pass to the API
149
+ # @param timeout [Integer] Set the request timeout
150
+ # @param open_timeout [Integer] Set the request open timeout
151
+ # @param new_line_separated [Boolean] Will response be newline separated?
152
+ def self.request(method, path, config, params = {}, headers = {},
153
+ timeout = 30, open_timeout = 30, new_line_separated = false)
154
+
126
155
  validate config
127
156
  options = {}
128
157
  url = build_url(path, config)
@@ -206,6 +235,8 @@ module DataSift
206
235
  end
207
236
  end
208
237
 
238
+ private
239
+
209
240
  def self.build_url(path, config)
210
241
  'http' + (config[:enable_ssl] ? 's' : '') + '://' + config[:api_host] +
211
242
  '/' + config[:api_version] + '/' + path
@@ -228,14 +259,18 @@ module DataSift
228
259
 
229
260
  def self.handle_api_error(code, body)
230
261
  case code
231
- when 400
232
- raise BadRequestError.new(code, body)
233
- when 401
234
- raise AuthError.new(code, body)
235
- when 404
236
- raise ApiResourceNotFoundError.new(code, body)
237
- else
238
- raise DataSiftError.new(code, body)
262
+ when 400
263
+ raise BadRequestError.new(code, body)
264
+ when 401
265
+ raise AuthError.new(code, body)
266
+ when 404
267
+ raise ApiResourceNotFoundError.new(code, body)
268
+ when 409
269
+ raise ConflictError.new(code, body)
270
+ when 410
271
+ raise GoneError.new(code, body)
272
+ else
273
+ raise DataSiftError.new(code, body)
239
274
  end
240
275
  end
241
276
 
data/lib/errors.rb CHANGED
@@ -1,3 +1,4 @@
1
+ # Custom error class for rescuing DataSift errors
1
2
  class DataSiftError < StandardError
2
3
  attr_reader :status
3
4
  attr_reader :body
@@ -8,13 +9,14 @@ class DataSiftError < StandardError
8
9
  end
9
10
 
10
11
  def message
11
- @body == nil ? @status : @body
12
+ @body.nil? ? @status : @body
12
13
  end
13
14
 
14
15
  def to_s
15
- #if both body and status were provided then message is the body otherwise the status contains the message
16
- msg = !@body.nil? && !@status.nil? ? @body : @status
17
- #if body is nil then status is the message body so no status is included
16
+ # If both body and status were provided then message is the body otherwise
17
+ # the status contains the message
18
+ msg = !@body.nil? && !@status.nil? ? @body : @status
19
+ # If body is nil then status is the message body so no status is included
18
20
  status_string = @body.nil? ? '' : "(Status #{@status}) "
19
21
  "#{status_string} : #{msg}"
20
22
  end
@@ -23,18 +25,29 @@ end
23
25
  class NotSupportedError < DataSiftError
24
26
  end
25
27
 
28
+ # Standard error returned when receiving a 400 response from the API
26
29
  class BadRequestError < DataSiftError
27
30
  end
28
31
 
32
+ # Standard error returned when receiving a 401 response from the API
29
33
  class AuthError < DataSiftError
30
34
  end
31
35
 
32
36
  class ConnectionError < DataSiftError
33
37
  end
34
38
 
39
+ # Standard error returned when receiving a 404 response from the API
35
40
  class ApiResourceNotFoundError < DataSiftError
36
41
  end
37
42
 
43
+ # Standard error returned when receiving a 409 response from the API
44
+ class ConflictError < DataSiftError
45
+ end
46
+
47
+ # Standard error returned when receiving a 410 response from the API
48
+ class GoneError < DataSiftError
49
+ end
50
+
38
51
  class InvalidConfigError < DataSiftError
39
52
  end
40
53
 
@@ -55,7 +68,10 @@ end
55
68
 
56
69
  class StreamingMessageError < DataSiftError
57
70
  end
71
+
58
72
  class WebSocketOnWindowsError < DataSiftError
59
73
  end
74
+
75
+ # Standard error returned when trying to use a method while missing parameters
60
76
  class BadParametersError < DataSiftError
61
- end
77
+ end
data/lib/historics.rb CHANGED
@@ -1,94 +1,125 @@
1
1
  module DataSift
2
+ # Methods for using DataSift Historics
2
3
  class Historics < DataSift::ApiResource
3
-
4
- ##
5
- # Create a new historics query and return its id.
6
- def prepare (hash, start, end_time, name, sources = 'twitter', sample = 100)
4
+ # Prepare a new Historics query
5
+ #
6
+ # @param hash [String] Hash of compiled CSDL filter
7
+ # @param start [Integer] Start timestamp for your Historics Query. Should be
8
+ # provided as a Unix timestamp
9
+ # @param end_time [Integer] End timestamp for your Historics Query. Should
10
+ # be provided as a Unix timestamp
11
+ # @param name [String] The name of your Historics query
12
+ # @param sources [String] Comma separated list of data sources you wish to
13
+ # query
14
+ # @param sample [Integer] Sample size of your Historics query
15
+ # @return [Object] API reponse object
16
+ def prepare(hash, start, end_time, name, sources = 'twitter', sample = 100)
7
17
  params = {
8
- :hash => hash,
9
- :start => start,
10
- :end => end_time,
11
- :name => name,
12
- :sources => sources,
13
- :sample => sample
18
+ :hash => hash,
19
+ :start => start,
20
+ :end => end_time,
21
+ :name => name,
22
+ :sources => sources,
23
+ :sample => sample
14
24
  }
15
25
  requires params
16
26
  DataSift.request(:POST, 'historics/prepare', @config, params)
17
27
  end
18
28
 
19
- # Pause historics query.
29
+ # Pause Historics query
30
+ #
31
+ # @param id [String] ID of the Historics query you need to pause
32
+ # @param reason [String] You can give a reason for pausing the query
20
33
  def pause(id, reason = '')
21
- params = {:id => id}
34
+ params = { :id => id }
22
35
  requires params
23
36
  params[:reason] = reason
24
37
  DataSift.request(:PUT, 'historics/pause', @config, params)
25
38
  end
26
39
 
27
- ##
28
- # Resume historics query.
40
+ # Resume Historics query
41
+ #
42
+ # @param id [String] ID of the Historics query you need to resume
29
43
  def resume(id)
30
- params = {:id => id}
44
+ params = { :id => id }
31
45
  requires params
32
46
  DataSift.request(:PUT, 'historics/resume', @config, params)
33
47
  end
34
48
 
35
- ##
36
- # Starts historics query.
49
+ # Start Historics query
50
+ #
51
+ # @param id [String] ID of the Historics query you need to start
37
52
  def start(id)
38
- params = {:id => id}
53
+ params = { :id => id }
39
54
  requires params
40
55
  DataSift.request(:POST, 'historics/start', @config, params)
41
56
  end
42
57
 
43
- ##
44
- # Stop historics query.
58
+ # Stop Historics query
59
+ #
60
+ # @param id [String] ID of the Historics query you need to stop
61
+ # @param reason [String] You can give a reason for stopping the query
45
62
  def stop(id, reason = '')
46
- params = {:id => id}
63
+ params = { :id => id }
47
64
  requires params
48
65
  params[:reason] = reason
49
66
  DataSift.request(:POST, 'historics/stop', @config, params)
50
67
  end
51
- ##
52
68
 
53
- ##
54
- # Check the data coverage in the archive for a specified interval.
55
- def status(start, end_time, sources='twitter')
56
- params = {:start => start, :end => end_time, :sources => sources}
69
+ # Check the data coverage in the archive for a specified interval
70
+ #
71
+ # @param start [Integer] Start timestamp for the period you wish to query.
72
+ # Should be provided as a Unix timestamp
73
+ # @param end_time [Integer] End timestamp for the period you wish to query.
74
+ # Should be provided as a Unix timestamp
75
+ # @param sources [String] Comma separated list of data sources you wish to
76
+ # query
77
+ def status(start, end_time, sources = 'twitter')
78
+ params = { :start => start, :end => end_time, :sources => sources }
57
79
  requires params
58
80
  DataSift.request(:GET, 'historics/status', @config, params)
59
81
  end
60
82
 
61
- ##
62
- # Update a historics query's name.
83
+ # Update the name of an Historics query
84
+ #
85
+ # @param id [String] ID of the Historics query you need to update
86
+ # @param name [String] New name for the Historics query
63
87
  def update(id, name)
64
- params = {:id => id, :name => name}
88
+ params = { :id => id, :name => name }
65
89
  requires params
66
90
  DataSift.request(:POST, 'historics/update', @config, params)
67
91
  end
68
92
 
69
- ##
70
- # Delete a historics query.
93
+ # Delete an Historics query
94
+ #
95
+ # @param id [String] ID of the Historics query you need to delete
71
96
  def delete(id)
72
- params = {:id => id}
97
+ params = { :id => id }
73
98
  requires params
74
99
  DataSift.request(:DELETE, 'historics/delete', @config, params)
75
100
  end
76
101
 
77
- ##
78
- # Get details for a given historics query.
102
+ # Get details for a given Historics query
103
+ #
104
+ # @param id [String] ID of the Historics query you need to get
105
+ # @param with_estimate [Boolean] 1 or 0 indicating whether you want to see
106
+ # the estimated completion time of the Historics query
79
107
  def get_by_id(id, with_estimate = 1)
80
- params = {:id => id, :with_estimate => with_estimate}
108
+ params = { :id => id, :with_estimate => with_estimate }
81
109
  requires params
82
110
  DataSift.request(:GET, 'historics/get', @config, params)
83
111
  end
84
112
 
85
- ##
86
- # Get details for a set of historics within the given page constraints.
87
- def get(max=20, page=1, with_estimate = 1)
88
- params = {:max => max, :page => page, :with_estimate => with_estimate}
113
+ # Get details for a list of Historics within the given page constraints
114
+ #
115
+ # @param max [Integer] Max number of Historics you wish to return per page
116
+ # @param page [Integer] Which page of results you need returned
117
+ # @param with_estimate [Boolean] 1 or 0 indicating whether you want to see
118
+ # the estimated completion time of the Historics query
119
+ def get(max = 20, page = 1, with_estimate = 1)
120
+ params = { :max => max, :page => page, :with_estimate => with_estimate }
89
121
  requires params
90
122
  DataSift.request(:GET, 'historics/get', @config, params)
91
123
  end
92
-
93
124
  end
94
125
  end
@@ -1,21 +1,38 @@
1
1
  module DataSift
2
+ # Methods for using DataSift Historics Previews
2
3
  class HistoricsPreview < DataSift::ApiResource
3
-
4
+ # Create a new Historics Preview
5
+ #
6
+ # @param hash [String] Hash of compiled CSDL definition
7
+ # @param sources [String] Comma separated list of data sources you wish to
8
+ # perform this Historics Preview against
9
+ # @param parameters [String] Historics Preview parameters. See our
10
+ # {http://dev.datasift.com/docs/api/1/previewcreate /preview/create API
11
+ # Docs} for full documentation
12
+ # @param start [String] Start timestamp for your Historics Preview. Should
13
+ # be provided as Unix timestamp
14
+ # @param end_time [String] End timestamp for your Historics Preview. Should
15
+ # be provided as Unix timestamp
4
16
  def create(hash, sources, parameters, start, end_time = nil)
5
17
  params = {
6
- :hash => hash,
7
- :sources => sources,
8
- :parameters => parameters,
9
- :start => start
18
+ :hash => hash,
19
+ :sources => sources,
20
+ :parameters => parameters,
21
+ :start => start
10
22
  }
11
- params.merge!(:end => end_time) if end_time != nil
23
+ requires params
24
+ params.merge!(:end => end_time) unless end_time.nil?
12
25
 
13
26
  DataSift.request(:POST, 'preview/create', @config, params)
14
27
  end
15
28
 
29
+ # Retreive an Historics Preview
30
+ #
31
+ # @param id [String] ID of the Historics Preview
16
32
  def get(id)
17
- DataSift.request(:POST, 'preview/get', @config, {:id => id})
33
+ params = { :id => id }
34
+ requires params
35
+ DataSift.request(:POST, 'preview/get', @config, params)
18
36
  end
19
-
20
37
  end
21
38
  end