Class: Crisp::Client
- Inherits:
-
Object
- Object
- Crisp::Client
- Defined in:
- lib/crisp-api.rb
Instance Attribute Summary collapse
-
#bucket ⇒ Object
Returns the value of attribute bucket.
- #rest_base_path ⇒ Object
- #rest_host ⇒ Object
-
#website ⇒ Object
Returns the value of attribute website.
Instance Method Summary collapse
- #authenticate(identifier, key) ⇒ Object
- #get(resource, query: {}) ⇒ Object
- #head(resource) ⇒ Object
-
#initialize ⇒ Client
constructor
A new instance of Client.
- #patch(resource, data: {}) ⇒ Object
- #post(resource, data: {}) ⇒ Object
- #put(resource, data: {}) ⇒ Object
- #remove(resource) ⇒ Object
- #set_tier(tier) ⇒ Object
- #timeout ⇒ Object
Constructor Details
#initialize ⇒ Client
Returns a new instance of Client.
23 24 25 26 27 28 29 |
# File 'lib/crisp-api.rb', line 23 def initialize() @auth = {} @tier = "user" @bucket = Crisp::BucketResource.new(self) @website = Crisp::WebsiteResource.new(self) end |
Instance Attribute Details
#bucket ⇒ Object
Returns the value of attribute bucket.
20 21 22 |
# File 'lib/crisp-api.rb', line 20 def bucket @bucket end |
#rest_base_path ⇒ Object
46 47 48 |
# File 'lib/crisp-api.rb', line 46 def rest_base_path @rest_base_path || "/v1" end |
#rest_host ⇒ Object
42 43 44 |
# File 'lib/crisp-api.rb', line 42 def rest_host @rest_host || "https://api.crisp.chat" end |
#website ⇒ Object
Returns the value of attribute website.
21 22 23 |
# File 'lib/crisp-api.rb', line 21 def website @website end |
Instance Method Details
#authenticate(identifier, key) ⇒ Object
33 34 35 36 |
# File 'lib/crisp-api.rb', line 33 def authenticate(identifier, key) @auth["identifier"] = identifier @auth["key"] = key end |
#get(resource, query: {}) ⇒ Object
54 55 56 |
# File 'lib/crisp-api.rb', line 54 def get(resource, query: {}) self._do_request(:get, resource, query: query) end |
#head(resource) ⇒ Object
58 59 60 |
# File 'lib/crisp-api.rb', line 58 def head(resource) self._do_request(:head, resource) end |
#patch(resource, data: {}) ⇒ Object
70 71 72 |
# File 'lib/crisp-api.rb', line 70 def patch(resource, data: {}) self._do_request(:patch, resource, data: data) end |
#post(resource, data: {}) ⇒ Object
66 67 68 |
# File 'lib/crisp-api.rb', line 66 def post(resource, data: {}) self._do_request(:post, resource, data: data) end |
#put(resource, data: {}) ⇒ Object
74 75 76 |
# File 'lib/crisp-api.rb', line 74 def put(resource, data: {}) self._do_request(:put, resource, data: data) end |
#remove(resource) ⇒ Object
62 63 64 |
# File 'lib/crisp-api.rb', line 62 def remove(resource) self._do_request(:delete, resource) end |
#set_tier(tier) ⇒ Object
38 39 40 |
# File 'lib/crisp-api.rb', line 38 def set_tier(tier) @tier = tier end |
#timeout ⇒ Object
50 51 52 |
# File 'lib/crisp-api.rb', line 50 def timeout @timeout || 5 end |