Class: Crisp::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/crisp-api.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeClient

Returns a new instance of Client.



23
24
25
26
27
28
# File 'lib/crisp-api.rb', line 23

def initialize()
  @auth = {}

  @bucket = Crisp::BucketResource.new(self)
  @website = Crisp::WebsiteResource.new(self)
end

Instance Attribute Details

#bucketObject

Returns the value of attribute bucket.



20
21
22
# File 'lib/crisp-api.rb', line 20

def bucket
  @bucket
end

#rest_base_pathObject



41
42
43
# File 'lib/crisp-api.rb', line 41

def rest_base_path
  @rest_base_path || "/v1"
end

#rest_hostObject



37
38
39
# File 'lib/crisp-api.rb', line 37

def rest_host
  @rest_host || "https://api.crisp.chat"
end

#websiteObject

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



32
33
34
35
# File 'lib/crisp-api.rb', line 32

def authenticate(identifier, key)
  @auth["identifier"] = identifier
  @auth["key"] = key
end

#get(resource, query: {}) ⇒ Object



49
50
51
# File 'lib/crisp-api.rb', line 49

def get(resource, query: {})
  self._do_request(:get, resource, query: query)
end

#head(resource) ⇒ Object



53
54
55
# File 'lib/crisp-api.rb', line 53

def head(resource)
  self._do_request(:head, resource)
end

#patch(resource, data: {}) ⇒ Object



65
66
67
# File 'lib/crisp-api.rb', line 65

def patch(resource, data: {})
  self._do_request(:patch, resource, data: data)
end

#post(resource, data: {}) ⇒ Object



61
62
63
# File 'lib/crisp-api.rb', line 61

def post(resource, data: {})
  self._do_request(:post, resource, data: data)
end

#put(resource, data: {}) ⇒ Object



69
70
71
# File 'lib/crisp-api.rb', line 69

def put(resource, data: {})
  self._do_request(:put, resource, data: data)
end

#remove(resource) ⇒ Object



57
58
59
# File 'lib/crisp-api.rb', line 57

def remove(resource)
  self._do_request(:delete, resource)
end

#timeoutObject



45
46
47
# File 'lib/crisp-api.rb', line 45

def timeout
  @timeout || 5
end