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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3dcb52c7cd84cfd52cf672db6ba448213a45b21e
4
- data.tar.gz: c3ff479712a79c11ca68857e9fc6cff7b86780e8
3
+ metadata.gz: 73edc201f441670de7a0a5f19f264e9cd63dbdd2
4
+ data.tar.gz: d9a70ac91e7d86a5a4e37776cadf9257ed18427c
5
5
  SHA512:
6
- metadata.gz: 20d99c221db89ad90d161b734080f4a1ebf6823b92e23024b775c4e778d982008f161d778dd283d88816ea3b10ac0f1c68b9da06ee015e670e1ec16c63919602
7
- data.tar.gz: 91e4207c7e740743955d85b5cdd41b0a48446954e6c8b4a1c83d5ef9c374083a3ed65c321e835a3d8aa383163c49c90db082cd4b78e0f19a3f194e4c685628ef
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
- Construct a new authenticated Crisp client with your `identifier` and `key` tokens.
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 following cURL request in your terminal (replace `YOUR_ACCOUNT_EMAIL` and `YOUR_ACCOUNT_PASSWORD`):
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
- ```bash
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: Be sure to login once, and re-use the same authentication keys (same `identifier` + `key`) in all your subsequent requests to the API. Do not generate new tokens from your code for every new request to the API (you will be heavily rate-limited; that will induce HTTP failures for some of your API calls).**
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.user.check_session_validity()`.
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, data)`
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
@@ -2,7 +2,7 @@ require File.expand_path("../lib/crisp-api", __FILE__)
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = 'crisp-api'
5
- s.version = '1.1.0'
5
+ s.version = '1.1.1'
6
6
  s.date = Date.today
7
7
  s.summary = "Crisp API Ruby"
8
8
  s.description = "Crisp API Ruby"
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.0",
89
+ :user_agent => "ruby-crisp-api/1.1.1",
93
90
  :accept => :json,
94
91
  :content_type => :json,
95
92
  :params => query
@@ -98,7 +98,7 @@ module Crisp
98
98
  end
99
99
 
100
100
  def remove_conversation(website_id, session_id)
101
- return @parent.delete(self._url_conversation(website_id, session_id, ""))
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.0
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: 2018-08-15 00:00:00.000000000 Z
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:
@@ -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