tag:help.tenderapp.com,2008-11-12:/discussions/questions/11276-api-access-the-time-parserTender: Discussion 2014-01-02T19:45:41Ztag:help.tenderapp.com,2008-11-12:Comment/307344242013-12-23T21:53:28Z2013-12-23T21:53:28ZAPI - Access the time parser?<div><p>On a second side note I noticed the discussion list for each
user is cached and not updating on each load. But I didn't find the
cache timer in the API (Maybe I'm just bad at searching)</p>
<p>How long is it between cache updates?</p></div>Michaeltag:help.tenderapp.com,2008-11-12:Comment/307344242013-12-24T18:16:40Z2013-12-30T04:15:46ZAPI - Access the time parser?<div><p>Hey Michael,</p>
<p>You can use
<code>$.edate.timeAgoInWords($.edate.parseUTC(TIMESTAMP))</code> to
get "X minutes ago".</p>
<p>We use <code>resolved</code> internally, but I think most of the
UI uses <code>closed</code>. They are the same, it's just how
things have been historically.</p>
<p>As for the cache, there is no timed expiration: the cache should
be invalidated when a discussion/comment comes in for this user. If
you can give me a few examples, I'll be able to look into it,
albeit not until next week. Also, which call do you make to get the
JSON?</p>
<p>Let me know if there is anything else I can do for you.</p>
<p>Cheers!</p></div>Julientag:help.tenderapp.com,2008-11-12:Comment/307344242013-12-27T00:42:30Z2013-12-27T02:00:10ZAPI - Access the time parser?<div><p>Hi Julien,</p>
<p>Currently hacking away using Tampermonkey, afraid the edate
object isn't within my scope. No worries though, I'll figure
something else out. :)</p>
<p>Might be Tampermonkey causing the caching as well I suppose.
I'll have to look into that.</p>
<p>The call to get it is what you'd expect from Tampermonkey</p>
<pre>
<code>function xmlrequest(emailUrl) {
GM_xmlhttpRequest({
method: "GET",
headers: {
"X-Tender-Auth": "TOKEN",
"Accept": "application/vnd.tender-v1+json",
"Content-Type": "application/json"
},
url: emailUrl,
onload: function(data) {
var e = JSON.parse(data.response);
// do stuff
}
});
}</code>
</pre></div>Michaeltag:help.tenderapp.com,2008-11-12:Comment/307344242013-12-27T01:59:28Z2013-12-27T01:59:28ZAPI - Access the time parser?<div><p>Hey Michael,</p>
<p><code>edate</code> is only on the dashboard side: I tested it
with Tampermonkey and I could use it. If you want to do the same on
the front part, you can do
<code>Date.parseUTC(XXX).timeAgoInWords()</code>. I know it's
always somewhat of a pain to have those differences, but you can
easily check whether <code>$$</code> is defined for example (which
is Prototype, so that would be the front).</p>
<p>As for the call, I was asking more for the URL, to see which
endpoint you are calling.</p>
<p>Cheers!</p></div>Julientag:help.tenderapp.com,2008-11-12:Comment/307344242013-12-27T02:20:45Z2014-01-02T19:45:41ZAPI - Access the time parser?<div><p>Hi Julien,</p>
<p>Thanks for your quick response.</p>
<p>I had a look and it must be in my settings. $$ is not defined
when the<br>
script runs, but is defined if I look for it through the Chrome
console.<br>
(same with $.edate)</p>
<p>The URL I call is either<br>
<a href=
"https://api.tenderapp.com/company/discussions?user_email=[email">https://api.tenderapp.com/company/discussions?user_email=[email</a>
taken<br>
from "user-link" div]<br>
or<br>
<a href=
"https://api.tenderapp.com/company/discussions?user_id=[email">https://api.tenderapp.com/company/discussions?user_id=[email</a>
taken from<br>
"user-link" div] depending if it's an anon or created user.</p>
<p>Kind regards,<br>
Michael</p></div>Michaeltag:help.tenderapp.com,2008-11-12:Comment/307344242013-12-27T02:27:24Z2013-12-27T02:27:24ZAPI - Access the time parser?<div><p>Found it. Had a @require for latest jQuery which didn't place
nice. All<br>
good with eDate. ^_^</p></div>Michaeltag:help.tenderapp.com,2008-11-12:Comment/307344242013-12-27T02:43:27Z2013-12-27T02:43:27ZAPI - Access the time parser?<div><p>Hey Michael,</p>
<p>You do not need to require jQuery, as it's available both on the
front and on the back. The only caveat is that it is included in
mode "no conflict" on the front, so only available as
<code>jQuery</code>, since <code>$</code> still refers to
Prototype.</p>
<p>For convenience, you can simply use a closure:</p>
<pre>
<code>(function($) {
// Inside this function $ == jQuery
})(jQuery);</code>
</pre>
<p>If you are looking for last discussions, you can also look at
the miniprofile call: <code>/users/miniprofile/EMAIL</code>, it
returns HTML, not JSON, but it might still be useful for your
purpose, and works for both users and anonymous.</p>
<p>Cheers!</p></div>Julien