Hey everyone, I'm about to publish the second vers...
# general
m
Hey everyone, I'm about to publish the second version of an OAuth npm module. I just want to make sure the readme is pretty clear. Would anybody be willing to take a look and provide some feedback if anything seems confusing? Thanks. https://github.com/MichaelEPope/nsrestlet
b
is there a reason you use OAuth and qs when request has support for oauth and uses qs internally anyway?
And i would have like usage of https://rest.netsuite.com/rest/datacenterurls for the url
otherwise I think the documentation is too long. The longer you make it, the less simple it looks. I would say only the things necessary for someone who knows nothing of your module should be in your readme. For example: move things like
Receiving and Returning Data in the Restlet
to a different page.
try combining
Calling the Endpoint
with your first code example
otherwise i like that your code actually has tests, thats a large contrast to a lot of the public suitescript stuff i see
your code also has really nice comments
m
Hey, thanks battk. 🙂 I just use OAuth 1.0a because that's what the samples I started from used. I'll have to test it out and see if request works without it. The other thing is that request is being kinda deprecated (to be precise, they are going to grant auto-commit status to contributors), so I might move off of it. But you're right - I might not need qs or oauth at all =0. I'll do some research 🙂
For https://rest.netsuite.com/rest/datacenterurls, can you show me the format of a full call (with the query string paramaters)
You can definately use it with the setting options being {url: 'https://rest.netsuite.com/rest/datacenterurls...'}, but maybe I can integrate the script id/deployment option into it as well
Your right on the documentation. I'm trying to find a good balance there. I want it to be simple enough experts can go grab it but detailed enough that beginners have no trouble with it. Perhaps I just need to separate some of it into another markdown document. I'll think about it.
And thanks 🙂 Yeah, tried doing that the past few days... testing is a world that is new to me... and I had quite a blast with it actually
Thanks for all your feedback ;D
:D*
b
Copy code
var oauth = {
  consumer_key: "",
  consumer_secret: "",
  token: "",
  token_secret: "",
  realm: account
};
var request = require("request-promise");

request("<https://rest.netsuite.com/rest/datacenterurls>", {
  qs: { account: oauth.account },
  json: true
})
  .then(function(response) {
    return request(response.restDomain + "/app/site/hosting/restlet.nl", {
      qs: { script: "", deploy: "" },
      oauth: oauth,
      json: true,
      method: "POST",
      body: { param0: "" }
    }).then(function(response) {
      console.log(response);
    });
  })
  .catch(function(e) {
    console.error(e);
  });
datacenterurls returns the domains for an account from the account parameter from a GET
m
Ah
So that makes it more viable if there is changes in how netsuite formats their URLs?
b
yes
m
Hmmm
okay
I'll think about doing that
Thanks! 🙂
Hey battk
random question
does that endpoint require OAuth
(aka, will it not work with NLAuth)
b
datacenterurls requires no authentication
m
sweet!
thanks!
Hey battk, just wanted to update you on what i decided to do. For now, I'm going to leave OAuth and qs out of request (again, in prep for the deprecation). For the docs, I'm still thinking about it. I might end up moving some into another helper file. For the data center URLs, I'll definitely include that though 🙂. Thank you for that.
Hope you're having a good morning/evening/something 🙂