crisp-api 1.1.2 → 1.1.3
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 +4 -4
- data/crisp-api.gemspec +7 -7
- data/examples/website_send_message_in_conversation.rb +1 -1
- data/lib/crisp-api.rb +6 -6
- data/lib/resources/bucket.rb +1 -1
- data/lib/resources/website.rb +61 -22
- metadata +8 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 34adf502b882792d271c3b6a3f58a2570ab2ba441a75fcb8da3e719be07dfa8e
|
4
|
+
data.tar.gz: ed6a3d8626475bbe5617d39c68fccfc45a86abd8ccaaf32b69ba1b7ad773c9ca
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5cc0ad79b5eda809419e3733c86a48e30f00b91a25240381a853de8a615c4d10cdf6f6101df24f7707e49b3e886c2a7c3aad18e7ae27648d8a921640bc849b6c
|
7
|
+
data.tar.gz: 22153279f095e17131241b520e271a1725d9d8f8a0f988df223d3e9a76939d1138d31e515b7995744339e2ce6bf2012525aa497334a41882f152e9ee4dd59e83
|
data/README.md
CHANGED
@@ -12,13 +12,13 @@ Copyright 2019 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.3"
|
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.
|
@@ -81,6 +81,7 @@ client.website.send_message_in_conversation(
|
|
81
81
|
|
82
82
|
* **Website Conversations**
|
83
83
|
* **List Conversations**: `client.website.list_conversations(website_id, page_number)`
|
84
|
+
* **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)`
|
84
85
|
|
85
86
|
* **Website Conversation**
|
86
87
|
* **Create A New Conversation**: `client.website.create_new_conversation(website_id)`
|
@@ -149,10 +150,9 @@ client.website.send_message_in_conversation(
|
|
149
150
|
* **Website Visitors**
|
150
151
|
* **Count Visitors**: `client.website.count_visitors(website_id)`
|
151
152
|
* **List Visitors**: `client.website.list_visitors(website_id, page_number)`
|
152
|
-
* **Get Session ID**: `client.website.
|
153
|
+
* **Get Session ID**: `client.website.get_session_id_by_token(website_id, token)`
|
153
154
|
|
154
155
|
### Bucket
|
155
156
|
|
156
157
|
* **Bucket URL**
|
157
158
|
* **Generate Bucket URL**: `client.bucket.generate_bucket_url(data)`
|
158
|
-
|
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.3"
|
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,12 +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
|
11
|
+
require_relative "errors/route"
|
12
|
+
require_relative "resources/bucket"
|
13
|
+
require_relative "resources/website"
|
14
14
|
|
15
15
|
module Crisp
|
16
16
|
class Client
|
@@ -86,7 +86,7 @@ module Crisp
|
|
86
86
|
:payload => (data ? data.to_json : nil),
|
87
87
|
|
88
88
|
:headers => {
|
89
|
-
:user_agent => "ruby-crisp-api/1.1.
|
89
|
+
:user_agent => "ruby-crisp-api/1.1.3",
|
90
90
|
:accept => :json,
|
91
91
|
:content_type => :json,
|
92
92
|
:params => query
|
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 = 0, 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 = 0)
|
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.remove(self._url_conversation(website_id, session_id
|
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,27 +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
|
-
return @parent.get(self._url_people("profile", website_id, email
|
236
|
+
return @parent.get(self._url_people("profile", website_id, email))
|
198
237
|
end
|
199
238
|
|
200
239
|
def get_people_profile(website_id, people_id)
|
201
|
-
return @parent.get(self._url_people("profile", website_id, people_id
|
240
|
+
return @parent.get(self._url_people("profile", website_id, people_id))
|
202
241
|
end
|
203
242
|
|
204
243
|
def save_people_profile(website_id, people_id, data)
|
205
|
-
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)
|
206
245
|
end
|
207
246
|
|
208
247
|
def update_people_profile(website_id, people_id, data)
|
209
|
-
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)
|
210
249
|
end
|
211
250
|
|
212
251
|
def remove_people_profile(website_id, people_id)
|
213
|
-
return @parent.remove(self._url_people("profile", website_id, people_id
|
252
|
+
return @parent.remove(self._url_people("profile", website_id, people_id))
|
214
253
|
end
|
215
254
|
|
216
255
|
def list_people_conversations(website_id, people_id, page_number)
|
@@ -218,7 +257,7 @@ module Crisp
|
|
218
257
|
end
|
219
258
|
|
220
259
|
def add_people_event(website_id, people_id, data)
|
221
|
-
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)
|
222
261
|
end
|
223
262
|
|
224
263
|
def list_people_events(website_id, people_id, page_number)
|
@@ -226,19 +265,19 @@ module Crisp
|
|
226
265
|
end
|
227
266
|
|
228
267
|
def get_people_data(website_id, people_id)
|
229
|
-
return @parent.get(self._url_people("data", website_id, people_id
|
268
|
+
return @parent.get(self._url_people("data", website_id, people_id))
|
230
269
|
end
|
231
270
|
|
232
271
|
def save_people_data(website_id, people_id, data)
|
233
|
-
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)
|
234
273
|
end
|
235
274
|
|
236
275
|
def get_people_subscription_status(website_id, people_id)
|
237
|
-
return @parent.get(self._url_people("subscription", website_id, people_id
|
276
|
+
return @parent.get(self._url_people("subscription", website_id, people_id))
|
238
277
|
end
|
239
278
|
|
240
279
|
def update_people_subscription_status(website_id, people_id, data)
|
241
|
-
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)
|
242
281
|
end
|
243
282
|
|
244
283
|
def get_session_id_by_token(website_id, token)
|
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.1.
|
4
|
+
version: 1.1.3
|
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-04-20 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: []
|
@@ -44,7 +44,7 @@ homepage: https://github.com/crisp-im/ruby-crisp-api
|
|
44
44
|
licenses:
|
45
45
|
- MIT
|
46
46
|
metadata: {}
|
47
|
-
post_install_message:
|
47
|
+
post_install_message:
|
48
48
|
rdoc_options: []
|
49
49
|
require_paths:
|
50
50
|
- lib
|
@@ -59,9 +59,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
59
59
|
- !ruby/object:Gem::Version
|
60
60
|
version: '0'
|
61
61
|
requirements: []
|
62
|
-
|
63
|
-
|
64
|
-
signing_key:
|
62
|
+
rubygems_version: 3.0.3
|
63
|
+
signing_key:
|
65
64
|
specification_version: 4
|
66
65
|
summary: Crisp API Ruby
|
67
66
|
test_files: []
|