Class: Layer::Client

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

Direct Known Subclasses

Platform, REST

Defined Under Namespace

Classes: Platform, REST

Class Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Class Attribute Details

.app_idObject


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

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

.tokenObject


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

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

Class Method Details

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


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

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


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

def configure
  yield self
end

.normalize_id(id) ⇒ Object


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

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

Instance Method Details

#delete(*args) ⇒ Object


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

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

#get(*args) ⇒ Object


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

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

#head(*args) ⇒ Object


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

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

#options(*args) ⇒ Object


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

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

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


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

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

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

#post(*args) ⇒ Object


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

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

#put(*args) ⇒ Object


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

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