Skip to content

Commit

Permalink
Allow configured protocol - boneskull#18
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonfah committed Oct 4, 2016
1 parent 1a4f282 commit b8e6b14
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 16 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Create a `fogbugz.conf.json` in your app's root directory. It should look like

```json
{
"protocol": "https",
"host": "zzz.fogbugz.com",
"username": "zzz@yyy.com",
"password": "Password1"
Expand Down
30 changes: 14 additions & 16 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@
this:
```json
{
"protocol": "https",
"host": "zzz.fogbugz.com",
"username": "zzz@yyy.com",
"password": "Password1"
"password": "Password1"
}
```
Usage
Expand Down Expand Up @@ -49,12 +50,6 @@ var cache = require('memory-cache');
var conf;
var fogbugz;

/**
* Default protocol
* @type {string}
*/
var PROTOCOL = 'https';

/**
* URL masks for the various API calls
* @type {{logon: string, logoff: string, listFilters: string,
Expand Down Expand Up @@ -201,7 +196,7 @@ fogbugz = {
if (!token) {
dfrd.reject(MODULE_ERRORS.undefinedToken);
} else {
request(format(URLs.logoff, PROTOCOL, conf.host, token),
request(format(URLs.logoff, conf.protocol, conf.host, token),
function(err) {
if (err) {
dfrd.reject(err);
Expand Down Expand Up @@ -236,7 +231,7 @@ fogbugz = {
});
}

request(format(URLs.logon, PROTOCOL, conf.host, conf.username,
request(format(URLs.logon, conf.protocol, conf.host, conf.username,
conf.password),
function(err, res, body) {
var newToken;
Expand Down Expand Up @@ -285,7 +280,7 @@ fogbugz = {
type: filter.$.type,
id: filter.$.sFilter,
url: format('%s://%s/default.asp?pgx=LF&ixFilter=%s',
PROTOCOL, conf.host, filter.$.sFilter)
conf.protocol, conf.host, filter.$.sFilter)
});
});
}
Expand All @@ -294,7 +289,7 @@ fogbugz = {
if (!token) {
dfrd.reject(MODULE_ERRORS.undefinedToken);
} else {
request(format(URLs.listFilters, PROTOCOL, conf.host, token),
request(format(URLs.listFilters, conf.protocol, conf.host, token),
function(err, res, body) {
var filters;
if (err) {
Expand Down Expand Up @@ -327,7 +322,7 @@ fogbugz = {
dfrd.reject(MODULE_ERRORS.undefinedToken);
} else {
id = typeof filter === 'string' ? filter : filter.id;
request(format(URLs.setCurrentFilter, PROTOCOL, conf.host, id,
request(format(URLs.setCurrentFilter, conf.protocol, conf.host, id,
token), function(err, res, body) {
if (err) {
dfrd.reject(err);
Expand Down Expand Up @@ -370,7 +365,7 @@ fogbugz = {
operations: kase.$.operations.split(','),
title: kase.sTitle[0].trim(),
status: kase.sStatus[0].trim(),
url: format('%s://%s/default.asp?%s', PROTOCOL, conf.host,
url: format('%s://%s/default.asp?%s', conf.protocol, conf.host,
kase.$.ixBug),
fixFor: kase.sFixFor[0].trim()
});
Expand Down Expand Up @@ -410,7 +405,7 @@ fogbugz = {
if (!token) {
dfrd.reject(MODULE_ERRORS.undefinedToken);
} else {
url = format(URLs.search, PROTOCOL, conf.host, query, fields, max,
url = format(URLs.search, conf.protocol, conf.host, query, fields, max,
token);
request(url, function(err, res, body) {
var newCases;
Expand Down Expand Up @@ -457,7 +452,7 @@ fogbugz = {
operations: kase.$.operations.split(','),
title: kase.sTitle[0].trim(),
status: kase.sStatus[0].trim(),
url: format('%s://%s/default.asp?%s', PROTOCOL, conf.host,
url: format('%s://%s/default.asp?%s', conf.protocol, conf.host,
kase.$.ixBug),
fixFor: kase.sFixFor[0].trim()
});
Expand Down Expand Up @@ -497,7 +492,7 @@ fogbugz = {
if (!token) {
dfrd.reject(MODULE_ERRORS.undefinedToken);
} else {
url = format(URLs.edit, PROTOCOL, conf.host, token, id, fields);
url = format(URLs.edit, conf.protocol, conf.host, token, id, fields);
// Some work need to do, parameters .....
Object.keys(parameters).forEach(function(k) {
url += '&' + k + '=' + parameters[k];
Expand Down Expand Up @@ -537,6 +532,9 @@ if (process.env.NODE_FOGBUGZ_CONFIG) {
conf = require('./fogbugz.conf.json');
}

//Default to https if protocol not specified in conf (backwards compatibility)
conf.protocol = conf.protocol || 'https';

module.exports = fogbugz;
module.exports.Filter = Filter;
module.exports.Case = Case;

0 comments on commit b8e6b14

Please sign in to comment.