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
59fddd1b
Commit
59fddd1b
authored
Dec 21, 2014
by
Alex MacCaw
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #6 from clearbit/alex-add-flag
Add flagging API.
parents
7c23e29a
42d03e78
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
4 deletions
+25
-4
person.js
src/person.js
+12
-1
resource.js
src/resource.js
+12
-2
person.js
test/person.js
+1
-1
No files found.
src/person.js
View file @
59fddd1b
...
@@ -2,6 +2,7 @@
...
@@ -2,6 +2,7 @@
var
assert
=
require
(
'assert'
);
var
assert
=
require
(
'assert'
);
var
resource
=
require
(
'./resource'
);
var
resource
=
require
(
'./resource'
);
var
_
=
require
(
'lodash'
);
function
requireEmail
(
options
)
{
function
requireEmail
(
options
)
{
assert
(
options
.
email
,
'An email must be provided'
);
assert
(
options
.
email
,
'An email must be provided'
);
...
@@ -12,7 +13,17 @@ exports.Person = resource.create('Person', {
...
@@ -12,7 +13,17 @@ exports.Person = resource.create('Person', {
path
:
'/people/email/<%= email %>'
,
path
:
'/people/email/<%= email %>'
,
queryKeys
:
'subscribe'
queryKeys
:
'subscribe'
})
})
.
on
(
'preFind'
,
requireEmail
);
.
on
(
'preFind'
,
requireEmail
)
.
include
({
flag
:
function
(
params
,
options
){
return
this
.
client
.
request
(
_
.
extend
({
api
:
this
.
_options
.
api
,
method
:
'post'
,
path
:
_
.
template
(
'/people/<%= id %>/flag'
,
this
),
query
:
params
||
{}
},
options
));
}
});
exports
.
PersonCompany
=
resource
.
create
(
'PersonCompany'
,
{
exports
.
PersonCompany
=
resource
.
create
(
'PersonCompany'
,
{
api
:
'person'
,
api
:
'person'
,
...
...
src/resource.js
View file @
59fddd1b
...
@@ -27,7 +27,12 @@ ClearbitResource.find = Promise.method(function (options) {
...
@@ -27,7 +27,12 @@ ClearbitResource.find = Promise.method(function (options) {
},
options
))
},
options
))
.
bind
(
this
)
.
bind
(
this
)
.
then
(
function
(
data
)
{
.
then
(
function
(
data
)
{
return
new
this
(
data
);
return
new
this
(
_
.
extend
({},
data
,
{
_options
:
this
.
_options
,
client
:
this
.
client
})
);
})
})
.
catch
(
isQueued
,
function
()
{
.
catch
(
isQueued
,
function
()
{
throw
new
this
.
QueuedError
(
this
.
_name
+
' lookup queued'
);
throw
new
this
.
QueuedError
(
this
.
_name
+
' lookup queued'
);
...
@@ -48,7 +53,7 @@ exports.create = function (name, options) {
...
@@ -48,7 +53,7 @@ exports.create = function (name, options) {
var
Resource
=
function
()
{
var
Resource
=
function
()
{
ClearbitResource
.
apply
(
this
,
arguments
);
ClearbitResource
.
apply
(
this
,
arguments
);
};
};
_
.
extend
(
Resource
,
new
EventEmitter
(),
EventEmitter
.
prototype
,
ClearbitResource
,
createErrors
(
name
),
{
_
.
extend
(
Resource
,
new
EventEmitter
(),
EventEmitter
.
prototype
,
ClearbitResource
,
createErrors
(
name
),
{
_name
:
name
,
_name
:
name
,
_options
:
_
.
extend
({},
options
,
{
_options
:
_
.
extend
({},
options
,
{
...
@@ -65,6 +70,11 @@ exports.create = function (name, options) {
...
@@ -65,6 +70,11 @@ exports.create = function (name, options) {
on
:
function
()
{
on
:
function
()
{
Resource
.
on
.
apply
(
Resource
,
arguments
);
Resource
.
on
.
apply
(
Resource
,
arguments
);
return
this
;
return
this
;
},
include
:
function
(
props
)
{
_
.
extend
(
Resource
.
prototype
,
props
);
return
this
;
}
}
});
});
};
};
test/person.js
View file @
59fddd1b
...
@@ -79,7 +79,7 @@ describe('Person', function () {
...
@@ -79,7 +79,7 @@ describe('Person', function () {
.
then
(
function
(
personCompany
)
{
.
then
(
function
(
personCompany
)
{
expect
(
personCompany
)
expect
(
personCompany
)
.
to
.
be
.
an
.
instanceOf
(
PersonCompany
)
.
to
.
be
.
an
.
instanceOf
(
PersonCompany
)
.
and
.
have
.
hav
e
.
keys
(
'person'
,
'company'
)
.
and
.
have
.
includ
e
.
keys
(
'person'
,
'company'
)
.
and
.
have
.
deep
.
property
(
'person.id'
,
alex
.
id
);
.
and
.
have
.
deep
.
property
(
'person.id'
,
alex
.
id
);
});
});
});
});
...
...
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