passivetotal 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 466cf1dbb64b1dd6a08c99f7fe7b704abd5174f7
4
- data.tar.gz: 7d83f321c9d76c14fa90ab614a44a60dbb2aa1bf
3
+ metadata.gz: ba999440914765150f5879f7e1477360c8004395
4
+ data.tar.gz: 4c5af19bed80397c721e95908500993825d15675
5
5
  SHA512:
6
- metadata.gz: 30b2003a7f8a0336eb11110e3fbce59a9a0ddeb62493c0ad9c1244d1f44226d16a8f8fafeda08296e5e34b756baf0cfea7cabde3792d9ea311f8fdf6b88cc63f
7
- data.tar.gz: 3b0127725ccba2de6fe62a8baf99aefaa18f4dc032fa5b32a47a9160398e37f1e905c280f7b4e24971589ef26ca3fbcd7d24f9212a3b058fe8959e9a6d49f760
6
+ metadata.gz: 3ab4e9de47859d9a39ff2529701fdeb7bd71f625dfa62643a2ab043bca552c0e51a796401b008f7a1024a8f1f6acbe1aaec1e9c7c27e6f67338f5b6898130289
7
+ data.tar.gz: e7b9320ce2cd7638ee222220ed314de0c7044c5675273bc5be2b6e2fed643f568c36a324161a302cf3250b85f5d01207c95777275ba2095c57e79c18a4761a69
@@ -10,6 +10,10 @@ module PassiveTotal # :nodoc:
10
10
 
11
11
  class InvalidAPIKeyError < ArgumentError; end
12
12
 
13
+ class Transaction < Struct.new(:query, :response, :response_time); end
14
+ class Query < Struct.new(:api, :query, :set, :url, :parameters); end
15
+ class Response < Struct.new(:json, :success, :request_time, :raw_query, :error, :result_count, :results); end
16
+
13
17
  # The API class wraps the PassiveTotal.org web API for all the verbs that it supports
14
18
  # See https://www.passivetotal.org/api/docs for the API documentation.
15
19
  class API
@@ -273,7 +277,14 @@ module PassiveTotal # :nodoc:
273
277
  response = http.request(request)
274
278
  delta = (Time.now - t1).to_f
275
279
  data = JSON.parse(response.body)
276
- return data
280
+
281
+ obj = Transaction.new(
282
+ Query.new(method, params['query'], params[method] || params['tag'], url, params),
283
+ Response.new(response.body, data['success'], data['request_time'], data['raw_query'], data['error'], data['result_count'], data['results']),
284
+ delta
285
+ )
286
+
287
+ return obj
277
288
  end
278
289
 
279
290
  # tests an item to see if it matches a valid type
@@ -148,7 +148,8 @@ module PassiveTotal # :nodoc:
148
148
  else
149
149
  data = pt.send(options[:method], options[:query])
150
150
  end
151
- return JSON.pretty_generate(data['results'])
151
+ data.response.results['response_time'] = data.query.response_time
152
+ return JSON.pretty_generate(data.response.results)
152
153
  end
153
154
  return ''
154
155
  end
@@ -1,3 +1,3 @@
1
1
  module PassiveTotal
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: passivetotal
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - chrislee35
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-07-03 00:00:00.000000000 Z
11
+ date: 2015-07-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json