Mural Ruby
Ruby library for the Mural public API.
Disclaimer
The views and opinions expressed in this repository are solely hose of the individual contributors and do not represent the official view of Tactivos, Inc. d/b/a Mural.
Mural does not endorse this repository in any way.
Installation
git checkout https://github.com/mickaelpham/mural-ruby
cd mural-ruby
bundle install
Authorization
-
Register a new app and gather your
client_id
andclient_secret
. For the scopes, pick the minimum required for your application. -
Create a
.env
file with the following template and fill inMURAL_CLIENT_ID
andMURAL_CLIENT_SECRET
with those values:
MURAL_CLIENT_ID=
MURAL_CLIENT_SECRET=
MURAL_SCOPE=
MURAL_REDIRECT_URI=http://localhost:4567/callback
MURAL_HOST=app.mural.co
- Run the script to request your access and refresh tokens:
bin/authorize
- Start the console:
bin/console
- From the console, create a client instance and start using it, e.g.:
irb(main):001> mural = Mural::Client.from_env
=>
#<Mural::Client:0x0000000120baa740
...
irb(main):002> mural.users.current_user
=>
#<Mural::CurrentUser:0x0000000124614bd8
@avatar="<AVATAR_URL>",
@company_id=nil,
@company_name=nil,
@created_on=1753301275000,
@email="<USER_EMAIL>",
@first_name="<USER_FIRST_NAME>",
@id="=<USER_ID>",
@last_active_workspace="<USER_WORKSPACE>",
@last_name="<USER_LAST_NAME>",
@type="member">
Usage
Upload a file to a mural
To upload a my.pdf
file that's located in the same directory as where you are
running the script:
MURAL_ID = 'workspace-1.mural-1'
client = Mural::Client.from_env
# Create an asset, receive an URL to upload the content to.
asset = client.mural_content.create_asset(
MURAL_ID,
file_extension: 'pdf',
asset_type: 'file'
)
# Upload the asset to the received URL.
request = Net::HTTP::Put.new(uri)
request['x-ms-blob-type'] = asset.headers.blob_type
path = File.expand_path('./my.pdf', __dir__)
request.body = File.read(path)
Net::HTTP.start(
uri.hostname, uri.port, use_ssl: uri.scheme == 'https'
) do |http|
http.request request
end
# Create a `file` widget on the mural to display the asset preview.
params = Mural::Widget::CreateFileParams.new.tap do |params|
params.name = asset.name
params.x = 250
params.y = 0
end
client.mural_content.create_file(MURAL_ID, params)
Mentioning someone in a comment
- You can reply to a comment by passing a
replies
array ofString
message. Each message will be added as a reply to the original comment. - You can "[at] mention" someone in a comment or in a reply by using the
following pattern in the
message
or thereplies
:
@[<USER FULL NAME> @<USER ID>](<USER ID>)
Example replying to a thread:
MURAL_ID = 'mural-1'
COMMENT_ID = 'comment-1'
reply_to_params = Mural::Widget::UpdateCommentParams.new.tap do |c|
c.replies = ["Can you have a look @[John Doe @user-1](user-1)]?"]
end
client.mural_content.update_comment(MURAL_ID, COMMENT_ID, reply_to_params)
Note that the user must already be a mural member for the mention to trigger an email notification.
Known limitations
-
DrawWidget
, AKA sketches, are not returned by theGET widgets
endpoint.
- Similarly,
InkingWidget
, AKA drawings, are not returned by the endpoint.
- Mind maps are smart widgets, they are simply a collection of text and arrow
widgets. There are no specific
type
for a mind map in the API.
- Likewise, smart planners are collection of widgets, and the API doesn't specify anything about them.