Skip to content
Snippets Groups Projects
Commit 932ae6b2 authored by Rodrigo Nascimento's avatar Rodrigo Nascimento
Browse files

Add examples of curl and json in integrations

parent 09159977
No related branches found
No related tags found
No related merge requests found
......@@ -42,6 +42,45 @@ Template.integrationsIncoming.helpers
_id: Random.id()
username: record.username
exampleJson: ->
record = Template.instance().record.get()
data =
username: record.alias
icon_emoji: record.emoji
icon_url: record.avatar
text: 'Example message'
attachments: [{
title: "Rocket.Chat"
title_link: "https://rocket.chat"
text: "Rocket.Chat, the best open source chat"
image_url: "https://rocket.chat/images/mockup.png"
color: "#764FA5"
}]
for key, value of data
delete data[key] if value in [null, ""]
return hljs.highlight('json', JSON.stringify(data, null, 2)).value
curl: ->
record = Template.instance().record.get()
data =
username: record.alias
icon_emoji: record.emoji
icon_url: record.avatar
text: 'Example message'
attachments: [{
title: "Rocket.Chat"
title_link: "https://rocket.chat"
text: "Rocket.Chat, the best open source chat"
image_url: "https://rocket.chat/images/mockup.png"
color: "#764FA5"
}]
for key, value of data
delete data[key] if value in [null, ""]
return "curl -X POST --data-urlencode 'payload=#{JSON.stringify(data)}' #{record.url}"
Template.integrationsIncoming.events
"blur input": (e, t) ->
......
......@@ -65,6 +65,14 @@
</div>
</div>
{{/if}}
<div class="input-line double-col">
<label>{{_ "Example"}}</label>
<div>
<pre><code class="hljs json json-example">{{{exampleJson}}}</code></pre>
<input type="text" name="curl" value="{{curl}}" disabled="disabled" />
<div class="settings-description"><a href="#" class="clipboard" data-clipboard-target="[name=curl]">{{_ "COPY_TO_CLIPBOARD"}}</a></div>
</div>
</div>
<div class="input-line message-example">
{{#nrr nrrargs 'message' example}}{{/nrr}}
</div>
......
......@@ -11,6 +11,7 @@ Package.onUse(function(api) {
api.use('coffeescript');
api.use('underscore');
api.use('simple:highlight.js');
api.use('rocketchat:lib@0.0.1');
api.use('kadira:flow-router', 'client');
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment