Skip to content

Commit 09cc58b

Browse files
committed
first
0 parents  commit 09cc58b

16 files changed

+373
-0
lines changed

.babelrc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{}

.editorconfig

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
root = true
2+
3+
[*]
4+
indent_style = space
5+
indent_size = 2
6+
charset = utf-8
7+
trim_trailing_whitespace = true
8+
insert_final_newline = true
9+
10+
[*.md]
11+
trim_trailing_whitespace = false

.eslintrc

+180
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,180 @@
1+
{
2+
"rules": {
3+
"strict": [
4+
2,
5+
"global"
6+
],
7+
"quotes": [
8+
2,
9+
"single"
10+
],
11+
"indent": [
12+
2,
13+
2
14+
],
15+
"one-var": [
16+
2,
17+
"never"
18+
],
19+
"consistent-return": 0,
20+
"no-use-before-define": [
21+
2,
22+
"nofunc"
23+
],
24+
"space-before-function-paren": [
25+
2,
26+
{
27+
"anonymous": "always",
28+
"named": "never"
29+
}
30+
],
31+
"space-after-keywords": [
32+
2,
33+
"always"
34+
],
35+
"array-bracket-spacing": [
36+
2,
37+
"never"
38+
],
39+
"space-in-parens": [
40+
2,
41+
"never"
42+
],
43+
"quote-props": [
44+
2,
45+
"as-needed"
46+
],
47+
"no-multiple-empty-lines": [
48+
2,
49+
{
50+
"max": 2
51+
}
52+
],
53+
"brace-style": [
54+
2,
55+
"1tbs"
56+
],
57+
"curly": [
58+
2,
59+
"all"
60+
],
61+
"key-spacing": [
62+
2,
63+
{
64+
"beforeColon": false,
65+
"afterColon": true
66+
}
67+
],
68+
"space-infix-ops": 2,
69+
"no-eval": 2,
70+
"no-with": 2,
71+
"eol-last": 2,
72+
"comma-dangle": [
73+
2,
74+
"never"
75+
],
76+
"no-cond-assign": 2,
77+
"no-constant-condition": 2,
78+
"no-control-regex": 2,
79+
"no-debugger": 2,
80+
"no-dupe-args": 2,
81+
"no-dupe-keys": 2,
82+
"no-duplicate-case": 2,
83+
"no-empty-character-class": 2,
84+
"no-empty": 2,
85+
"no-ex-assign": 2,
86+
"no-extra-boolean-cast": 2,
87+
"no-extra-semi": 2,
88+
"no-func-assign": 2,
89+
"no-inner-declarations": [
90+
2,
91+
"functions"
92+
],
93+
"no-invalid-regexp": 2,
94+
"no-irregular-whitespace": 2,
95+
"no-negated-in-lhs": 2,
96+
"no-obj-calls": 2,
97+
"no-regex-spaces": 2,
98+
"no-sparse-arrays": 2,
99+
"no-unreachable": 2,
100+
"use-isnan": 2,
101+
"valid-typeof": 2,
102+
"dot-notation": [
103+
2,
104+
{
105+
"allowKeywords": true
106+
}
107+
],
108+
"eqeqeq": 2,
109+
"no-alert": 2,
110+
"no-caller": 2,
111+
"no-empty-label": 2,
112+
"no-extend-native": 2,
113+
"no-extra-bind": 2,
114+
"no-fallthrough": 2,
115+
"no-implied-eval": 2,
116+
"no-iterator": 2,
117+
"no-labels": 2,
118+
"no-lone-blocks": 2,
119+
"no-loop-func": 2,
120+
"no-multi-spaces": 2,
121+
"no-multi-str": 2,
122+
"no-native-reassign": 2,
123+
"no-new-func": 2,
124+
"no-new-wrappers": 2,
125+
"no-new": 2,
126+
"no-octal-escape": 2,
127+
"no-octal": 2,
128+
"no-proto": 2,
129+
"no-redeclare": 2,
130+
"no-return-assign": 2,
131+
"no-script-url": 2,
132+
"no-sequences": 2,
133+
"no-unused-expressions": 2,
134+
"yoda": 2,
135+
"no-delete-var": 2,
136+
"no-label-var": 2,
137+
"no-shadow-restricted-names": 2,
138+
"no-shadow": 2,
139+
"no-undef-init": 2,
140+
"no-undef": 2,
141+
"no-unused-vars": [
142+
2,
143+
{
144+
"vars": "all",
145+
"args": "after-used"
146+
}
147+
],
148+
"camelcase": 2,
149+
"comma-spacing": 2,
150+
"new-cap": 2,
151+
"new-parens": 2,
152+
"no-array-constructor": 2,
153+
"no-mixed-spaces-and-tabs": [
154+
2,
155+
false
156+
],
157+
"no-new-object": 2,
158+
"no-spaced-func": 2,
159+
"no-trailing-spaces": 2,
160+
"no-underscore-dangle": 2,
161+
"no-wrap-func": 2,
162+
"semi-spacing": [
163+
2,
164+
{
165+
"before": false,
166+
"after": true
167+
}
168+
],
169+
"semi": 2,
170+
"space-return-throw-case": 2
171+
},
172+
"env": {
173+
"node": true,
174+
"mocha": true,
175+
"es6": true
176+
},
177+
"ecmaFeatures": {
178+
"modules": true
179+
}
180+
}

.gitattributes

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* text=auto

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
node_modules
2+
coverage
3+
dist

.package.json.swp

12 KB
Binary file not shown.

.travis.yml

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
language: node_js
2+
node_js:
3+
- '0.10'
4+
- '0.12'
5+
- 'iojs'

LICENSE

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
Copyright 2015 Bob Long <[email protected]>
2+
3+
Licensed under the Apache License, Version 2.0 (the "License");
4+
you may not use this file except in compliance with the License.
5+
You may obtain a copy of the License at
6+
7+
http://www.apache.org/licenses/LICENSE-2.0
8+
9+
Unless required by applicable law or agreed to in writing, software
10+
distributed under the License is distributed on an "AS IS" BASIS,
11+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
See the License for the specific language governing permissions and
13+
limitations under the License.

README.md

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# intercom-node [![NPM version][npm-image]][npm-url] [![Build Status][travis-image]][travis-url] [![Dependency Status][daviddm-image]][daviddm-url]
2+
> Official Node bindings to the Intercom API
3+
4+
5+
## Install
6+
7+
```sh
8+
$ npm install --save intercom-node
9+
```
10+
11+
12+
## Usage
13+
14+
```js
15+
var intercomNode = require('intercom-node');
16+
17+
intercomNode('Rainbow');
18+
```
19+
20+
## License
21+
22+
Apache-2.0 © [Bob Long]()
23+
24+
25+
[npm-image]: https://badge.fury.io/js/intercom-node.svg
26+
[npm-url]: https://npmjs.org/package/intercom-node
27+
[travis-image]: https://travis-ci.org/intercom/intercom-node.svg?branch=master
28+
[travis-url]: https://travis-ci.org/intercom/intercom-node
29+
[daviddm-image]: https://david-dm.org/intercom/intercom-node.svg?theme=shields.io
30+
[daviddm-url]: https://david-dm.org/intercom/intercom-node

gulpfile.js

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
var gulp = require('gulp');
2+
var eslint = require('gulp-eslint');
3+
var excludeGitignore = require('gulp-exclude-gitignore');
4+
var mocha = require('gulp-mocha');
5+
var istanbul = require('gulp-istanbul');
6+
var nsp = require('gulp-nsp');
7+
var plumber = require('gulp-plumber');
8+
var babel = require('gulp-babel');
9+
10+
// Initialize the babel transpiler so ES2015 files gets compiled
11+
// when they're loaded
12+
require('babel-core/register');
13+
14+
gulp.task('static', function () {
15+
return gulp.src('**/*.js')
16+
.pipe(excludeGitignore())
17+
.pipe(eslint())
18+
.pipe(eslint.format())
19+
.pipe(eslint.failAfterError());
20+
});
21+
22+
gulp.task('nsp', function (cb) {
23+
nsp('package.json', cb);
24+
});
25+
26+
gulp.task('pre-test', function () {
27+
return gulp.src('lib/**/*.js')
28+
.pipe(babel())
29+
.pipe(istanbul({includeUntested: true}))
30+
.pipe(istanbul.hookRequire());
31+
});
32+
33+
gulp.task('test', ['pre-test'], function (cb) {
34+
var mochaErr;
35+
36+
gulp.src('test/**/*.js')
37+
.pipe(plumber())
38+
.pipe(mocha({reporter: 'spec'}))
39+
.on('error', function (err) {
40+
mochaErr = err;
41+
})
42+
.pipe(istanbul.writeReports())
43+
.on('end', function () {
44+
cb(mochaErr);
45+
});
46+
});
47+
48+
gulp.task('babel', function () {
49+
return gulp.src('lib/**/*.js')
50+
.pipe(babel())
51+
.pipe(gulp.dest('dist'));
52+
});
53+
54+
gulp.task('prepublish', ['nsp', 'babel']);
55+
gulp.task('default', ['static', 'test']);

lib/.client.js.swp

12 KB
Binary file not shown.

lib/client.js

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
var unirest = require('unirest');
2+
3+
export class Client {
4+
constructor(appId, appApiKey) {
5+
this.appId = appId;
6+
this.appApiKey = appApiKey;
7+
}
8+
ping(f) {
9+
unirest.get('https://api.intercom.io/admins')
10+
.header('Accept', 'application/json')
11+
.header('Content-Type', 'application/json')
12+
.end(r => f(r.status));
13+
}
14+
}

lib/index.js

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from '../lib/client';

package.json

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
{
2+
"name": "intercom-node",
3+
"version": "0.0.0",
4+
"description": "Official Node bindings to the Intercom API",
5+
"homepage": "https://github.com/intercom/intercom-node",
6+
"repository": "intercom/intercom-node",
7+
"author": {
8+
"name": "Bob Long",
9+
"email": "[email protected]",
10+
"url": ""
11+
},
12+
"files": [
13+
"dist"
14+
],
15+
"main": "dist/index.js",
16+
"keywords": [
17+
"intercom",
18+
"api"
19+
],
20+
"dependencies": {
21+
"unirest": "*"
22+
},
23+
"devDependencies": {
24+
"gulp": "^3.6.0",
25+
"gulp-eslint": "^0.15.0",
26+
"gulp-exclude-gitignore": "^1.0.0",
27+
"gulp-istanbul": "^0.9.0",
28+
"gulp-mocha": "^2.0.0",
29+
"gulp-plumber": "^1.0.0",
30+
"gulp-nsp": "^0.4.5",
31+
"gulp-babel": "^5.1.0",
32+
"babel-core": "^5.5.0",
33+
"nock" : "*"
34+
},
35+
"scripts": {
36+
"prepublish": "gulp prepublish",
37+
"test": "gulp"
38+
},
39+
"license": "Apache-2.0"
40+
}

test/.index.js.swp

12 KB
Binary file not shown.

test/index.js

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import assert from 'assert';
2+
import {Client} from '../lib';
3+
var nock = require('nock');
4+
5+
describe('clients', function () {
6+
it('should be constructed', function () {
7+
let client = new Client('foo', 'bar');
8+
assert.equal('foo', client.appId);
9+
assert.equal('bar', client.appApiKey);
10+
});
11+
it('ping', function (done) {
12+
nock('https://api.intercom.io').get('/admins').reply(200, {});
13+
let client = new Client('foo', 'bar');
14+
client.ping(function (r) {
15+
assert.equal(200, r);
16+
done();
17+
});
18+
});
19+
});

0 commit comments

Comments
 (0)