Class: Cased::Policy

Inherits:
Object
  • Object
show all
Defined in:
lib/cased/policy.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_key:) ⇒ Policy

Returns a new instance of Policy.



9
10
11
12
# File 'lib/cased/policy.rb', line 9

def initialize(api_key:)
  @api_key = api_key
  @client = Cased::Clients.create(api_key: @api_key)
end

Instance Attribute Details

#api_keyObject (readonly)

Returns the value of attribute api_key.



7
8
9
# File 'lib/cased/policy.rb', line 7

def api_key
  @api_key
end

#clientObject (readonly)

Returns the value of attribute client.



7
8
9
# File 'lib/cased/policy.rb', line 7

def client
  @client
end

Instance Method Details

#event(id) ⇒ Object



18
19
20
21
# File 'lib/cased/policy.rb', line 18

def event(id)
  response = @client.get("events/#{id}")
  response.body
end

#events(phrase: nil, variables: {}) ⇒ Object



14
15
16
# File 'lib/cased/policy.rb', line 14

def events(phrase: nil, variables: {})
  Query.new(@client, phrase: phrase, variables: variables)
end