Class: Crisp::WebsiteResource

Inherits:
Object
  • Object
show all
Defined in:
lib/resources/website.rb

Constant Summary collapse

SEARCH_CONVERSATIONS_QUERY_PARAMETERS =
[
  "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",
  "filter_date_end",
  "order_date_created",
  "order_date_updated",
]

Instance Method Summary collapse

Constructor Details

#initialize(parent) ⇒ WebsiteResource

Returns a new instance of WebsiteResource.



30
31
32
# File 'lib/resources/website.rb', line 30

def initialize(parent)
  @parent = parent
end

Instance Method Details

#add_new_people_profile(website_id, data) ⇒ Object



227
228
229
# File 'lib/resources/website.rb', line 227

def add_new_people_profile(website_id, data)
  return @parent.post(self._url_website(website_id, "/people/profile"), data: data)
end

#add_people_event(website_id, people_id, data) ⇒ Object



259
260
261
# File 'lib/resources/website.rb', line 259

def add_people_event(website_id, people_id, data)
  return @parent.post(self._url_people("events", website_id, people_id), data: data)
end

#assign_conversation_routing(website_id, session_id, data) ⇒ Object



175
176
177
# File 'lib/resources/website.rb', line 175

def assign_conversation_routing(website_id, session_id, data)
  return @parent.patch(self._url_conversation(website_id, session_id, "/routing"), data: data)
end

#batch_read_items(website_id, data) ⇒ Object



66
67
68
# File 'lib/resources/website.rb', line 66

def batch_read_items(website_id, data)
  return @parent.patch(self._url_website(website_id, "/batch/read"), data: data)
end

#batch_remove_items(website_id, data) ⇒ Object



70
71
72
# File 'lib/resources/website.rb', line 70

def batch_remove_items(website_id, data)
  return @parent.patch(self._url_website(website_id, "/batch/remove"), data: data)
end

#batch_resolve_items(website_id, data) ⇒ Object



62
63
64
# File 'lib/resources/website.rb', line 62

def batch_resolve_items(website_id, data)
  return @parent.patch(self._url_website(website_id, "/batch/resolve"), data: data)
end

#block_incoming_messages_for_conversation(website_id, session_id, data) ⇒ Object



207
208
209
# File 'lib/resources/website.rb', line 207

def block_incoming_messages_for_conversation(website_id, session_id, data)
  return @parent.patch(self._url_conversation(website_id, session_id, "/block"), data: data)
end

#change_conversation_state(website_id, session_id, data) ⇒ Object



199
200
201
# File 'lib/resources/website.rb', line 199

def change_conversation_state(website_id, session_id, data)
  return @parent.patch(self._url_conversation(website_id, session_id, "/state"), data: data)
end

#check_conversation_exists(website_id, session_id) ⇒ Object



131
132
133
# File 'lib/resources/website.rb', line 131

def check_conversation_exists(website_id, session_id)
  return @parent.head(self._url_conversation(website_id, session_id))
end

#check_people_profile_exists(website_id, people_id) ⇒ Object



231
232
233
# File 'lib/resources/website.rb', line 231

def check_people_profile_exists(website_id, people_id)
  return @parent.head(self._url_people("profile", website_id, people_id))
end

#compose_message_in_conversation(website_id, session_id, data) ⇒ Object



159
160
161
# File 'lib/resources/website.rb', line 159

def compose_message_in_conversation(website_id, session_id, data)
  return @parent.patch(self._url_conversation(website_id, session_id, "/compose"), data: data)
end

#count_visitors(website_id) ⇒ Object



94
95
96
# File 'lib/resources/website.rb', line 94

def count_visitors(website_id)
  return @parent.get(self._url_website(website_id, "/visitors/count"))
end

#create_new_conversation(website_id) ⇒ Object



127
128
129
# File 'lib/resources/website.rb', line 127

def create_new_conversation(website_id)
  return @parent.post(self._url_website(website_id, "/conversation"))
end

#create_website(data) ⇒ Object



50
51
52
# File 'lib/resources/website.rb', line 50

def create_website(data)
  return @parent.post("/website", data)
end

#delete_website(website_id) ⇒ Object



58
59
60
# File 'lib/resources/website.rb', line 58

def delete_website(website_id)
  return @parent.delete(self._url_website(website_id))
end

#find_people_profile_by_email(website_id, email) ⇒ Object



235
236
237
# File 'lib/resources/website.rb', line 235

def find_people_profile_by_email(website_id, email)
  return @parent.get(self._url_people("profile", website_id, email))
end

#get_block_status_for_conversation(website_id, session_id) ⇒ Object



203
204
205
# File 'lib/resources/website.rb', line 203

def get_block_status_for_conversation(website_id, session_id)
  return @parent.get(self._url_conversation(website_id, session_id, "/block"))
end

#get_conversation(website_id, session_id) ⇒ Object



135
136
137
# File 'lib/resources/website.rb', line 135

def get_conversation(website_id, session_id)
  return @parent.get(self._url_conversation(website_id, session_id))
end

#get_conversation_metas(website_id, session_id) ⇒ Object



179
180
181
# File 'lib/resources/website.rb', line 179

def get_conversation_metas(website_id, session_id)
  return @parent.get(self._url_conversation(website_id, session_id, "/meta"))
end

#get_conversation_routing_assign(website_id, session_id) ⇒ Object



171
172
173
# File 'lib/resources/website.rb', line 171

def get_conversation_routing_assign(website_id, session_id)
  return @parent.get(self._url_conversation(website_id, session_id, "/routing"))
end

#get_conversation_state(website_id, session_id) ⇒ Object



195
196
197
# File 'lib/resources/website.rb', line 195

def get_conversation_state(website_id, session_id)
  return @parent.get(self._url_conversation(website_id, session_id, "/state"))
end

#get_messages_in_conversation(website_id, session_id, query) ⇒ Object



147
148
149
# File 'lib/resources/website.rb', line 147

def get_messages_in_conversation(website_id, session_id, query)
  return @parent.get(self._url_conversation(website_id, session_id, "/messages"), query: query)
end

#get_people_data(website_id, people_id) ⇒ Object



267
268
269
# File 'lib/resources/website.rb', line 267

def get_people_data(website_id, people_id)
  return @parent.get(self._url_people("data", website_id, people_id))
end

#get_people_profile(website_id, people_id) ⇒ Object



239
240
241
# File 'lib/resources/website.rb', line 239

def get_people_profile(website_id, people_id)
  return @parent.get(self._url_people("profile", website_id, people_id))
end

#get_people_statistics(website_id) ⇒ Object



215
216
217
# File 'lib/resources/website.rb', line 215

def get_people_statistics(website_id)
  return @parent.get(self._url_website(website_id, "/people/stats"))
end

#get_people_subscription_status(website_id, people_id) ⇒ Object



279
280
281
# File 'lib/resources/website.rb', line 279

def get_people_subscription_status(website_id, people_id)
  return @parent.get(self._url_people("subscription", website_id, people_id))
end

#get_session_id_by_token(website_id, token) ⇒ Object



287
288
289
# File 'lib/resources/website.rb', line 287

def get_session_id_by_token(website_id, token)
  return @parent.get(self._url_website(website_id, "/visitors/token/#{token}"))
end

#get_website(website_id) ⇒ Object



54
55
56
# File 'lib/resources/website.rb', line 54

def get_website(website_id)
  return @parent.get(self._url_website(website_id))
end

#get_website_availability_status(website_id) ⇒ Object



74
75
76
# File 'lib/resources/website.rb', line 74

def get_website_availability_status(website_id)
  return @parent.get(self._url_website(website_id, "/availability/status"))
end

#get_website_settings(website_id) ⇒ Object



86
87
88
# File 'lib/resources/website.rb', line 86

def get_website_settings(website_id)
  return @parent.get(self._url_website(website_id, "/settings"))
end

#initiate_conversation_with_existing_session(website_id, session_id) ⇒ Object



143
144
145
# File 'lib/resources/website.rb', line 143

def initiate_conversation_with_existing_session(website_id, session_id)
  return @parent.post(self._url_conversation(website_id, session_id, "/initiate"))
end

#list_conversation_events(website_id, session_id, page_number) ⇒ Object



191
192
193
# File 'lib/resources/website.rb', line 191

def list_conversation_events(website_id, session_id, page_number)
  return @parent.get(self._url_conversation(website_id, session_id, "/events/%d" % page_number))
end

#list_conversation_pages(website_id, session_id, page_number) ⇒ Object



187
188
189
# File 'lib/resources/website.rb', line 187

def list_conversation_pages(website_id, session_id, page_number)
  return @parent.get(self._url_conversation(website_id, session_id, "/pages/%d" % page_number))
end

#list_conversations(website_id, page_number = 1) ⇒ Object



123
124
125
# File 'lib/resources/website.rb', line 123

def list_conversations(website_id, page_number = 1)
  return self.search_conversations(website_id, page_number)
end

#list_last_active_website_operators(website_id) ⇒ Object



82
83
84
# File 'lib/resources/website.rb', line 82

def list_last_active_website_operators(website_id)
  return @parent.get(self._url_website(website_id, "/operators/active"))
end

#list_people_conversations(website_id, people_id, page_number) ⇒ Object



255
256
257
# File 'lib/resources/website.rb', line 255

def list_people_conversations(website_id, people_id, page_number)
  return @parent.get(self._url_people("conversations", website_id, people_id, "/list/%d" % page_number))
end

#list_people_events(website_id, people_id, page_number) ⇒ Object



263
264
265
# File 'lib/resources/website.rb', line 263

def list_people_events(website_id, people_id, page_number)
  return @parent.get(self._url_people("events", website_id, people_id, "/list/%d" % page_number))
end

#list_people_profiles(website_id, page_number) ⇒ Object



223
224
225
# File 'lib/resources/website.rb', line 223

def list_people_profiles(website_id, page_number)
  return @parent.get(self._url_website(website_id, "/people/profiles/%d" % page_number))
end

#list_people_segments(website_id, page_number) ⇒ Object



219
220
221
# File 'lib/resources/website.rb', line 219

def list_people_segments(website_id, page_number)
  return @parent.get(self._url_website(website_id, "/people/segments/%d" % page_number))
end

#list_visitors(website_id, page_number) ⇒ Object



98
99
100
# File 'lib/resources/website.rb', line 98

def list_visitors(website_id, page_number)
  return @parent.get(self._url_website(website_id, "/visitors/list/%d" % page_number))
end

#list_website_operators(website_id) ⇒ Object



78
79
80
# File 'lib/resources/website.rb', line 78

def list_website_operators(website_id)
  return @parent.get(self._url_website(website_id, "/operators/list"))
end

#mark_messages_delivered_in_conversation(website_id, session_id, data) ⇒ Object



167
168
169
# File 'lib/resources/website.rb', line 167

def mark_messages_delivered_in_conversation(website_id, session_id, data)
  return @parent.patch(self._url_conversation(website_id, session_id, "/delivered"), data: data)
end

#mark_messages_read_in_conversation(website_id, session_id, data) ⇒ Object



163
164
165
# File 'lib/resources/website.rb', line 163

def mark_messages_read_in_conversation(website_id, session_id, data)
  return @parent.patch(self._url_conversation(website_id, session_id, "/read"), data: data)
end

#remove_conversation(website_id, session_id) ⇒ Object



139
140
141
# File 'lib/resources/website.rb', line 139

def remove_conversation(website_id, session_id)
  return @parent.remove(self._url_conversation(website_id, session_id))
end

#remove_people_profile(website_id, people_id) ⇒ Object



251
252
253
# File 'lib/resources/website.rb', line 251

def remove_people_profile(website_id, people_id)
  return @parent.remove(self._url_people("profile", website_id, people_id))
end

#request_email_transcript_for_conversation(website_id, session_id, data) ⇒ Object



211
212
213
# File 'lib/resources/website.rb', line 211

def request_email_transcript_for_conversation(website_id, session_id, data)
  return @parent.post(self._url_conversation(website_id, session_id, "/transcript"), data: data)
end

#save_people_data(website_id, people_id, data) ⇒ Object



271
272
273
# File 'lib/resources/website.rb', line 271

def save_people_data(website_id, people_id, data)
  return @parent.put(self._url_people("data", website_id, people_id), data: data)
end

#save_people_profile(website_id, people_id, data) ⇒ Object



243
244
245
# File 'lib/resources/website.rb', line 243

def save_people_profile(website_id, people_id, data)
  return @parent.put(self._url_people("profile", website_id, people_id), data: data)
end

#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 = "") ⇒ Object



102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
# File 'lib/resources/website.rb', line 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 = "")
  resource_url = ""
  query_parameters = []

  SEARCH_CONVERSATIONS_QUERY_PARAMETERS.each do |parameter|
    parameter_value = binding.local_variable_get(parameter)

    if parameter_value != ""
      query_parameters.push("%s=%s" % [parameter, CGI.escape(parameter_value).gsub("+", "%20")])
    end
  end

  if query_parameters != []
    resource_url = self._url_website(website_id, "/conversations/%d?%s" % [page_number, query_parameters.join("&")])
  else
    resource_url = self._url_website(website_id, "/conversations/%d" % page_number)
  end

  return @parent.get(resource_url)
end

#send_message_in_conversation(website_id, session_id, data) ⇒ Object



151
152
153
# File 'lib/resources/website.rb', line 151

def send_message_in_conversation(website_id, session_id, data)
  return @parent.post(self._url_conversation(website_id, session_id, "/message"), data: data)
end

#update_conversation_metas(website_id, session_id, data) ⇒ Object



183
184
185
# File 'lib/resources/website.rb', line 183

def update_conversation_metas(website_id, session_id, data)
  return @parent.patch(self._url_conversation(website_id, session_id, "/meta"), data: data)
end

#update_message_in_conversation(website_id, session_id, fingerprint, data) ⇒ Object



155
156
157
# File 'lib/resources/website.rb', line 155

def update_message_in_conversation(website_id, session_id, fingerprint, data)
  return @parent.patch(self._url_conversation(website_id, session_id, "/message/%d" % fingerprint), data: data)
end

#update_people_data(website_id, people_id, data) ⇒ Object



275
276
277
# File 'lib/resources/website.rb', line 275

def update_people_data(website_id, people_id, data)
  return @parent.patch(self._url_people("data", website_id, people_id), data: data)
end

#update_people_profile(website_id, people_id, data) ⇒ Object



247
248
249
# File 'lib/resources/website.rb', line 247

def update_people_profile(website_id, people_id, data)
  return @parent.patch(self._url_people("profile", website_id, people_id), data: data)
end

#update_people_subscription_status(website_id, people_id, data) ⇒ Object



283
284
285
# File 'lib/resources/website.rb', line 283

def update_people_subscription_status(website_id, people_id, data)
  return @parent.patch(self._url_people("subscription", website_id, people_id), data: data)
end

#update_website_settings(website_id, data) ⇒ Object



90
91
92
# File 'lib/resources/website.rb', line 90

def update_website_settings(website_id, data)
  return @parent.patch(self._url_website(website_id, "/settings"), data: data)
end