Class: Layer::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/layer/client.rb,
lib/layer/client/rest.rb,
lib/layer/client/webhook.rb,
lib/layer/client/platform.rb

Direct Known Subclasses

Platform, REST

Defined Under Namespace

Classes: Platform, REST, Webhook

Class Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Class Attribute Details

.app_idObject



13
14
15
# File 'lib/layer/client.rb', line 13

def app_id
  @app_id || ENV['LAYER_APP_ID']
end

.tokenObject



17
18
19
# File 'lib/layer/client.rb', line 17

def token
  @token ||= ENV['LAYER_PLATFORM_TOKEN']
end

Class Method Details

.authenticate(app_id = self.app_id, &block) ⇒ Object



29
30
31
# File 'lib/layer/client.rb', line 29

def authenticate(app_id = self.app_id, &block)
  Layer::Client::REST.new(app_id, &block)
end

.configure {|_self| ... } ⇒ Object

Yields:

  • (_self)

Yield Parameters:

  • _self (Layer::Client)

    the object that the method was called on



21
22
23
# File 'lib/layer/client.rb', line 21

def configure
  yield self
end

.normalize_id(id) ⇒ Object



25
26
27
# File 'lib/layer/client.rb', line 25

def normalize_id(id)
  id.to_s.split('/').last
end

Instance Method Details

#delete(*args) ⇒ Object



52
53
54
# File 'lib/layer/client.rb', line 52

def delete(*args)
  request(:delete, *args)
end

#get(*args) ⇒ Object



34
35
36
# File 'lib/layer/client.rb', line 34

def get(*args)
  request(:get, *args)
end

#head(*args) ⇒ Object



56
57
58
# File 'lib/layer/client.rb', line 56

def head(*args)
  request(:head, *args)
end

#options(*args) ⇒ Object



60
61
62
# File 'lib/layer/client.rb', line 60

def options(*args)
  request(:options, *args)
end

#patch(url, payload = {}, headers = {}) ⇒ Object



42
43
44
45
46
# File 'lib/layer/client.rb', line 42

def patch(url, payload = {}, headers = {})
  headers['Content-Type'] = 'application/vnd.layer-patch+json'

  request(:patch, url, payload, headers)
end

#post(*args) ⇒ Object



38
39
40
# File 'lib/layer/client.rb', line 38

def post(*args)
  request(:post, *args)
end

#put(*args) ⇒ Object



48
49
50
# File 'lib/layer/client.rb', line 48

def put(*args)
  request(:put, *args)
end