crisp-api 1.0.5 → 1.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/README.md +17 -41
- data/crisp-api.gemspec +7 -7
- data/examples/website_send_message_in_conversation.rb +1 -1
- data/lib/crisp-api.rb +12 -9
- data/lib/resources/bucket.rb +1 -1
- data/lib/resources/website.rb +65 -25
- metadata +8 -11
- data/examples/user_get_profile.rb +0 -19
- data/lib/resources/user.rb +0 -72
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 53c7728a4e3a7dfd54454fda7525cdaf6ba0b6fa51e722b7a9c9d5d289dd0236
|
4
|
+
data.tar.gz: 8e35a4746ca4e8279b6cee485abd2a9a9411efae6a02358a7f5d6d17fd3905f0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 54a6816c31343e8edabf31b24653eaec00d97cefaea05863b9e30bec1a781452cdd90a9b4b57168f434fbdbfe2353d2a66f0a5951374d381bb079e5588af58ed
|
7
|
+
data.tar.gz: 2b7b0ce22ce1f4eeb5471e800735f70926e50909260606644badca667c1d678bb288f297fe3b3ef393882b23e7d37f18f96666bb13f69edf1e3a850c9cfefcbb
|
data/README.md
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
The Crisp API Ruby wrapper. Authenticate, send messages, fetch conversations, access your agent accounts from your Ruby code.
|
4
4
|
|
5
|
-
Copyright
|
5
|
+
Copyright 2019 Crisp IM SARL. See LICENSE for copying information.
|
6
6
|
|
7
7
|
* **📝 Implements**: [Crisp Platform - API ~ v1](https://docs.crisp.chat/api/v1/) at reference revision: 12/31/2017
|
8
8
|
* **😘 Maintainer**: [@valeriansaliou](https://github.com/valeriansaliou)
|
@@ -12,16 +12,16 @@ Copyright 2018 Crisp IM SARL. See LICENSE for copying information.
|
|
12
12
|
Add the library to your `Gemfile`:
|
13
13
|
|
14
14
|
```bash
|
15
|
-
gem
|
15
|
+
gem "crisp-api", "~> 1.1.4"
|
16
16
|
```
|
17
17
|
|
18
18
|
Then, import it:
|
19
19
|
|
20
20
|
```ruby
|
21
|
-
require
|
21
|
+
require "crisp-api"
|
22
22
|
```
|
23
23
|
|
24
|
-
|
24
|
+
Build a new authenticated Crisp client with your `identifier` and `key` tokens.
|
25
25
|
|
26
26
|
```ruby
|
27
27
|
client = Crisp::Client.new
|
@@ -33,18 +33,18 @@ Then, your client is ready to be consumed!
|
|
33
33
|
|
34
34
|
## Authentication
|
35
35
|
|
36
|
-
To authenticate against the API, generate your session identifier and session key **once** using the
|
36
|
+
To authenticate against the API, generate your session identifier and session key **once** using the [Crisp token generation utility](https://go.crisp.chat/account/token/). You'll get a token keypair made of 2 values.
|
37
37
|
|
38
|
-
|
39
|
-
curl -H "Content-Type: application/json" -X POST -d '{"email":"YOUR_ACCOUNT_EMAIL","password":"YOUR_ACCOUNT_PASSWORD"}' https://api.crisp.chat/v1/user/session/login
|
40
|
-
```
|
41
|
-
|
42
|
-
If authentication succeeds, you will get a JSON response containing your authentication keys: `identifier` and `key`. **Keep those 2 values private, and store them safely for long-term use**.
|
38
|
+
**Keep your token keypair values private, and store them safely for long-term use.**
|
43
39
|
|
44
40
|
Then, add authentication parameters to your `client` instance right after you create it:
|
45
41
|
|
46
42
|
```ruby
|
47
|
-
client = Crisp
|
43
|
+
client = Crisp::Client.new
|
44
|
+
|
45
|
+
# Make sure to use the correct tier if you are authenticating a plugin
|
46
|
+
# eg. with a permanent token generated from Crisp Marketplace
|
47
|
+
client.set_tier("plugin")
|
48
48
|
|
49
49
|
# Authenticate to API (identifier, key)
|
50
50
|
# eg. client.authenticate("5c0595b2-9381-4a76-a2e0-04aa00c1ede7", "3bdb0812d0f5352bf68901ddc731434dade419b98507971905acdd2f967df61c")
|
@@ -53,7 +53,7 @@ client.authenticate(identifier, key)
|
|
53
53
|
# Now, you can use authenticated API sections.
|
54
54
|
```
|
55
55
|
|
56
|
-
**🔴 Important:
|
56
|
+
**🔴 Important: Make sure to generate your token once, and use the same token keys in all your subsequent requests to the API. Do not generate too many tokens, as we may invalidate your older tokens to make room for newer tokens.**
|
57
57
|
|
58
58
|
## Resource Methods
|
59
59
|
|
@@ -61,7 +61,7 @@ Most useful available Crisp API resources are implemented. **Programmatic method
|
|
61
61
|
|
62
62
|
Thus, it is straightforward to look for them in the library while reading the [API Reference](https://docs.crisp.chat/api/v1/).
|
63
63
|
|
64
|
-
In the following method prototypes, `crisp` is to be replaced with your Crisp API instance. For example, instanciate `client = Crisp()` and then call eg: `client.
|
64
|
+
In the following method prototypes, `crisp` is to be replaced with your Crisp API instance. For example, instanciate `client = Crisp()` and then call eg: `client.website.list_conversations(website_id, 1)`.
|
65
65
|
|
66
66
|
When calling a method that writes data to the API (eg. send a message with: `client.website.send_message_in_conversation()`), you need to submit it this way:
|
67
67
|
|
@@ -85,9 +85,10 @@ client.website.send_message_in_conversation(
|
|
85
85
|
|
86
86
|
* **Website Conversations**
|
87
87
|
* **List Conversations**: `client.website.list_conversations(website_id, page_number)`
|
88
|
+
* **Search Conversations**: `client.website.search_conversations(website_id, page_number, search_query, search_type, search_operator, include_empty, filter_unread, filter_resolved, filter_not_resolved, filter_mention, filter_assigned, filter_unassigned, filter_date_start, filter_date_end, order_date_created", order_date_updated)`
|
88
89
|
|
89
90
|
* **Website Conversation**
|
90
|
-
* **Create A New Conversation**: `client.website.create_new_conversation(website_id
|
91
|
+
* **Create A New Conversation**: `client.website.create_new_conversation(website_id)`
|
91
92
|
* **Check If Conversation Exists**: `client.website.check_conversation_exists(website_id, session_id)`
|
92
93
|
* **Get A Conversation**: `client.website.get_conversation(website_id, session_id)`
|
93
94
|
* **Remove A Conversation**: `client.website.remove_conversation(website_id, session_id)`
|
@@ -118,7 +119,7 @@ client.website.send_message_in_conversation(
|
|
118
119
|
* **Check If People Profile Exists**: `client.website.check_people_profile_exists(website_id, people_id)`
|
119
120
|
* **Get People Profile**: `client.website.get_people_profile(website_id, people_id)`
|
120
121
|
* **Save People Profile**: `client.website.save_people_profile(website_id, people_id, data)`
|
121
|
-
* **Find People Profile By Email**: `find_people_profile_by_email(website_id, email)`
|
122
|
+
* **Find People Profile By Email**: `client.website.find_people_profile_by_email(website_id, email)`
|
122
123
|
* **Update People Profile**: `client.website.update_people_profile(website_id, people_id, data)`
|
123
124
|
* **Remove People Profile**: `client.website.remove_people_profile(website_id, people_id)`
|
124
125
|
* **List People Conversations**: `client.website.list_people_conversations(website_id, people_id, page_number)`
|
@@ -153,34 +154,9 @@ client.website.send_message_in_conversation(
|
|
153
154
|
* **Website Visitors**
|
154
155
|
* **Count Visitors**: `client.website.count_visitors(website_id)`
|
155
156
|
* **List Visitors**: `client.website.list_visitors(website_id, page_number)`
|
157
|
+
* **Get Session ID**: `client.website.get_session_id_by_token(website_id, token)`
|
156
158
|
|
157
159
|
### Bucket
|
158
160
|
|
159
161
|
* **Bucket URL**
|
160
162
|
* **Generate Bucket URL**: `client.bucket.generate_bucket_url(data)`
|
161
|
-
|
162
|
-
### User
|
163
|
-
|
164
|
-
* **User Availability**
|
165
|
-
* **Get User Availability**: `client.user.get_user_availability()`
|
166
|
-
* **Update User Availability**: `client.user.update_user_availability(data)`
|
167
|
-
* **Get User Availability Status**: `client.user.get_user_availability_status()`
|
168
|
-
|
169
|
-
* **User Account Base**
|
170
|
-
* **Get User Account**: `client.user.get_user_account()`
|
171
|
-
* **Create User Account**: `client.user.create_user_account(data)`
|
172
|
-
|
173
|
-
* **User Account Websites**
|
174
|
-
* **List Websites**: `client.user.list_websites()`
|
175
|
-
|
176
|
-
* **User Account Profile**
|
177
|
-
* **Get Profile**: `client.user.get_profile()`
|
178
|
-
* **Update Profile**: `client.user.update_profile(data)`
|
179
|
-
|
180
|
-
* **User Session**
|
181
|
-
* **Check Session Validity**: `client.user.check_session_validity()`
|
182
|
-
* **Create A New Session**: `client.user.create_new_session(data)`
|
183
|
-
* **Destroy A Session**: `client.user.destroy_session()`
|
184
|
-
|
185
|
-
* **User Statistics**
|
186
|
-
* **Count Total Unread Messages**: `client.user.count_total_unread_messages()`
|
data/crisp-api.gemspec
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
require File.expand_path("../lib/crisp-api", __FILE__)
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
|
-
s.name =
|
5
|
-
s.version =
|
4
|
+
s.name = "crisp-api"
|
5
|
+
s.version = "1.1.4"
|
6
6
|
s.date = Date.today
|
7
7
|
s.summary = "Crisp API Ruby"
|
8
8
|
s.description = "Crisp API Ruby"
|
9
9
|
s.authors = ["Valerian Saliou"]
|
10
|
-
s.email =
|
10
|
+
s.email = "valerian@valeriansaliou.name"
|
11
11
|
s.files = `git ls-files`.split($/)
|
12
|
-
s.homepage =
|
13
|
-
s.license =
|
14
|
-
s.require_paths = [
|
12
|
+
s.homepage = "https://github.com/crisp-im/ruby-crisp-api"
|
13
|
+
s.license = "MIT"
|
14
|
+
s.require_paths = ["lib"]
|
15
15
|
|
16
|
-
s.add_dependency
|
16
|
+
s.add_dependency "rest-client", "~> 2.0"
|
17
17
|
end
|
data/lib/crisp-api.rb
CHANGED
@@ -5,13 +5,12 @@
|
|
5
5
|
# Author: Valerian Saliou <valerian@valeriansaliou.name>
|
6
6
|
##
|
7
7
|
|
8
|
-
require
|
9
|
-
require
|
8
|
+
require "rest-client"
|
9
|
+
require "json"
|
10
10
|
|
11
|
-
require_relative
|
12
|
-
require_relative
|
13
|
-
require_relative
|
14
|
-
require_relative 'resources/website'
|
11
|
+
require_relative "errors/route"
|
12
|
+
require_relative "resources/bucket"
|
13
|
+
require_relative "resources/website"
|
15
14
|
|
16
15
|
module Crisp
|
17
16
|
class Client
|
@@ -19,14 +18,13 @@ module Crisp
|
|
19
18
|
attr_writer :rest_base_path
|
20
19
|
|
21
20
|
attr_accessor :bucket
|
22
|
-
attr_accessor :user
|
23
21
|
attr_accessor :website
|
24
22
|
|
25
23
|
def initialize()
|
26
24
|
@auth = {}
|
25
|
+
@tier = "user"
|
27
26
|
|
28
27
|
@bucket = Crisp::BucketResource.new(self)
|
29
|
-
@user = Crisp::UserResource.new(self)
|
30
28
|
@website = Crisp::WebsiteResource.new(self)
|
31
29
|
end
|
32
30
|
|
@@ -37,6 +35,10 @@ module Crisp
|
|
37
35
|
@auth["key"] = key
|
38
36
|
end
|
39
37
|
|
38
|
+
def set_tier(tier)
|
39
|
+
@tier = tier
|
40
|
+
end
|
41
|
+
|
40
42
|
def rest_host
|
41
43
|
@rest_host || "https://api.crisp.chat"
|
42
44
|
end
|
@@ -89,9 +91,10 @@ module Crisp
|
|
89
91
|
:payload => (data ? data.to_json : nil),
|
90
92
|
|
91
93
|
:headers => {
|
92
|
-
:user_agent => "ruby-crisp-api/1.
|
94
|
+
:user_agent => "ruby-crisp-api/1.1.4",
|
93
95
|
:accept => :json,
|
94
96
|
:content_type => :json,
|
97
|
+
"X-Crisp-Tier" => @tier,
|
95
98
|
:params => query
|
96
99
|
}
|
97
100
|
)
|
data/lib/resources/bucket.rb
CHANGED
data/lib/resources/website.rb
CHANGED
@@ -5,25 +5,43 @@
|
|
5
5
|
# Author: Valerian Saliou <valerian@valeriansaliou.name>
|
6
6
|
##
|
7
7
|
|
8
|
-
require
|
8
|
+
require "rest-client"
|
9
9
|
|
10
10
|
module Crisp
|
11
11
|
class WebsiteResource
|
12
|
+
SEARCH_CONVERSATIONS_QUERY_PARAMETERS = [
|
13
|
+
"search_query",
|
14
|
+
"search_type",
|
15
|
+
"search_operator",
|
16
|
+
"include_empty",
|
17
|
+
"filter_unread",
|
18
|
+
"filter_resolved",
|
19
|
+
"filter_not_resolved",
|
20
|
+
"filter_mention",
|
21
|
+
"filter_assigned",
|
22
|
+
"filter_unassigned",
|
23
|
+
"filter_date_start",
|
24
|
+
"filter_date_end",
|
25
|
+
"filter_date_end",
|
26
|
+
"order_date_created",
|
27
|
+
"order_date_updated",
|
28
|
+
]
|
29
|
+
|
12
30
|
def initialize(parent)
|
13
31
|
@parent = parent
|
14
32
|
end
|
15
33
|
|
16
34
|
protected
|
17
35
|
|
18
|
-
def _url_website(website_id, resource)
|
36
|
+
def _url_website(website_id, resource = "")
|
19
37
|
return "/website/%s%s" % [website_id, resource]
|
20
38
|
end
|
21
39
|
|
22
|
-
def _url_conversation(website_id, session_id, resource)
|
40
|
+
def _url_conversation(website_id, session_id, resource = "")
|
23
41
|
return self._url_website(website_id, "/conversation/%s%s" % [session_id, resource])
|
24
42
|
end
|
25
43
|
|
26
|
-
def _url_people(kind, website_id, people_id, resource)
|
44
|
+
def _url_people(kind, website_id, people_id, resource = "")
|
27
45
|
return self._url_website(website_id, "/people/%s/%s%s" % [kind, people_id, resource])
|
28
46
|
end
|
29
47
|
|
@@ -34,11 +52,11 @@ module Crisp
|
|
34
52
|
end
|
35
53
|
|
36
54
|
def get_website(website_id)
|
37
|
-
return @parent.get(self._url_website(website_id
|
55
|
+
return @parent.get(self._url_website(website_id))
|
38
56
|
end
|
39
57
|
|
40
58
|
def delete_website(website_id)
|
41
|
-
return @parent.delete(self._url_website(website_id
|
59
|
+
return @parent.delete(self._url_website(website_id))
|
42
60
|
end
|
43
61
|
|
44
62
|
def batch_resolve_items(website_id, data)
|
@@ -81,8 +99,29 @@ module Crisp
|
|
81
99
|
return @parent.get(self._url_website(website_id, "/visitors/list/%d" % page_number))
|
82
100
|
end
|
83
101
|
|
84
|
-
def
|
85
|
-
|
102
|
+
def search_conversations(website_id, page_number = 1, search_query = "", search_type = "", search_operator = "", include_empty = "", filter_unread = "", filter_resolved = "", filter_not_resolved = "", filter_mention = "", filter_assigned = "", filter_unassigned = "", filter_date_start = "", filter_date_end = "", order_date_created = "", order_date_updated = "")
|
103
|
+
resource_url = ""
|
104
|
+
query_parameters = []
|
105
|
+
|
106
|
+
SEARCH_CONVERSATIONS_QUERY_PARAMETERS.each do |parameter|
|
107
|
+
parameter_value = binding.local_variable_get(parameter)
|
108
|
+
|
109
|
+
if parameter_value != ""
|
110
|
+
query_parameters.push("%s=%s" % [parameter, CGI.escape(parameter_value).gsub("+", "%20")])
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
if query_parameters != []
|
115
|
+
resource_url = self._url_website(website_id, "/conversations/%d?%s" % [page_number, query_parameters.join("&")])
|
116
|
+
else
|
117
|
+
resource_url = self._url_website(website_id, "/conversations/%d" % page_number)
|
118
|
+
end
|
119
|
+
|
120
|
+
return @parent.get(resource_url)
|
121
|
+
end
|
122
|
+
|
123
|
+
def list_conversations(website_id, page_number = 1)
|
124
|
+
return self.search_conversations(website_id, page_number)
|
86
125
|
end
|
87
126
|
|
88
127
|
def create_new_conversation(website_id, data)
|
@@ -90,15 +129,15 @@ module Crisp
|
|
90
129
|
end
|
91
130
|
|
92
131
|
def check_conversation_exists(website_id, session_id)
|
93
|
-
return @parent.head(self._url_conversation(website_id, session_id
|
132
|
+
return @parent.head(self._url_conversation(website_id, session_id))
|
94
133
|
end
|
95
134
|
|
96
135
|
def get_conversation(website_id, session_id)
|
97
|
-
return @parent.get(self._url_conversation(website_id, session_id
|
136
|
+
return @parent.get(self._url_conversation(website_id, session_id))
|
98
137
|
end
|
99
138
|
|
100
139
|
def remove_conversation(website_id, session_id)
|
101
|
-
return @parent.
|
140
|
+
return @parent.remove(self._url_conversation(website_id, session_id))
|
102
141
|
end
|
103
142
|
|
104
143
|
def initiate_conversation_with_existing_session(website_id, session_id)
|
@@ -190,30 +229,27 @@ module Crisp
|
|
190
229
|
end
|
191
230
|
|
192
231
|
def check_people_profile_exists(website_id, people_id)
|
193
|
-
return @parent.head(self._url_people("profile", website_id, people_id
|
232
|
+
return @parent.head(self._url_people("profile", website_id, people_id))
|
194
233
|
end
|
195
234
|
|
196
235
|
def find_people_profile_by_email(website_id, email)
|
197
|
-
|
198
|
-
profiles = @parent.get(self._url_website(website_id, "/people/profiles/1?search_filter=%s" % CGI.escape(filter.to_json)))
|
199
|
-
|
200
|
-
return profiles[0]
|
236
|
+
return @parent.get(self._url_people("profile", website_id, email))
|
201
237
|
end
|
202
238
|
|
203
239
|
def get_people_profile(website_id, people_id)
|
204
|
-
return @parent.get(self._url_people("profile", website_id, people_id
|
240
|
+
return @parent.get(self._url_people("profile", website_id, people_id))
|
205
241
|
end
|
206
242
|
|
207
243
|
def save_people_profile(website_id, people_id, data)
|
208
|
-
return @parent.put(self._url_people("profile", website_id, people_id
|
244
|
+
return @parent.put(self._url_people("profile", website_id, people_id), data: data)
|
209
245
|
end
|
210
246
|
|
211
247
|
def update_people_profile(website_id, people_id, data)
|
212
|
-
return @parent.patch(self._url_people("profile", website_id, people_id
|
248
|
+
return @parent.patch(self._url_people("profile", website_id, people_id), data: data)
|
213
249
|
end
|
214
250
|
|
215
251
|
def remove_people_profile(website_id, people_id)
|
216
|
-
return @parent.remove(self._url_people("profile", website_id, people_id
|
252
|
+
return @parent.remove(self._url_people("profile", website_id, people_id))
|
217
253
|
end
|
218
254
|
|
219
255
|
def list_people_conversations(website_id, people_id, page_number)
|
@@ -221,7 +257,7 @@ module Crisp
|
|
221
257
|
end
|
222
258
|
|
223
259
|
def add_people_event(website_id, people_id, data)
|
224
|
-
return @parent.post(self._url_people("events", website_id, people_id
|
260
|
+
return @parent.post(self._url_people("events", website_id, people_id), data: data)
|
225
261
|
end
|
226
262
|
|
227
263
|
def list_people_events(website_id, people_id, page_number)
|
@@ -229,19 +265,23 @@ module Crisp
|
|
229
265
|
end
|
230
266
|
|
231
267
|
def get_people_data(website_id, people_id)
|
232
|
-
return @parent.get(self._url_people("data", website_id, people_id
|
268
|
+
return @parent.get(self._url_people("data", website_id, people_id))
|
233
269
|
end
|
234
270
|
|
235
271
|
def save_people_data(website_id, people_id, data)
|
236
|
-
return @parent.put(self._url_people("data", website_id, people_id
|
272
|
+
return @parent.put(self._url_people("data", website_id, people_id), data: data)
|
237
273
|
end
|
238
274
|
|
239
275
|
def get_people_subscription_status(website_id, people_id)
|
240
|
-
return @parent.get(self._url_people("subscription", website_id, people_id
|
276
|
+
return @parent.get(self._url_people("subscription", website_id, people_id))
|
241
277
|
end
|
242
278
|
|
243
279
|
def update_people_subscription_status(website_id, people_id, data)
|
244
|
-
return @parent.patch(self._url_people("subscription", website_id, people_id
|
280
|
+
return @parent.patch(self._url_people("subscription", website_id, people_id), data: data)
|
281
|
+
end
|
282
|
+
|
283
|
+
def get_session_id_by_token(website_id, token)
|
284
|
+
return @parent.get(self._url_website(website_id, "/visitors/token/#{token}"))
|
245
285
|
end
|
246
286
|
end
|
247
287
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: crisp-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Valerian Saliou
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-06-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 2.0
|
19
|
+
version: '2.0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 2.0
|
26
|
+
version: '2.0'
|
27
27
|
description: Crisp API Ruby
|
28
28
|
email: valerian@valeriansaliou.name
|
29
29
|
executables: []
|
@@ -35,18 +35,16 @@ files:
|
|
35
35
|
- LICENSE
|
36
36
|
- README.md
|
37
37
|
- crisp-api.gemspec
|
38
|
-
- examples/user_get_profile.rb
|
39
38
|
- examples/website_send_message_in_conversation.rb
|
40
39
|
- lib/crisp-api.rb
|
41
40
|
- lib/errors/route.rb
|
42
41
|
- lib/resources/bucket.rb
|
43
|
-
- lib/resources/user.rb
|
44
42
|
- lib/resources/website.rb
|
45
43
|
homepage: https://github.com/crisp-im/ruby-crisp-api
|
46
44
|
licenses:
|
47
45
|
- MIT
|
48
46
|
metadata: {}
|
49
|
-
post_install_message:
|
47
|
+
post_install_message:
|
50
48
|
rdoc_options: []
|
51
49
|
require_paths:
|
52
50
|
- lib
|
@@ -61,9 +59,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
61
59
|
- !ruby/object:Gem::Version
|
62
60
|
version: '0'
|
63
61
|
requirements: []
|
64
|
-
|
65
|
-
|
66
|
-
signing_key:
|
62
|
+
rubygems_version: 3.0.3
|
63
|
+
signing_key:
|
67
64
|
specification_version: 4
|
68
65
|
summary: Crisp API Ruby
|
69
66
|
test_files: []
|
@@ -1,19 +0,0 @@
|
|
1
|
-
##
|
2
|
-
# ruby-crisp-api
|
3
|
-
#
|
4
|
-
# Copyright 2018, Valerian Saliou
|
5
|
-
# Author: Valerian Saliou <valerian@valeriansaliou.name>
|
6
|
-
##
|
7
|
-
|
8
|
-
require 'crisp-api'
|
9
|
-
|
10
|
-
client = Crisp::Client.new
|
11
|
-
|
12
|
-
client.authenticate(
|
13
|
-
"5c0595b2-9381-4a76-a2e0-04aa00c1ede7",
|
14
|
-
"3bdb0812d0f5352bf68901ddc731434dade419b98507971905acdd2f967df61c"
|
15
|
-
)
|
16
|
-
|
17
|
-
data = client.user.get_profile()
|
18
|
-
|
19
|
-
puts data.inspect
|
data/lib/resources/user.rb
DELETED
@@ -1,72 +0,0 @@
|
|
1
|
-
##
|
2
|
-
# ruby-crisp-api
|
3
|
-
#
|
4
|
-
# Copyright 2018, Valerian Saliou
|
5
|
-
# Author: Valerian Saliou <valerian@valeriansaliou.name>
|
6
|
-
##
|
7
|
-
|
8
|
-
require 'rest-client'
|
9
|
-
|
10
|
-
module Crisp
|
11
|
-
class UserResource
|
12
|
-
def initialize(parent)
|
13
|
-
@parent = parent
|
14
|
-
end
|
15
|
-
|
16
|
-
protected
|
17
|
-
|
18
|
-
def _url_user(resource)
|
19
|
-
return "/user%s" % resource
|
20
|
-
end
|
21
|
-
|
22
|
-
public
|
23
|
-
|
24
|
-
def get_user_availability
|
25
|
-
return @parent.get(self._url_user("/availability"))
|
26
|
-
end
|
27
|
-
|
28
|
-
def update_user_availability(data)
|
29
|
-
return @parent.patch(self._url_user("/availability"), data: data)
|
30
|
-
end
|
31
|
-
|
32
|
-
def get_user_availability_status
|
33
|
-
return @parent.get(self._url_user("/availability/status"))
|
34
|
-
end
|
35
|
-
|
36
|
-
def get_user_account
|
37
|
-
return @parent.get(self._url_user("/account"))
|
38
|
-
end
|
39
|
-
|
40
|
-
def create_user_account(data)
|
41
|
-
return @parent.post(self._url_user("/account"), data: data)
|
42
|
-
end
|
43
|
-
|
44
|
-
def list_websites
|
45
|
-
return @parent.get(self._url_user("/account/websites"))
|
46
|
-
end
|
47
|
-
|
48
|
-
def get_profile
|
49
|
-
return @parent.get(self._url_user("/account/profile"))
|
50
|
-
end
|
51
|
-
|
52
|
-
def update_profile(data)
|
53
|
-
return @parent.patch(self._url_user("/account/profile"), data: data)
|
54
|
-
end
|
55
|
-
|
56
|
-
def check_session_validity
|
57
|
-
return @parent.head(self._url_user("/session"))
|
58
|
-
end
|
59
|
-
|
60
|
-
def create_new_session(data)
|
61
|
-
return @parent.post(self._url_user("/session/login"))
|
62
|
-
end
|
63
|
-
|
64
|
-
def destroy_session
|
65
|
-
return @parent.post(self._url_user("/session/logout"))
|
66
|
-
end
|
67
|
-
|
68
|
-
def count_total_unread_messages
|
69
|
-
return @parent.get(self._url_user("/stats/unread"))
|
70
|
-
end
|
71
|
-
end
|
72
|
-
end
|