Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

strava-v3

Package Overview
Dependencies
Maintainers
1
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

strava-v3 - npm Package Compare versions

Comparing version 1.4.0 to 1.5.0

lib/uploads.js

7

index.js

@@ -17,2 +17,3 @@ /**

, streams = require('./lib/streams')
, uploads = require('./lib/uploads')
;

@@ -42,2 +43,3 @@

strava.streams = streams;
strava.uploads = uploads;

@@ -47,6 +49,1 @@ //and export

/* TODO api functionality
/v3/uploads
*/

@@ -42,5 +42,5 @@ /**

var endpoint = 'athlete'
, body = util.getRequestBodyObj(_updateAllowedProps,args);
, form = util.getRequestBodyObj(_updateAllowedProps,args);
args.body = body;
args.form = form;
util.putEndpoint(endpoint,args,done);

@@ -47,0 +47,0 @@ };

@@ -6,4 +6,7 @@ /**

var request = require('request')
, querystring = require('querystring');
, querystring = require('querystring')
, fs = require('fs');
//request.debug = true
var util = {};

@@ -59,3 +62,3 @@

//stringify the body object for passage
var qs = querystring.stringify(args.body);console.log(qs);
var qs = querystring.stringify(args.body);

@@ -73,2 +76,6 @@ var url = this.endpointBase + endpoint

//add form data if present
if(args.form)
options.form = args.form;
this._requestHelper(options,done);

@@ -107,2 +114,10 @@ };

//add form data if present
if(args.form)
options.form = args.form;
//add multipart data if present
if(args.multipart)
options.multipart = args.multipart;
this._requestHelper(options,done);

@@ -144,3 +159,39 @@ };

//===== postUpload =====
util.postUpload = function(args,done) {
//all strava requests require an access_token, so let's do that check here
if (typeof args.access_token === 'undefined' && !this.config.access_token) {
return done({'msg': 'you must include an access_token'});
}
//add in default access_token, if not overwritten by args
else if (typeof args.access_token === 'undefined') {
args.access_token = this.config.access_token;
}
var url = this.endpointBase + 'uploads'
, options = {
url: url
, method: 'POST'
, json: true
, headers: {
Authorization: 'Bearer ' + args.access_token
}
};
var req = request.post(options, function(err, httpResponse, payload) {
done(err, payload);
});
var form = req.form();
//append the rest of the formData values
for(var key in args.formData) {
form.append(key, args.formData[key]);
}
form.append('file', fs.createReadStream(args.file));
};
//===== get pagination query string =====

@@ -147,0 +198,0 @@ util.getPaginationQS = function(args) {

{
"name": "strava-v3",
"version": "1.4.0",
"version": "1.5.0",
"description": "Simple wrapper for strava v3 api",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -7,3 +7,3 @@

###Status
Currently supporting API functionality for the following:
Supports API functionality for all API endpoints from `oauth` to `uploads`:

@@ -19,2 +19,3 @@ * `oauth`

* `streams`
* `uploads`

@@ -37,3 +38,3 @@ ## Installation

```js
strava = require('strava-v3');
var strava = require('strava-v3');
strava.athlete.get({},function(err,payload) {

@@ -63,3 +64,3 @@ if(!err) {

```js
strava = require('strava-v3')
var strava = require('strava-v3')
strava.<api endpoint>.<api endpoint option>(args,callback)

@@ -71,3 +72,3 @@ ```

```js
strava = require('strava-v3');
var strava = require('strava-v3');
strava.athletes.get({id:12345},function(err,payload) {

@@ -87,3 +88,3 @@ //do something with your payload

```js
strava = require('strava-v3');
var strava = require('strava-v3');
strava.athlete.get({'access_token':'abcde'},function(err,payload) {

@@ -101,3 +102,3 @@ //do something with your payload

```js
strava = require('strava-v3');
var strava = require('strava-v3');
strava.athlete.getFollowers({

@@ -111,2 +112,21 @@ 'page':1

###Uploading files
To upload a file you'll have to pass in the `data_type` as specified in Strava's API reference as well as a string `file` designating the `<filepath>/<filename>`. If you want to get updates on the status of your upload pass in `statusCallback` along with the rest of your `args` - the wrapper will check on the upload once a second until complete.
Example usage:
```js
var strava = require('strava-v3');
strava.uploads.post({
'data_type':'gpx'
, 'file': 'data/your_file.gpx'
, 'name': 'Epic times'
, 'statusCallback': function(err,payload) {
//do something with your payload
}
},function(err,payload) {
//do something with your payload
});
```
###Supported API Endpoints

@@ -171,1 +191,4 @@

Uploads:
* `strava.uploads.post(args,done)`

@@ -68,3 +68,2 @@ /**

, name:"should've been running"
, access_token: readWriteAccessToken
};

@@ -71,0 +70,0 @@

@@ -5,4 +5,2 @@

var athlete_id = "2402496";
describe('athlete', function(){

@@ -107,9 +105,10 @@

it('should update the weight of the current athlete', function(done) {
it('should update the city of the current athlete', function(done) {
strava.athlete.update({weight:68.2,city:"Portland"},function(err,payload){
strava.athlete.update({city:"Seattle"},function(err,payload){
if(!err) {
//console.log(payload);
console.log(payload);
(payload.resource_state).should.be.exactly(3);
(payload.city).should.be.exactly("Seattle");
}

@@ -116,0 +115,0 @@ else {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc