crisp-api 1.1.0 → 1.1.1
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 +4 -4
- data/README.md +7 -18
- data/crisp-api.gemspec +1 -1
- data/lib/crisp-api.rb +1 -4
- data/lib/resources/website.rb +1 -1
- metadata +2 -3
- data/lib/resources/user.rb +0 -36
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 73edc201f441670de7a0a5f19f264e9cd63dbdd2
|
4
|
+
data.tar.gz: d9a70ac91e7d86a5a4e37776cadf9257ed18427c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 06e95d148d771c58a47908bcaf5fedbf61d658e9508b63d134eb92ec324d2efeda2eca1dbb13dff1e6214596f1a3a456683e86d64e3c6ac38fcc4a1ccdb75a5b
|
7
|
+
data.tar.gz: dad99b1c1f8756531d5f6bfef3ce0684b35ac6a475763d9added5c6890829ec842abf6ad3ecbdcefd55b27ccbbff5c4f5402eb9cccfe68ebb8b4e90ecba984cd
|
data/README.md
CHANGED
@@ -21,7 +21,7 @@ Then, import it:
|
|
21
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,14 @@ 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
|
48
44
|
|
49
45
|
# Authenticate to API (identifier, key)
|
50
46
|
# eg. client.authenticate("5c0595b2-9381-4a76-a2e0-04aa00c1ede7", "3bdb0812d0f5352bf68901ddc731434dade419b98507971905acdd2f967df61c")
|
@@ -53,7 +49,7 @@ client.authenticate(identifier, key)
|
|
53
49
|
# Now, you can use authenticated API sections.
|
54
50
|
```
|
55
51
|
|
56
|
-
**🔴 Important:
|
52
|
+
**🔴 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
53
|
|
58
54
|
## Resource Methods
|
59
55
|
|
@@ -61,7 +57,7 @@ Most useful available Crisp API resources are implemented. **Programmatic method
|
|
61
57
|
|
62
58
|
Thus, it is straightforward to look for them in the library while reading the [API Reference](https://docs.crisp.chat/api/v1/).
|
63
59
|
|
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.
|
60
|
+
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
61
|
|
66
62
|
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
63
|
|
@@ -87,7 +83,7 @@ client.website.send_message_in_conversation(
|
|
87
83
|
* **List Conversations**: `client.website.list_conversations(website_id, page_number)`
|
88
84
|
|
89
85
|
* **Website Conversation**
|
90
|
-
* **Create A New Conversation**: `client.website.create_new_conversation(website_id
|
86
|
+
* **Create A New Conversation**: `client.website.create_new_conversation(website_id)`
|
91
87
|
* **Check If Conversation Exists**: `client.website.check_conversation_exists(website_id, session_id)`
|
92
88
|
* **Get A Conversation**: `client.website.get_conversation(website_id, session_id)`
|
93
89
|
* **Remove A Conversation**: `client.website.remove_conversation(website_id, session_id)`
|
@@ -158,10 +154,3 @@ client.website.send_message_in_conversation(
|
|
158
154
|
|
159
155
|
* **Bucket URL**
|
160
156
|
* **Generate Bucket URL**: `client.bucket.generate_bucket_url(data)`
|
161
|
-
|
162
|
-
### User
|
163
|
-
|
164
|
-
* **User Session**
|
165
|
-
* **Check Session Validity**: `client.user.check_session_validity()`
|
166
|
-
* **Create A New Session**: `client.user.create_new_session(data)`
|
167
|
-
* **Destroy A Session**: `client.user.destroy_session()`
|
data/crisp-api.gemspec
CHANGED
data/lib/crisp-api.rb
CHANGED
@@ -10,7 +10,6 @@ require 'json'
|
|
10
10
|
|
11
11
|
require_relative 'errors/route'
|
12
12
|
require_relative 'resources/bucket'
|
13
|
-
require_relative 'resources/user'
|
14
13
|
require_relative 'resources/website'
|
15
14
|
|
16
15
|
module Crisp
|
@@ -19,14 +18,12 @@ 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 = {}
|
27
25
|
|
28
26
|
@bucket = Crisp::BucketResource.new(self)
|
29
|
-
@user = Crisp::UserResource.new(self)
|
30
27
|
@website = Crisp::WebsiteResource.new(self)
|
31
28
|
end
|
32
29
|
|
@@ -89,7 +86,7 @@ module Crisp
|
|
89
86
|
:payload => (data ? data.to_json : nil),
|
90
87
|
|
91
88
|
:headers => {
|
92
|
-
:user_agent => "ruby-crisp-api/1.1.
|
89
|
+
:user_agent => "ruby-crisp-api/1.1.1",
|
93
90
|
:accept => :json,
|
94
91
|
:content_type => :json,
|
95
92
|
:params => query
|
data/lib/resources/website.rb
CHANGED
@@ -98,7 +98,7 @@ module Crisp
|
|
98
98
|
end
|
99
99
|
|
100
100
|
def remove_conversation(website_id, session_id)
|
101
|
-
return @parent.
|
101
|
+
return @parent.remove(self._url_conversation(website_id, session_id, ""))
|
102
102
|
end
|
103
103
|
|
104
104
|
def initiate_conversation_with_existing_session(website_id, session_id)
|
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.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Valerian Saliou
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-02-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|
@@ -39,7 +39,6 @@ files:
|
|
39
39
|
- lib/crisp-api.rb
|
40
40
|
- lib/errors/route.rb
|
41
41
|
- lib/resources/bucket.rb
|
42
|
-
- lib/resources/user.rb
|
43
42
|
- lib/resources/website.rb
|
44
43
|
homepage: https://github.com/crisp-im/ruby-crisp-api
|
45
44
|
licenses:
|
data/lib/resources/user.rb
DELETED
@@ -1,36 +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 check_session_validity
|
25
|
-
return @parent.head(self._url_user("/session"))
|
26
|
-
end
|
27
|
-
|
28
|
-
def create_new_session(data)
|
29
|
-
return @parent.post(self._url_user("/session/login"))
|
30
|
-
end
|
31
|
-
|
32
|
-
def destroy_session
|
33
|
-
return @parent.post(self._url_user("/session/logout"))
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|