// Generated by CoffeeScript 1.3.3
(function() {
  var ReadLater, root;

  ReadLater = (function() {

    function ReadLater(username, password) {
      this.username = username;
      this.password = password;
      this.pocket_apikey = '4c2T7D4dg52f6r440gd746eW4cpkG7f6';
      this.pocket_auth_url = 'https://readitlaterlist.com/v2/auth?username={%USERNAME%}&password={%PASSWORD%}&apikey=' + this.pocket_apikey;
      this.pocket_add_url = 'https://readitlaterlist.com/v2/add?username={%USERNAME%}&password={%PASSWORD%}&apikey=' + this.pocket_apikey + '&url={%URL%}&title={%SELECTION%}';
      this.instap_auth_url = 'https://www.instapaper.com/api/authenticate?username={%USERNAME%}&password={%PASSWORD%}';
      this.instapp_add_url = 'https://www.instapaper.com/api/add?username={%USERNAME%}&password={%PASSWORD%}&url={%URL%}&title=&selection={%SELECTION%}';
    }

    ReadLater.prototype.init = function(username, password) {
      this.username = username;
      return this.password = password;
    };

    ReadLater.prototype.addItem = function(service, url, text, callback) {
      var req_url;
      if (service === 'pocket') {
        req_url = this.pocket_add_url;
      } else {
        req_url = this.instapp_add_url;
      }
      req_url = req_url.replace('{%USERNAME%}', encodeURIComponent(this.username));
      req_url = req_url.replace('{%PASSWORD%}', encodeURIComponent(this.password));
      req_url = req_url.replace('{%URL%}', encodeURIComponent(url));
      req_url = req_url.replace('{%SELECTION%}', encodeURIComponent(text));
      return $.get(req_url, callback);
    };

    return ReadLater;

  })();

  root = typeof exports !== "undefined" && exports !== null ? exports : this;

  root.ReadLaterServ = ReadLater;

}).call(this);
