Class: Layer::Platform::Client
- Inherits:
-
Object
- Object
- Layer::Platform::Client
- Defined in:
- lib/layer/platform/client.rb
Instance Attribute Summary collapse
-
#api_token ⇒ Object
Returns the value of attribute api_token.
-
#app_id ⇒ Object
Returns the value of attribute app_id.
Instance Method Summary collapse
- #announcements ⇒ Object
- #client ⇒ Object
- #conversations ⇒ Object
- #delete(url) ⇒ Object
- #generate_identity_token(options = {}) ⇒ Object
- #get(url, *args) ⇒ Object
-
#initialize(options = {}) ⇒ Client
constructor
A new instance of Client.
- #patch(url, *args) ⇒ Object
- #post(url, *args) ⇒ Object
- #put(url, *args) ⇒ Object
- #strip_layer_prefix(string) ⇒ Object
- #users ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Client
Returns a new instance of Client.
6 7 8 9 10 |
# File 'lib/layer/platform/client.rb', line 6 def initialize( = {}) @api_token = [:api_token] || ENV['LAYER_API_TOKEN'] @app_id = [:app_id] || ENV['LAYER_APP_ID'] strip_layer_prefix(@app_id) end |
Instance Attribute Details
#api_token ⇒ Object
Returns the value of attribute api_token.
4 5 6 |
# File 'lib/layer/platform/client.rb', line 4 def api_token @api_token end |
#app_id ⇒ Object
Returns the value of attribute app_id.
4 5 6 |
# File 'lib/layer/platform/client.rb', line 4 def app_id @app_id end |
Instance Method Details
#announcements ⇒ Object
40 41 42 |
# File 'lib/layer/platform/client.rb', line 40 def announcements Layer::ResourceProxy.new(nil, Layer::Resources::Announcement) end |
#client ⇒ Object
12 13 14 |
# File 'lib/layer/platform/client.rb', line 12 def client @http_client ||= Layer::HttpClient.new(app_id, api_token) end |
#conversations ⇒ Object
44 45 46 |
# File 'lib/layer/platform/client.rb', line 44 def conversations Layer::ResourceProxy.new(nil, Layer::Resources::Conversation) end |
#delete(url) ⇒ Object
32 33 34 |
# File 'lib/layer/platform/client.rb', line 32 def delete(url) client.delete(url) end |
#generate_identity_token(options = {}) ⇒ Object
52 53 54 |
# File 'lib/layer/platform/client.rb', line 52 def generate_identity_token( = {}) Layer::IdentityToken.new() end |
#get(url, *args) ⇒ Object
16 17 18 |
# File 'lib/layer/platform/client.rb', line 16 def get(url, *args) client.get(url, *args) end |
#patch(url, *args) ⇒ Object
28 29 30 |
# File 'lib/layer/platform/client.rb', line 28 def patch(url, *args) client.patch(url, *args) end |
#post(url, *args) ⇒ Object
20 21 22 |
# File 'lib/layer/platform/client.rb', line 20 def post(url, *args) client.post(url, *args) end |
#put(url, *args) ⇒ Object
24 25 26 |
# File 'lib/layer/platform/client.rb', line 24 def put(url, *args) client.put(url, *args) end |
#strip_layer_prefix(string) ⇒ Object
36 37 38 |
# File 'lib/layer/platform/client.rb', line 36 def strip_layer_prefix(string) string.split("/").last if string end |