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
-
#user ⇒ Object
Returns the value of attribute user.
-
#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
- #timeout ⇒ Object
Constructor Details
#initialize ⇒ Client
Returns a new instance of Client.
25 26 27 28 29 30 31 |
# File 'lib/crisp-api.rb', line 25 def initialize() @auth = {} @bucket = Crisp::BucketResource.new(self) @user = Crisp::UserResource.new(self) @website = Crisp::WebsiteResource.new(self) end |
Instance Attribute Details
#bucket ⇒ Object
Returns the value of attribute bucket.
21 22 23 |
# File 'lib/crisp-api.rb', line 21 def bucket @bucket end |
#rest_base_path ⇒ Object
44 45 46 |
# File 'lib/crisp-api.rb', line 44 def rest_base_path @rest_base_path || "/v1" end |
#rest_host ⇒ Object
40 41 42 |
# File 'lib/crisp-api.rb', line 40 def rest_host @rest_host || "https://api.crisp.chat" end |
#user ⇒ Object
Returns the value of attribute user.
22 23 24 |
# File 'lib/crisp-api.rb', line 22 def user @user end |
#website ⇒ Object
Returns the value of attribute website.
23 24 25 |
# File 'lib/crisp-api.rb', line 23 def website @website end |
Instance Method Details
#authenticate(identifier, key) ⇒ Object
35 36 37 38 |
# File 'lib/crisp-api.rb', line 35 def authenticate(identifier, key) @auth["identifier"] = identifier @auth["key"] = key end |
#get(resource, query: {}) ⇒ Object
52 53 54 |
# File 'lib/crisp-api.rb', line 52 def get(resource, query: {}) self._do_request(:get, resource, query: query) end |
#head(resource) ⇒ Object
56 57 58 |
# File 'lib/crisp-api.rb', line 56 def head(resource) self._do_request(:head, resource) end |
#patch(resource, data: {}) ⇒ Object
68 69 70 |
# File 'lib/crisp-api.rb', line 68 def patch(resource, data: {}) self._do_request(:patch, resource, data: data) end |
#post(resource, data: {}) ⇒ Object
64 65 66 |
# File 'lib/crisp-api.rb', line 64 def post(resource, data: {}) self._do_request(:post, resource, data: data) end |
#put(resource, data: {}) ⇒ Object
72 73 74 |
# File 'lib/crisp-api.rb', line 72 def put(resource, data: {}) self._do_request(:put, resource, data: data) end |
#remove(resource) ⇒ Object
60 61 62 |
# File 'lib/crisp-api.rb', line 60 def remove(resource) self._do_request(:delete, resource) end |
#timeout ⇒ Object
48 49 50 |
# File 'lib/crisp-api.rb', line 48 def timeout @timeout || 5 end |