Git Product home page Git Product logo

sparky's People

Contributors

darrenparkinson avatar levensailor avatar nmarus avatar objectisadvantag avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sparky's Issues

Markdown support

It would be great to have the ability to use the new markdown message support functionality when sending messages.

need a getMessagesAfter function

Spark APIs do not provide a way to get/list messages for a space after a certain date, only before...
that isnt very helpful in many situations. The /events API is only available to compliance officer roles, which is not the vast majority of users. We need a way, with a standard user token (from oAuth) to list messages from a certain date till now... Ideally sparky would fill that void with a getMessagesAfter(date, roomId, pagesize) could go back page-by-page till it finds the the threshold message/time.

messagesGet validator issue

I think i have an issue with isMessageSearch validator method
Validator.isMessageSearch = searchObj => (typeof messageSearch === 'object' && searchObj.roomId);

This method test typeof "messageSearch" variable instead of "searchObj" variable.

Write like that, it works better.
Validator.isMessageSearch = searchObj => (typeof searchObj=== 'object' && searchObj.roomId);

returned error from membershipAdd is not object

Example of working error:

spark.personGet('Y2lzY29zcGFyaMWU4LWI1MzQtZDM3YjY1MzYzNjhl]', '1234')
  .then(result => {
    console.log('Good:', result);
  })
  .catch(error => {
    console.log(JSON.stringify(error, null, 2));  // ​​​​​{​​​​​​​  "code": 404,​​​​​​​​​​  "type": "ERR_STATUS"​​​​​ ​​​​​}​​​​​
    console.log(typeof error); // object
    console.log('Array? ', Array.isArray(error)); // false
    console.log(error);  { [Error: recieved error 404 for a GET request to https://api.ciscospark.com/v1/people/Y2lzY29zcGFyaMWU4LWI1MzQtZDM3YjY1MzYzNjhl] code: 404, type: 'ERR_STATUS' 
   })

membershipAdd result error not an object

spark.membershipAdd(spaceId, '1234')
  .then(result => {
    console.log('Good:', result);
  })
  .catch(error => {
    console.log(JSON.stringify(error, null, 2));  // {}
    console.log(typeof error); // object
    console.log(Array.isArray(error));  //false
    console.log(error); // [Error: invalid arguments]​​​​​
   })

Sorry that I did not have the time to dig further.

remvoe console.error from spark request

The library should not log errors, itself. This should be the responsibility the surrounding code. In fact, it might not be an error and is correctly handled.

TODO: There may be other places in the code this occurs too.

Line 315 in spark.js -> console.error(err)


        const processError = (_res, _opts) => {
          const err = new Error(`recieved error ${_res.statusCode} for a ${_opts.method.toUpperCase()} request to ${_opts.url}`);
          // attach statusCode to error.code
          err.code = _res.statusCode;
          // attach err.type
          if (parseInt(_res.statusCode, 10) === 400) {
            err.type = 'ERR_REQUEST';
          } else if (parseInt(_res.statusCode, 10) === 401) {
            err.type = 'ERR_UNAUTHORIZED';
          } else if (parseInt(_res.statusCode, 10) === 403) {
            err.type = 'ERR_FORBIDDEN';
          } else if (parseInt(_res.statusCode, 10) === 409) {
            err.type = 'ERR_CONFLICT';
          } else if (parseInt(_res.statusCode, 10) === 415) {
            err.type = 'ERR_MEDIA';
          } else if (parseInt(_res.statusCode, 10) === 429) {
            err.type = 'ERR_RATELIMIT';
          } else {
            err.type = 'ERR_STATUS';
          }
          console.error(err);
          return when.reject(err);
};

Error Management

When the Cisco Spark API returns an error such as a 409, I am having difficulties handling it from my client application code.

Sparky returns an err containing only a message, which gives no other option but to do string comparison, or creating a regexp to matching a 409 status error.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.