Class: Tripwire::Server::FingerprintsResource

Inherits:
BaseResource
  • Object
show all
Defined in:
lib/tripwire/server/client.rb

Instance Method Summary collapse

Methods inherited from BaseResource

#initialize

Constructor Details

This class inherits a constructor from Tripwire::Server::BaseResource

Instance Method Details

#get(visitor_id) ⇒ Object



205
206
207
# File 'lib/tripwire/server/client.rb', line 205

def get(visitor_id)
  @client.request_json("GET", "/v1/fingerprints/#{CGI.escape(visitor_id)}")[:data]
end

#iter(limit: nil, search: nil, sort: nil) ⇒ Object



209
210
211
212
213
214
215
216
217
218
219
220
# File 'lib/tripwire/server/client.rb', line 209

def iter(limit: nil, search: nil, sort: nil)
  Enumerator.new do |yielder|
    cursor = nil
    loop do
      page = list(limit: limit, cursor: cursor, search: search, sort: sort)
      page.items.each { |item| yielder << item }
      break unless page.has_more && page.next_cursor

      cursor = page.next_cursor
    end
  end
end

#list(limit: nil, cursor: nil, search: nil, sort: nil) ⇒ Object



195
196
197
198
199
200
201
202
203
# File 'lib/tripwire/server/client.rb', line 195

def list(limit: nil, cursor: nil, search: nil, sort: nil)
  payload = @client.request_json("GET", "/v1/fingerprints", query: {
    limit: limit,
    cursor: cursor,
    search: search,
    sort: sort
  })
  list_result(payload)
end