Class: Lifen::Flow

Inherits:
Base
  • Object
show all
Defined in:
lib/lifen/flow.rb

Instance Method Summary collapse

Instance Method Details

#attach_users(users_to_attach) ⇒ Object



41
42
43
44
45
46
47
48
49
50
51
# File 'lib/lifen/flow.rb', line 41

def attach_users(users_to_attach)
  params = extract_users_uuids(users_to_attach)

  json = client.post("central/api/chats/#{uuid}/attach_users?rel=activeUsers", params)

  build_users(json)

  check_if_users_were_attached!(users_to_attach)

  self
end

#createObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/lifen/flow.rb', line 11

def create
  users_to_attach = users

  params = {title: title, users: extract_users_uuids(users_to_attach)}

  json = client.post("central/api/chats?rel=activeUsers", params)

  json_flow = json.first

  flow = self.class.new(json_flow)

  self.user = user
  self.uuid = flow.uuid
  self.title = flow.title

  build_users(json_flow)

  check_if_users_were_attached!(users_to_attach)

  self
end

#detach_users(users_to_detach) ⇒ Object



53
54
55
56
57
58
59
60
61
62
63
# File 'lib/lifen/flow.rb', line 53

def detach_users(users_to_detach)
  params = extract_users_uuids(users_to_detach)

  json = client.post("central/api/chats/#{uuid}/detach_users?rel=activeUsers", params)

  build_users(json)

  check_if_users_were_detached!(users_to_detach)

  self
end

#saveObject



33
34
35
36
37
38
39
# File 'lib/lifen/flow.rb', line 33

def save
  params = {title: title, uuid: uuid}

  json = client.put("central/api/chats/#{uuid}", params)

  self.title = json["title"]
end