Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
clearbit
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
prospector
clearbit
Commits
d5516615
Commit
d5516615
authored
Oct 09, 2014
by
Ben Drucker
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow a person to be fetched with Person#find
parent
b96598c1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
140 additions
and
0 deletions
+140
-0
person.js
src/person.js
+28
-0
person.json
test/fixtures/person.json
+73
-0
person.js
test/person.js
+39
-0
No files found.
src/person.js
0 → 100644
View file @
d5516615
'use strict'
;
var
assert
=
require
(
'assert'
);
var
_
=
require
(
'lodash'
);
module
.
exports
=
function
(
client
)
{
function
Person
(
data
)
{
_
.
extend
(
this
,
data
);
}
Person
.
find
=
function
(
options
)
{
assert
(
options
&&
options
.
email
,
'An email must be provided'
);
return
this
.
client
.
request
(
_
.
extend
({
api
:
'person'
,
path
:
'/people/email/'
+
options
.
email
,
query
:
_
.
pick
(
options
,
'subscribe'
,
'company'
)
},
options
))
.
bind
(
this
)
.
then
(
function
(
data
)
{
return
new
this
(
data
);
});
};
Person
.
prototype
.
client
=
Person
.
client
=
client
;
return
Person
;
};
\ No newline at end of file
test/fixtures/person.json
0 → 100644
View file @
d5516615
{
"id"
:
"d54c54ad-40be-4305-8a34-0ab44710b90d"
,
"name"
:
{
"fullName"
:
"Alex MacCaw"
,
"givenName"
:
"Alex"
,
"familyName"
:
"MacCaw"
},
"email"
:
"alex@alexmaccaw.com"
,
"gender"
:
"male"
,
"location"
:
"San Francisco"
,
"bio"
:
"O'Reilly author, software engineer & traveller. Founder of https://clearbit.co"
,
"site"
:
"http://alexmaccaw.com"
,
"avatar"
:
"https://pbs.twimg.com/profile_images/1826201101/297606_10150904890650705_570400704_21211347_1883468370_n.jpeg"
,
"employment"
:
{
"name"
:
"Clearbit"
,
"title"
:
"CEO"
,
"domain"
:
"clearbit.co"
},
"facebook"
:
{
"handle"
:
"amaccaw"
},
"github"
:
{
"handle"
:
"maccman"
,
"avatar"
:
"http://www.gravatar.com/avatar/baf018e2cc4616e4776d323215c7136c"
,
"company"
:
"Freelance"
,
"blog"
:
"http://alexmaccaw.com"
,
"followers"
:
2880
,
"following"
:
94
},
"twitter"
:
{
"handle"
:
"maccaw"
,
"id"
:
2006261
,
"bio"
:
"O'Reilly author, software engineer & traveller. Founder of https://clearbit.co"
,
"followers"
:
14993
,
"following"
:
1645
,
"location"
:
"San Francisco"
,
"site"
:
"http://alexmaccaw.com"
,
"avatar"
:
"https://pbs.twimg.com/profile_images/1826201101/297606_10150904890650705_570400704_21211347_1883468370_n.jpeg"
},
"linkedin"
:
{
"handle"
:
"pub/alex-maccaw/78/929/ab5"
},
"googleplus"
:
{
"handle"
:
null
},
"angellist"
:
{
"handle"
:
null
,
"bio"
:
null
,
"blog"
:
null
,
"site"
:
null
,
"followers"
:
null
,
"avatar"
:
null
},
"aboutme"
:
{
"handle"
:
"maccaw"
,
"bio"
:
"Software engineer & traveller. Walker, skier, reader, tennis player, breather, ginger beer drinker, scooterer & generally enjoying things :)"
,
"avatar"
:
"http://o.aolcdn.com/dims-global/dims/ABOUTME/5/803/408/80/http://d3mod6n032mdiz.cloudfront.net/thumb2/m/a/c/maccaw/maccaw-840x560.jpg"
},
"gravatar"
:
{
"handle"
:
"maccman"
,
"urls"
:
[
],
"avatar"
:
"http://2.gravatar.com/avatar/994909da96d3afaf4daaf54973914b64"
,
"avatars"
:
[
{
"url"
:
"http://2.gravatar.com/avatar/994909da96d3afaf4daaf54973914b64"
,
"type"
:
"thumbnail"
}
]
}
}
\ No newline at end of file
test/person.js
0 → 100644
View file @
d5516615
'use strict'
;
var
expect
=
require
(
'chai'
).
expect
;
var
nock
=
require
(
'nock'
);
var
Client
=
require
(
'../src/client'
);
describe
(
'Person'
,
function
()
{
var
client
=
new
Client
({
key
:
'k'
});
var
Person
=
require
(
'../src/person'
)(
client
);
var
mock
;
before
(
function
()
{
mock
=
nock
(
'https://person.clearbit.co'
);
});
after
(
nock
.
cleanAll
);
afterEach
(
function
()
{
mock
.
done
();
});
describe
(
'Person#find'
,
function
()
{
it
(
'can find a person by email'
,
function
()
{
var
alex
=
require
(
'./fixtures/person'
);
mock
.
get
(
'/v1/people/email/alex@alexmaccaw.com'
)
.
reply
(
200
,
alex
);
return
Person
.
find
({
email
:
'alex@alexmaccaw.com'
})
.
then
(
function
(
person
)
{
expect
(
person
)
.
to
.
be
.
an
.
instanceOf
(
Person
)
.
and
.
have
.
property
(
'id'
,
alex
.
id
);
});
});
});
});
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment