Skip to content
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

Sb 875 notification service #103

Closed

Conversation

manjudr
Copy link
Contributor

@manjudr manjudr commented Nov 22, 2017

@kochhar @gsbajaj72

This patch is related to notification service. Please review it and let me know if any changes are needed.

@manjudr manjudr requested review from gsbajaj72 and kochhar November 22, 2017 12:19
* If the payload is valid structure then it will returns the payload object else it will return the null
*/

get () {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this method can be removed.

@@ -0,0 +1,80 @@
let Joi = require('joi')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggest renaming this file. this is not a service.

* @return {boolean} If the playload is in valid structure then it will returns the true else false
*/
__validate (payload) {
let validation = Joi.validate(payload, Joi.object().keys({
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this validation configuration (Joi.object().keys(...)) should be an attribute of the class itself.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also, the notification payload is being created in code -- it is not user-submitted. does it need to be validated?

return status
}

__create () {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this method could also be removed.

const _ = require('lodash')
let _defaultDateFormat = dateFormat(new Date(), 'yyyy-mm-dd HH:MM:ss:lo')

class notificationPayload {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

class names should start with an upper-case letter.

class notificationService {
constructor (config) {
this.suportedType = config.suportedType || _supportedType
this.userAccessToken = config.userAccessToken
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should not be managed here, it should be managed at the httpService level. please move out from this class.

});
}
});
let config = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's do some pair-programming on this snippet tomorrow.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

* @param {object} options request object
* @return {object} response or error object
*/
__httpService (options) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

abstract out this http service. use a common one which is also being used by the object rest class.

* @param {string} key User access token
* @return {object}
*/
__getRequestHeader (key) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please move into the common http service container.

payload: payload
}
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

take a look at this gist: I think it does what you need:
https://gist.github.com/kochhar/273438f0afbc3afd7a4f5cebcd10e44e

@kochhar
Copy link
Contributor

kochhar commented Nov 23, 2017

https://gist.github.com/kochhar/7e1c27b88020ab053e7cb2fc56bf28a0

  • snippets from the pair programming this morning

Copy link
Contributor

@kochhar kochhar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good! suggest adding more test cases to the notification service and to the http wrapper.

*
* let target = new NotificationTarget({geo:{ids:['432-5435-6566']}})
*/
constructor({
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggest changing the constructor to take args like geo

rajeevsathish pushed a commit that referenced this pull request Aug 13, 2021
Issue #SB-26013 : feat : observation for teacher
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants