Class: Mural::Client

Inherits:
Object
  • Object
show all
Includes:
Authentication
Defined in:
lib/mural/client.rb,
lib/mural/client/rooms.rb,
lib/mural/client/users.rb,
lib/mural/client/murals.rb,
lib/mural/client/search.rb,
lib/mural/client/templates.rb,
lib/mural/client/workspaces.rb,
lib/mural/client/mural_content.rb,
lib/mural/client/authentication.rb,
lib/mural/client/users/room_users.rb,
lib/mural/client/users/mural_users.rb,
lib/mural/client/mural_content/tags.rb,
lib/mural/client/mural_content/areas.rb,
lib/mural/client/mural_content/chats.rb,
lib/mural/client/mural_content/files.rb,
lib/mural/client/mural_content/arrows.rb,
lib/mural/client/mural_content/images.rb,
lib/mural/client/mural_content/shapes.rb,
lib/mural/client/mural_content/tables.rb,
lib/mural/client/mural_content/titles.rb,
lib/mural/client/mural_content/widgets.rb,
lib/mural/client/mural_content/comments.rb,
lib/mural/client/mural_content/text_boxes.rb,
lib/mural/client/mural_content/sticky_notes.rb,
lib/mural/client/mural_content/facilitation_features.rb

Defined Under Namespace

Modules: Authentication Classes: MuralContent, Murals, Rooms, Search, Templates, Users, Workspaces

Constant Summary collapse

ENV_VARS =
{
  host: 'MURAL_HOST',
  client_id: 'MURAL_CLIENT_ID',
  client_secret: 'MURAL_CLIENT_SECRET',
  redirect_uri: 'MURAL_REDIRECT_URI',
  scope: 'MURAL_SCOPE',
  access_token: 'MURAL_ACCESS_TOKEN',
  refresh_token: 'MURAL_REFRESH_TOKEN'
}.freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Authentication

#authorize_url, #refresh, #request_token

Constructor Details

#initializeClient

Returns a new instance of Client.



34
35
36
37
38
39
40
41
42
43
44
# File 'lib/mural/client.rb', line 34

def initialize
  @host = 'app.mural.co'

  @mural_content = Mural::Client::MuralContent.new(self)
  @murals = Mural::Client::Murals.new(self)
  @rooms = Mural::Client::Rooms.new(self)
  @search = Mural::Client::Search.new(self)
  @templates = Mural::Client::Templates.new(self)
  @users = Mural::Client::Users.new(self)
  @workspaces = Mural::Client::Workspaces.new(self)
end

Instance Attribute Details

#mural_contentObject (readonly)

Returns the value of attribute mural_content.



31
32
33
# File 'lib/mural/client.rb', line 31

def mural_content
  @mural_content
end

#muralsObject (readonly)

Returns the value of attribute murals.



31
32
33
# File 'lib/mural/client.rb', line 31

def murals
  @murals
end

#roomsObject (readonly)

Returns the value of attribute rooms.



31
32
33
# File 'lib/mural/client.rb', line 31

def rooms
  @rooms
end

#searchObject (readonly)

Returns the value of attribute search.



31
32
33
# File 'lib/mural/client.rb', line 31

def search
  @search
end

#templatesObject (readonly)

Returns the value of attribute templates.



31
32
33
# File 'lib/mural/client.rb', line 31

def templates
  @templates
end

#usersObject (readonly)

Returns the value of attribute users.



31
32
33
# File 'lib/mural/client.rb', line 31

def users
  @users
end

#workspacesObject (readonly)

Returns the value of attribute workspaces.



31
32
33
# File 'lib/mural/client.rb', line 31

def workspaces
  @workspaces
end

Class Method Details

.from_envObject



17
18
19
20
21
22
23
24
25
# File 'lib/mural/client.rb', line 17

def self.from_env
  new.tap do |client|
    ENV_VARS.each do |attr, env_var|
      value = ENV.fetch(env_var, nil)

      client.public_send(:"#{attr}=", value) unless value.nil?
    end
  end
end

Instance Method Details

#delete(path) ⇒ Object



75
76
77
78
79
80
# File 'lib/mural/client.rb', line 75

def delete(path)
  uri = URI::HTTPS.build(host: host, path: path)
  req = Net::HTTP::Delete.new(uri)

  retryable_request(req)
end

#get(path, query = {}) ⇒ Object



46
47
48
49
50
51
52
53
54
55
# File 'lib/mural/client.rb', line 46

def get(path, query = {})
  uri = URI::HTTPS.build(
    host: host,
    path: path,
    query: URI.encode_www_form(query.compact)
  )

  req = Net::HTTP::Get.new uri
  retryable_request(req)
end

#patch(path, body = {}) ⇒ Object



66
67
68
69
70
71
72
73
# File 'lib/mural/client.rb', line 66

def patch(path, body = {})
  uri = URI::HTTPS.build(host: host, path: path)
  req = Net::HTTP::Patch.new(uri)
  req['Content-Type'] = 'application/json'
  req.body = body.compact.to_json

  retryable_request(req)
end

#post(path, body = {}) ⇒ Object



57
58
59
60
61
62
63
64
# File 'lib/mural/client.rb', line 57

def post(path, body = {})
  uri = URI::HTTPS.build(host: host, path: path)
  req = Net::HTTP::Post.new(uri)
  req['Content-Type'] = 'application/json'
  req.body = body.compact.to_json

  retryable_request(req)
end