crisp-api 1.0.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 704987e5c967c926caf8629b2dcc11a6137e80d6
4
+ data.tar.gz: 60555599bd6529c0c7a619a88214784855148e4f
5
+ SHA512:
6
+ metadata.gz: 428fb0189315af090ffed1a0505ffcda531ef78dfc74aed8eb41f988c0323710739c32385d8711a55c915f92887c7c30921d93ad7aafe063b6c69b854806b630
7
+ data.tar.gz: 3d97221cd573e943ca21a89ddb9f08986c117b72d52dae26f3d9c7293e59436621639dff2937ab0a3baa32e36db61e74d0350511d6d51f0b720c83e32f2fffb8
data/.gitignore ADDED
@@ -0,0 +1,7 @@
1
+ *.gem
2
+ *.rbc
3
+
4
+ /.bundle/
5
+ /vendor/
6
+
7
+ Gemfile.lock
data/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ source "https://rubygems.org"
2
+ gem "rest-client"
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2018 Crisp IM SARL
2
+
3
+ Permission is hereby granted, free of charge, to any person
4
+ obtaining a copy of this software and associated documentation
5
+ files (the "Software"), to deal in the Software without
6
+ restriction, including without limitation the rights to use,
7
+ copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ copies of the Software, and to permit persons to whom the
9
+ Software is furnished to do so, subject to the following
10
+ conditions:
11
+
12
+ The above copyright notice and this permission notice shall be
13
+ included in all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
17
+ OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
19
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22
+ OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,178 @@
1
+ # ruby-crisp-api
2
+
3
+ The Crisp API Ruby wrapper. Authenticate, send messages, fetch conversations, access your agent accounts from your Ruby code.
4
+
5
+ Copyright 2018 Crisp IM SARL. See LICENSE for copying information.
6
+
7
+ * **📝 Implements**: [Crisp Platform - API ~ v1](https://docs.crisp.chat/api/v1/) at reference revision: 12/31/2017
8
+ * **😘 Maintainer**: [@valeriansaliou](https://github.com/valeriansaliou)
9
+
10
+ ## Usage
11
+
12
+ Add the library to your `Gemfile`:
13
+
14
+ ```bash
15
+ gem 'crisp-api', '~> 1.0'
16
+ ```
17
+
18
+ Then, import it:
19
+
20
+ ```ruby
21
+ require 'crisp-api'
22
+ ```
23
+
24
+ Construct a new authenticated Crisp client with your `identifier` and `key` tokens.
25
+
26
+ ```ruby
27
+ client = Crisp::Client.new
28
+
29
+ client.authenticate(identifier, key)
30
+ ```
31
+
32
+ Then, your client is ready to be consumed!
33
+
34
+ ## Authentication
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`):
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**.
43
+
44
+ Then, add authentication parameters to your `client` instance right after you create it:
45
+
46
+ ```ruby
47
+ client = Crisp()
48
+
49
+ # Authenticate to API (identifier, key)
50
+ # eg. client.authenticate("5c0595b2-9381-4a76-a2e0-04aa00c1ede7", "3bdb0812d0f5352bf68901ddc731434dade419b98507971905acdd2f967df61c")
51
+ client.authenticate(identifier, key)
52
+
53
+ # Now, you can use authenticated API sections.
54
+ ```
55
+
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).**
57
+
58
+ ## Resource Methods
59
+
60
+ Most useful available Crisp API resources are implemented. **Programmatic methods names are named after their label name in the [API Reference](https://docs.crisp.chat/api/v1/)**.
61
+
62
+ Thus, it is straightforward to look for them in the library while reading the [API Reference](https://docs.crisp.chat/api/v1/).
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.user.check_session_validity()`.
65
+
66
+ When calling a method that writes data to the API (eg: `client.user.create_user_account()`), you need to build an account instance and submit it this way:
67
+
68
+ ```ruby
69
+ client.user.create_user_account({
70
+ "email" => "john@acme-inc.com",
71
+ "password" => "SecurePassword",
72
+ "first_name" => "John",
73
+ "last_name" => "Doe"
74
+ })
75
+ ```
76
+
77
+ ### Bucket
78
+
79
+ * **Bucket URL**
80
+ * **Generate Bucket URL**: `client.bucket.generate_bucket_url`
81
+
82
+ ### User
83
+
84
+ * **User Availability**
85
+ * **Get User Availability**: `client.user.get_user_availability`
86
+ * **Update User Availability**: `client.user.update_user_availability`
87
+ * **Get User Availability Status**: `client.user.get_user_availability_status`
88
+
89
+ * **User Account Base**
90
+ * **Get User Account**: `client.user.get_user_account`
91
+ * **Create User Account**: `client.user.create_user_account`
92
+
93
+ * **User Account Websites**
94
+ * **List Websites**: `client.user.list_websites`
95
+
96
+ * **User Account Profile**
97
+ * **Get Profile**: `client.user.get_profile`
98
+ * **Update Profile**: `client.user.update_profile`
99
+
100
+ * **User Session**
101
+ * **Check Session Validity**: `client.user.check_session_validity`
102
+ * **Create A New Session**: `client.user.create_new_session`
103
+ * **Destroy A Session**: `client.user.destroy_session`
104
+
105
+ * **User Statistics**
106
+ * **Count Total Unread Messages**: `client.user.count_total_unread_messages`
107
+
108
+ ### Website
109
+
110
+ * **Website Base**
111
+ * **Create Website**: `client.website.create_website`
112
+ * **Get A Website**: `client.website.get_website`
113
+ * **Delete A Website**: `client.website.delete_website`
114
+
115
+ * **Website Batch**
116
+ * **Batch Resolve Items**: `client.website.batch_resolve_items`
117
+ * **Batch Read Items**: `client.website.batch_read_items`
118
+ * **Batch Remove Items**: `client.website.batch_remove_items`
119
+
120
+ * **Website Availability**
121
+ * **Get Website Availability Status**: `client.website.get_website_availability_status`
122
+
123
+ * **Website Operator**
124
+ * **List Website Operators**: `client.website.list_website_operators`
125
+ * **List Last Active Website Operators**: `client.website.list_last_active_website_operators`
126
+
127
+ * **Website Settings**
128
+ * **Get Website Settings**: `client.website.get_website_settings`
129
+ * **Update Website Settings**: `client.website.update_website_settings`
130
+
131
+ * **Website Visitors**
132
+ * **Count Visitors**: `client.website.count_visitors`
133
+ * **List Visitors**: `client.website.list_visitors`
134
+
135
+ * **Website Conversations**
136
+ * **List Conversations**: `client.website.list_conversations`
137
+
138
+ * **Website Conversation**
139
+ * **Create A New Conversation**: `client.website.create_new_conversation`
140
+ * **Check If Conversation Exists**: `client.website.check_conversation_exists`
141
+ * **Get A Conversation**: `client.website.get_conversation`
142
+ * **Remove A Conversation**: `client.website.remove_conversation`
143
+ * **Initiate A Conversation With Existing Session**: `client.website.initiate_conversation_with_existing_session`
144
+ * **Get Messages In Conversation**: `client.website.get_messages_in_conversation`
145
+ * **Send A Message In Conversation**: `client.website.send_message_in_conversation`
146
+ * **Update A Message In Conversation**: `client.website.update_message_in_conversation`
147
+ * **Compose A Message In Conversation**: `client.website.compose_message_in_conversation`
148
+ * **Mark Messages As Read In Conversation**: `client.website.mark_messages_read_in_conversation`
149
+ * **Mark Messages As Delivered In Conversation**: `client.website.mark_messages_delivered_in_conversation`
150
+ * **Get Conversation Routing Assign**: `client.website.get_conversation_routing_assign`
151
+ * **Assign Conversation Routing**: `client.website.assign_conversation_routing`
152
+ * **Get Conversation Metas**: `client.website.get_conversation_metas`
153
+ * **Update Conversation Metas**: `client.website.update_conversation_metas`
154
+ * **List Conversation Pages**: `client.website.list_conversation_pages`
155
+ * **List Conversation Events**: `client.website.list_conversation_events`
156
+ * **Get Conversation State**: `client.website.get_conversation_state`
157
+ * **Change Conversation State**: `client.website.change_conversation_state`
158
+ * **Get Block Status For Conversation**: `client.website.get_block_status_for_conversation`
159
+ * **Block Incoming Messages For Conversation**: `client.website.block_incoming_messages_for_conversation`
160
+ * **Request Email Transcript For Conversation**: `client.website.request_email_transcript_for_conversation`
161
+
162
+ * **Website People**
163
+ * **Get People Statistics**: `client.website.get_people_statistics`
164
+ * **List People Segments**: `client.website.list_people_segments`
165
+ * **List People Profiles**: `client.website.list_people_profiles`
166
+ * **Add New People Profile**: `client.website.add_new_people_profile`
167
+ * **Check If People Profile Exists**: `client.website.check_people_profile_exists`
168
+ * **Get People Profile**: `client.website.get_people_profile`
169
+ * **Save People Profile**: `client.website.save_people_profile`
170
+ * **Update People Profile**: `client.website.update_people_profile`
171
+ * **Remove People Profile**: `client.website.remove_people_profile`
172
+ * **List People Conversations**: `client.website.list_people_conversations`
173
+ + **Add A People Event**: `client.website.add_people_event`
174
+ + **List People Events**: `client.website.list_people_events`
175
+ + **Get People Data**: `client.website.get_people_data`
176
+ + **Save People Data**: `client.website.save_people_data`
177
+ + **Get People Subscription Status**: `client.website.get_people_subscription_status`
178
+ + **Update People Subscription Status**: `client.website.update_people_subscription_status`
data/crisp-api.gemspec ADDED
@@ -0,0 +1,15 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = 'crisp-api'
3
+ s.version = '1.0.1'
4
+ s.date = Date.today
5
+ s.summary = "Crisp API Ruby"
6
+ s.description = "Crisp API Ruby"
7
+ s.authors = ["Valerian Saliou"]
8
+ s.email = 'valerian@valeriansaliou.name'
9
+ s.files = `git ls-files`.split($/)
10
+ s.homepage = 'https://github.com/crisp-im/ruby-crisp-api'
11
+ s.license = 'MIT'
12
+ s.require_paths = ['lib']
13
+
14
+ s.add_dependency 'rest-client', '~> 2.0.0'
15
+ end
@@ -0,0 +1,19 @@
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
@@ -0,0 +1,32 @@
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
+ # Message routing details
18
+ website_id = "6497e4a4-b17c-41e0-bfea-eea97ba8115a"
19
+ session_id = "session_f32bc993-f7ce-41af-bcd1-110fc147a392"
20
+
21
+ data = client.website.send_message_in_conversation(
22
+ website_id, session_id,
23
+
24
+ {
25
+ "type" => "text",
26
+ "content" => "This message was sent from python-crisp-api! :)",
27
+ "from" => "operator",
28
+ "origin" => "chat"
29
+ }
30
+ )
31
+
32
+ puts data.inspect
data/lib/crisp.rb ADDED
@@ -0,0 +1,124 @@
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
+ require 'json'
10
+
11
+ require_relative 'errors/route'
12
+ require_relative 'resources/bucket'
13
+ require_relative 'resources/user'
14
+ require_relative 'resources/website'
15
+
16
+ module Crisp
17
+ class Client
18
+ attr_writer :rest_host
19
+ attr_writer :rest_base_path
20
+
21
+ attr_accessor :bucket
22
+ attr_accessor :user
23
+ attr_accessor :website
24
+
25
+ def initialize()
26
+ @auth = {}
27
+
28
+ @bucket = Crisp::BucketResource.new(self)
29
+ @user = Crisp::UserResource.new(self)
30
+ @website = Crisp::WebsiteResource.new(self)
31
+ end
32
+
33
+ public
34
+
35
+ def authenticate(identifier, key)
36
+ @auth["identifier"] = identifier
37
+ @auth["key"] = key
38
+ end
39
+
40
+ def rest_host
41
+ @rest_host || "https://api.crisp.chat"
42
+ end
43
+
44
+ def rest_base_path
45
+ @rest_base_path || "/v1"
46
+ end
47
+
48
+ def timeout
49
+ @timeout || 5
50
+ end
51
+
52
+ def get(resource, query: {})
53
+ self._do_request(:get, resource, query: query)
54
+ end
55
+
56
+ def head(resource)
57
+ self._do_request(:head, resource)
58
+ end
59
+
60
+ def remove(resource)
61
+ self._do_request(:delete, resource)
62
+ end
63
+
64
+ def post(resource, data: {})
65
+ self._do_request(:post, resource, data: data)
66
+ end
67
+
68
+ def patch(resource, data: {})
69
+ self._do_request(:patch, resource, data: data)
70
+ end
71
+
72
+ def put(resource, data: {})
73
+ self._do_request(:put, resource, data: data)
74
+ end
75
+
76
+ protected
77
+
78
+ def _do_request(method, resource, query: nil, data: nil)
79
+ begin
80
+ response = RestClient::Request.execute(
81
+ :url => self._prepare_rest_url(resource),
82
+ :method => method,
83
+ :timeout => self.timeout,
84
+ :verify_ssl => OpenSSL::SSL::VERIFY_PEER,
85
+
86
+ :user => @auth["identifier"],
87
+ :password => @auth["key"],
88
+
89
+ :payload => (data ? data.to_json : nil),
90
+
91
+ :headers => {
92
+ :user_agent => "ruby-crisp-api/1.0.1",
93
+ :accept => :json,
94
+ :content_type => :json,
95
+ :params => query
96
+ }
97
+ )
98
+ rescue RestClient::ExceptionWithResponse => error
99
+ response = error.response
100
+ rescue
101
+ response = nil
102
+ end
103
+
104
+ if response
105
+ result = JSON.parse(response)
106
+ else
107
+ result = {
108
+ "error" => true,
109
+ "reason" => "http_error"
110
+ }
111
+ end
112
+
113
+ if result["error"] === true
114
+ raise RouteError, (result["reason"] || "error")
115
+ end
116
+
117
+ return result["data"] || {}
118
+ end
119
+
120
+ def _prepare_rest_url(resource)
121
+ return self.rest_host + self.rest_base_path + resource
122
+ end
123
+ end
124
+ end
@@ -0,0 +1,18 @@
1
+ ##
2
+ # ruby-crisp-api
3
+ #
4
+ # Copyright 2018, Valerian Saliou
5
+ # Author: Valerian Saliou <valerian@valeriansaliou.name>
6
+ ##
7
+
8
+ class RouteError < StandardError
9
+ def initialize(reason)
10
+ @reason = reason
11
+
12
+ super(reason)
13
+ end
14
+
15
+ def to_s
16
+ @reason
17
+ end
18
+ end
@@ -0,0 +1,28 @@
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 BucketResource
12
+ def initialize(parent)
13
+ @parent = parent
14
+ end
15
+
16
+ protected
17
+
18
+ def _url_bucket(resource)
19
+ return "/bucket%s" % resource
20
+ end
21
+
22
+ public
23
+
24
+ def generate_bucket_url(data)
25
+ return @parent.post(self._url_bucket("/url/generate"), data: data)
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,72 @@
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
@@ -0,0 +1,240 @@
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 WebsiteResource
12
+ def initialize(parent)
13
+ @parent = parent
14
+ end
15
+
16
+ protected
17
+
18
+ def _url_website(website_id, resource)
19
+ return "/website/%s%s" % [website_id, resource]
20
+ end
21
+
22
+ def _url_conversation(website_id, session_id, resource)
23
+ return self._url_website(website_id, "/conversation/%s%s" % [session_id, resource])
24
+ end
25
+
26
+ def _url_people(kind, website_id, people_id, resource)
27
+ return self._url_website(website_id, "/people/%s/%s%s" % [kind, people_id, resource])
28
+ end
29
+
30
+ public
31
+
32
+ def create_website(data)
33
+ return @parent.post("/website", data)
34
+ end
35
+
36
+ def get_website(website_id)
37
+ return @parent.get(self._url_website(website_id, ""))
38
+ end
39
+
40
+ def delete_website(website_id)
41
+ return @parent.delete(self._url_website(website_id, ""))
42
+ end
43
+
44
+ def batch_resolve_items(website_id, data)
45
+ return @parent.patch(self._url_website(website_id, "/batch/resolve"), data: data)
46
+ end
47
+
48
+ def batch_read_items(website_id, data)
49
+ return @parent.patch(self._url_website(website_id, "/batch/read"), data: data)
50
+ end
51
+
52
+ def batch_remove_items(website_id, data)
53
+ return @parent.patch(self._url_website(website_id, "/batch/remove"), data: data)
54
+ end
55
+
56
+ def get_website_availability_status(website_id)
57
+ return @parent.get(self._url_website(website_id, "/availability/status"))
58
+ end
59
+
60
+ def list_website_operators(website_id)
61
+ return @parent.get(self._url_website(website_id, "/operators/list"))
62
+ end
63
+
64
+ def list_last_active_website_operators(website_id)
65
+ return @parent.get(self._url_website(website_id, "/operators/active"))
66
+ end
67
+
68
+ def get_website_settings(website_id)
69
+ return @parent.get(self._url_website(website_id, "/settings"))
70
+ end
71
+
72
+ def update_website_settings(website_id, data)
73
+ return @parent.patch(self._url_website(website_id, "/settings"), data: data)
74
+ end
75
+
76
+ def count_visitors(website_id)
77
+ return @parent.get(self._url_website(website_id, "/visitors/count"))
78
+ end
79
+
80
+ def list_visitors(website_id, page_number)
81
+ return @parent.get(self._url_website(website_id, "/visitors/list/%d" % page_number))
82
+ end
83
+
84
+ def list_conversations(website_id, page_number)
85
+ return @parent.get(self._url_website(website_id, "/conversations/%d" % page_number))
86
+ end
87
+
88
+ def create_new_conversation(website_id, data)
89
+ return @parent.post(self._url_website(website_id, "/conversation"), data: data)
90
+ end
91
+
92
+ def check_conversation_exists(website_id, session_id)
93
+ return @parent.head(self._url_conversation(website_id, session_id, ""))
94
+ end
95
+
96
+ def get_conversation(website_id, session_id)
97
+ return @parent.get(self._url_conversation(website_id, session_id, ""))
98
+ end
99
+
100
+ def remove_conversation(website_id, session_id)
101
+ return @parent.delete(self._url_conversation(website_id, session_id, ""))
102
+ end
103
+
104
+ def initiate_conversation_with_existing_session(website_id, session_id)
105
+ return @parent.post(self._url_conversation(website_id, session_id, "/initiate"))
106
+ end
107
+
108
+ def get_messages_in_conversation(website_id, session_id, query)
109
+ return @parent.get(self._url_conversation(website_id, session_id, "/messages"), query: query)
110
+ end
111
+
112
+ def send_message_in_conversation(website_id, session_id, data)
113
+ return @parent.post(self._url_conversation(website_id, session_id, "/message"), data: data)
114
+ end
115
+
116
+ def update_message_in_conversation(website_id, session_id, fingerprint, data)
117
+ return @parent.patch(self._url_conversation(website_id, session_id, "/message/%d" % fingerprint), data: data)
118
+ end
119
+
120
+ def compose_message_in_conversation(website_id, session_id, data)
121
+ return @parent.patch(self._url_conversation(website_id, session_id, "/compose"), data: data)
122
+ end
123
+
124
+ def mark_messages_read_in_conversation(website_id, session_id, data)
125
+ return @parent.patch(self._url_conversation(website_id, session_id, "/read"), data: data)
126
+ end
127
+
128
+ def mark_messages_delivered_in_conversation(website_id, session_id, data)
129
+ return @parent.patch(self._url_conversation(website_id, session_id, "/delivered"), data: data)
130
+ end
131
+
132
+ def get_conversation_routing_assign(website_id, session_id)
133
+ return @parent.get(self._url_conversation(website_id, session_id, "/routing"))
134
+ end
135
+
136
+ def assign_conversation_routing(website_id, session_id, data)
137
+ return @parent.patch(self._url_conversation(website_id, session_id, "/routing"), data: data)
138
+ end
139
+
140
+ def get_conversation_metas(website_id, session_id)
141
+ return @parent.get(self._url_conversation(website_id, session_id, "/meta"))
142
+ end
143
+
144
+ def update_conversation_metas(website_id, session_id, data)
145
+ return @parent.patch(self._url_conversation(website_id, session_id, "/meta"), data: data)
146
+ end
147
+
148
+ def list_conversation_pages(website_id, session_id, page_number)
149
+ return @parent.get(self._url_conversation(website_id, session_id, "/pages/%d" % page_number))
150
+ end
151
+
152
+ def list_conversation_events(website_id, session_id, page_number)
153
+ return @parent.get(self._url_conversation(website_id, session_id, "/events/%d" % page_number))
154
+ end
155
+
156
+ def get_conversation_state(website_id, session_id)
157
+ return @parent.get(self._url_conversation(website_id, session_id, "/state"))
158
+ end
159
+
160
+ def change_conversation_state(website_id, session_id, data)
161
+ return @parent.patch(self._url_conversation(website_id, session_id, "/state"), data: data)
162
+ end
163
+
164
+ def get_block_status_for_conversation(website_id, session_id)
165
+ return @parent.get(self._url_conversation(website_id, session_id, "/block"))
166
+ end
167
+
168
+ def block_incoming_messages_for_conversation(website_id, session_id, data)
169
+ return @parent.patch(self._url_conversation(website_id, session_id, "/block"), data: data)
170
+ end
171
+
172
+ def request_email_transcript_for_conversation(website_id, session_id, data)
173
+ return @parent.post(self._url_conversation(website_id, session_id, "/transcript"), data: data)
174
+ end
175
+
176
+ def get_people_statistics(website_id)
177
+ return @parent.get(self._url_website(website_id, "/people/stats"))
178
+ end
179
+
180
+ def list_people_segments(website_id, page_number)
181
+ return @parent.get(self._url_website(website_id, "/people/segments/%d" % page_number))
182
+ end
183
+
184
+ def list_people_profiles(website_id, page_number)
185
+ return @parent.get(self._url_website(website_id, "/people/profiles/%d" % page_number))
186
+ end
187
+
188
+ def add_new_people_profile(website_id, data)
189
+ return @parent.post(self._url_website(website_id, "/people/profile"))
190
+ end
191
+
192
+ def check_people_profile_exists(website_id, people_id)
193
+ return @parent.head(self._url_people("profile", website_id, people_id, ""))
194
+ end
195
+
196
+ def get_people_profile(website_id, people_id)
197
+ return @parent.get(self._url_people("profile", website_id, people_id, ""))
198
+ end
199
+
200
+ def save_people_profile(website_id, people_id, data)
201
+ return @parent.put(self._url_people("profile", website_id, people_id, ""), data: data)
202
+ end
203
+
204
+ def update_people_profile(website_id, people_id, data)
205
+ return @parent.patch(self._url_people("profile", website_id, people_id, ""), data: data)
206
+ end
207
+
208
+ def remove_people_profile(website_id, people_id)
209
+ return @parent.remove(self._url_people("profile", website_id, people_id, ""))
210
+ end
211
+
212
+ def list_people_conversations(website_id, people_id, page_number)
213
+ return @parent.get(self._url_people("conversations", website_id, people_id, "/list/%d" % page_number))
214
+ end
215
+
216
+ def add_people_event(website_id, people_id, data)
217
+ return @parent.post(self._url_people("events", website_id, people_id, ""), data: data)
218
+ end
219
+
220
+ def list_people_events(website_id, people_id, page_number)
221
+ return @parent.get(self._url_people("events", website_id, people_id, "/list/%d" % page_number))
222
+ end
223
+
224
+ def get_people_data(website_id, people_id)
225
+ return @parent.get(self._url_people("data", website_id, people_id, ""))
226
+ end
227
+
228
+ def save_people_data(website_id, people_id, data)
229
+ return @parent.put(self._url_people("data", website_id, people_id, ""), data: data)
230
+ end
231
+
232
+ def get_people_subscription_status(website_id, people_id)
233
+ return @parent.get(self._url_people("subscription", website_id, people_id, ""))
234
+ end
235
+
236
+ def update_people_subscription_status(website_id, people_id, data)
237
+ return @parent.patch(self._url_people("subscription", website_id, people_id, ""), data: data)
238
+ end
239
+ end
240
+ end
metadata ADDED
@@ -0,0 +1,69 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: crisp-api
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Valerian Saliou
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2018-01-04 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rest-client
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 2.0.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 2.0.0
27
+ description: Crisp API Ruby
28
+ email: valerian@valeriansaliou.name
29
+ executables: []
30
+ extensions: []
31
+ extra_rdoc_files: []
32
+ files:
33
+ - ".gitignore"
34
+ - Gemfile
35
+ - LICENSE
36
+ - README.md
37
+ - crisp-api.gemspec
38
+ - examples/user_get_profile.rb
39
+ - examples/website_send_message_in_conversation.rb
40
+ - lib/crisp.rb
41
+ - lib/errors/route.rb
42
+ - lib/resources/bucket.rb
43
+ - lib/resources/user.rb
44
+ - lib/resources/website.rb
45
+ homepage: https://github.com/crisp-im/ruby-crisp-api
46
+ licenses:
47
+ - MIT
48
+ metadata: {}
49
+ post_install_message:
50
+ rdoc_options: []
51
+ require_paths:
52
+ - lib
53
+ required_ruby_version: !ruby/object:Gem::Requirement
54
+ requirements:
55
+ - - ">="
56
+ - !ruby/object:Gem::Version
57
+ version: '0'
58
+ required_rubygems_version: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
63
+ requirements: []
64
+ rubyforge_project:
65
+ rubygems_version: 2.6.11
66
+ signing_key:
67
+ specification_version: 4
68
+ summary: Crisp API Ruby
69
+ test_files: []