-
Notifications
You must be signed in to change notification settings - Fork 75
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Deploy full scale oauth functionality #97
Conversation
Bug Fix: add includeSelector to getUserdetails api (pajaydev#89)
Added findItemsineBayStores support (pajaydev#94)
Fix some resource lookups
There seems to be a bug I missed on |
Additional Changelog
|
I added a bunch more fixes and added tests for the oauth functionality. Everything should work now. Though during development I encountered a few bugs that were left in the original branch. There seems to be a few synchronicity issues. Since the previous logic was using this assigns So you'd assume that this'd result in This one should be fixed now, but I think there might still be some logic errors here and there. |
@TotallyNotChase I appreciate your efforts to bring these changes. I will review this PR as soon as possible. I can see that you have included oauth changes and clean up task in same PR, Shall we separate that out ?. |
@@ -50,7 +50,7 @@ ebay.findCompletedItems({ | |||
// // This call searches for items on eBay using specific eBay product values. | |||
// https://developer.ebay.com/DevZone/finding/CallRef/findItemsByProduct.html#findItemsByProduct | |||
ebay.findItemsByProduct({ | |||
productId: 53039031, | |||
productID: 53039031, | |||
entriesPerPage: 2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@TotallyNotChase I don't think you have to change variable names as part of this PR, since this library is out and many people are using it. It would be difficult until or unless we have mention these changes as breaking changes and release a major version.
}); | ||
|
||
// Getting access token and calling getItem method. | ||
ebay.getAccessToken() | ||
ebay.getApplicationToken() | ||
.then((data) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shall we keep name as getAccessToken
since we are using this convention from the start ?.
@pajaydev ahh that's a fair point. My bad, I didn't realize that. Would you like me to revert all the clean up changes (migration from I agree that it makes much more sense to release a big cleanup + enhancement in a major release. Sorry for not realizing that. |
@TotallyNotChase Yes, I appreciate if you can separate the enhancement (keep only Oauth changes) and the cleanup in two separate PRs, kindly keep all the variable name, this changes and function name changes in cleanup PR so that I can verify those changes. My point is, it's better not to change variable names or function names affecting users, until or unless its much needed. |
@pajaydev alright! I'll separate them out and make another clean PR :) |
Goal of the pull request:
Description
Added full oauth functionality to the API. Now supports both app access tokens and user access tokens for all kinds of API calls. Closes #93
P.S - Long changelog, I hope you have some free time to read through all this :)
Changelog
Updated app version to 2.8.7
Updated dependency versions
Refine file structure of
utils
(previouslycommon-utils
).buildURL.js
has also been moved inside.Here's a list of functions that the
utils
include, corresponding to their parent files-general.js
base64Encode
getSiteId
upperCase
isString
isEmptyObj
buildURL.js
buildSearchURL
buildShoppingUrl
URLQuery.js
encodeURLQuery
urlParseObj
constructAdditionalParams
Changed structure of the
ebay
object. Most of the fields that were previously stored underthis.options
are now stored underthis.
, this is done because the functions that rely onoptions
are now easier to work with and should now follow a single responsibility principle, as well has avoid some confusion, hopefully.Most of the function calls will now require only
this
as a parameter, unless that function explicitly needs custom configurations or options provided by the user, in that case theconfig
(similar to the originaloption
) should be usedThe properties held withing
this
are-environment
baseUrl
baseSvcUrl
oauthEndpoint
credentials
clientID
clientSecret
headers
globalID
siteID
To elaborate on the previous statement about single responsiblity principle. Most of the functions called by the user will now use their own
options
parameter asconfig
. So instead of feeding inthis.options
in each and every request (even thoughthis.options
might have some unwanted params), we'll only have to feed in the options the user gave us.For this reason, options like
limit
are no longer being accepted in theebay
constructor, these should be supplied to their respective function calls. Headers should be global though and that feature is still left intact, headers are now stored inthis.headers
.As for any huge paradigm shifts, there shouldn't be any. As mentioned before, most of the function calls that we were passing
this.options
to were only expecting a few of the fields in it, fields that are now easily found inthis.
The
ebay
constructor no longer uses thebody
parameter. Those are bound to their respective token getter functions.Rename
getItem
togetItemById
and make it return apromise
just like all the other functions.All the function calls (at this stage) that use an access token will now use
this.appAccessToken
. We've yet to implement any functions that useuserAccessToken
though.All the variables in the library that have a name that ends with
Id
have been changed so that all of them end inID
(both capitalized). This is for consistency, but this comes with a set of problems.Ebay's own API is very inconsistent in this topic, some fields use
ID
, while others useId
, to counter this, the fields that useId
(specifically all the functions that useurlParseObj
andconstructAdditionalParams
will be taken care of using a regex replace. See here for clarity.Make the error messages consistent and remove custom styling. I believe it'd be helpful to make our custom exception classes rather than printing the exception flags such as (
INVALID_REQUEST_PARAMS
), let me know how you'd want to tackle this.makeRequest
now takes in an additional parameter -customOptions
, this is one of the few functions that require not justthis
, but also a custom config as parameters.this
will still be passed in asself
, which should be less confusing that usingthis.options
as self and also a bit more concise. Theself
param is currently only used to extract the headers (this.headers
), wherascustomOptions
should hold thecontentType
and thedata
(in case of a post request).Added
postRequest
, this is used only for POST requests and currently only by the access token functions.I suggest we get rid of
makeRequest
and only keeppostRequest
andgetRequest
, with proper tweaks ofcourse. I believe this to be more concise.