Class: AccessGrid::Console

Inherits:
Object
  • Object
show all
Defined in:
lib/accessgrid/console.rb

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ Console

Returns a new instance of Console.



4
5
6
# File 'lib/accessgrid/console.rb', line 4

def initialize(client)
  @client = client
end

Instance Method Details

#create_template(params) ⇒ Object



8
9
10
11
12
# File 'lib/accessgrid/console.rb', line 8

def create_template(params)
  transformed_params = transform_template_params(params)
  response = @client.make_request(:post, '/api/v1/enterprise/templates', transformed_params)
  Template.new(response)
end

#event_log(params) ⇒ Object



26
27
28
29
30
# File 'lib/accessgrid/console.rb', line 26

def event_log(params)
  card_template_id = params.delete(:card_template_id)
  response = @client.make_request(:get, "/api/v1/enterprise/templates/#{card_template_id}/logs", params)
  response['logs'].map { |log| Event.new(log) }
end

#read_template(params) ⇒ Object



21
22
23
24
# File 'lib/accessgrid/console.rb', line 21

def read_template(params)
  response = @client.make_request(:get, "/api/v1/enterprise/templates/#{params[:card_template_id]}")
  Template.new(response)
end

#update_template(params) ⇒ Object



14
15
16
17
18
19
# File 'lib/accessgrid/console.rb', line 14

def update_template(params)
  card_template_id = params.delete(:card_template_id)
  transformed_params = transform_template_params(params)
  response = @client.make_request(:put, "/api/v1/enterprise/templates/#{card_template_id}", transformed_params)
  Template.new(response)
end