Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
F
fullcontact
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
fullcontact
Commits
17ac5d7a
Commit
17ac5d7a
authored
May 13, 2013
by
3rd-Eden
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[fix] Always default to the "old" rates
[fix] Added missing callback [fix] Allow the API to be rewritten
parent
86554d76
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
54 additions
and
4 deletions
+54
-4
index.js
index.js
+7
-4
fullcontact.test.js
test/fullcontact.test.js
+47
-0
No files found.
index.js
View file @
17ac5d7a
...
...
@@ -69,9 +69,9 @@ FullContact.prototype.request = function req(packet, args) {
,
self
=
this
;
request
(
packet
,
function
requested
(
err
,
res
,
body
)
{
self
.
ratereset
=
+
res
.
headers
[
'X-Rate-Limit-Reset'
];
self
.
ratelimit
=
+
res
.
headers
[
'X-Rate-Limit-Limit'
];
self
.
remaining
=
+
res
.
headers
[
'X-Rate-Limit-Remaining'
];
self
.
ratereset
=
+
res
.
headers
[
'X-Rate-Limit-Reset'
]
||
self
.
ratereste
;
self
.
ratelimit
=
+
res
.
headers
[
'X-Rate-Limit-Limit'
]
||
self
.
ratelimit
;
self
.
remaining
=
+
res
.
headers
[
'X-Rate-Limit-Remaining'
]
||
self
.
remaining
;
if
(
err
)
return
fn
(
err
);
...
...
@@ -96,6 +96,8 @@ FullContact.prototype.request = function req(packet, args) {
return
fn
(
err
);
}
fn
(
undefined
,
body
);
});
return
this
;
...
...
@@ -207,8 +209,9 @@ FullContact.prototype.args = function parser(args) {
*/
FullContact
.
define
=
function
define
(
where
,
name
,
fn
)
{
Object
.
defineProperty
(
where
,
name
,
{
configurable
:
true
,
get
:
function
get
()
{
return
where
[
name
]
=
fn
(
);
return
where
[
name
]
=
fn
.
call
(
this
);
},
set
:
function
set
(
value
)
{
Object
.
defineProperty
(
where
,
name
,
{
...
...
test/fullcontact.test.js
View file @
17ac5d7a
...
...
@@ -10,7 +10,54 @@ describe('FullContact', function () {
//
var
key
=
process
.
env
.
API_KEY
;
//
// Some of the requests take a really long time, so set a really long timeout
//
this
.
timeout
(
20000
);
it
(
'exposes the createClient api which initializes the constructor'
,
function
()
{
var
api
=
FullContact
.
createClient
(
key
);
expect
(
api
).
to
.
be
.
instanceOf
(
FullContact
);
});
it
(
'exposes the Person constructor'
,
function
()
{
expect
(
FullContact
.
Person
).
to
.
be
.
a
(
'function'
);
});
it
(
'exposes the Location constructor'
,
function
()
{
expect
(
FullContact
.
Location
).
to
.
be
.
a
(
'function'
);
});
it
(
'exposes the Email constructor'
,
function
()
{
expect
(
FullContact
.
Email
).
to
.
be
.
a
(
'function'
);
});
it
(
'exposes the Name constructor'
,
function
()
{
expect
(
FullContact
.
Name
).
to
.
be
.
a
(
'function'
);
});
it
(
'sets the x-rate properties on request'
,
function
(
done
)
{
var
fc
=
new
FullContact
(
key
);
[
'remaining'
,
'ratelimit'
,
'ratereset'
].
forEach
(
function
(
prop
)
{
expect
(
fc
[
prop
]).
to
.
equal
(
0
);
});
fc
.
person
.
email
(
'arnout@observe.it'
,
function
normalize
(
err
,
data
)
{
if
(
err
)
return
done
(
err
);
[
'remaining'
,
'ratelimit'
,
'ratereset'
].
forEach
(
function
(
prop
)
{
expect
(
fc
[
prop
]).
to
.
not
.
equal
(
0
);
expect
(
fc
[
prop
]).
to
.
be
.
a
(
'number'
);
});
done
();
});
});
it
(
'decreases the rate remaining on request'
);
it
(
'errors when an invalid API key is given'
);
it
(
'does batch requests'
);
});
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