danielbonifacio-sdk
Advanced tools
Comparing version 2.2.0 to 2.3.0
@@ -1,2 +0,3 @@ | ||
import Service from "../Service"; | ||
import { User } from '../@types'; | ||
import Service from '../Service'; | ||
declare class UserService extends Service { | ||
@@ -102,3 +103,156 @@ static getAllEditors(): Promise<{ | ||
}>; | ||
static getAllUsers(): Promise<{ | ||
id: number; | ||
name: string; | ||
email: string; | ||
avatarUrls: { | ||
default: string; | ||
small: string; | ||
medium: string; | ||
large: string; | ||
}; | ||
role: "EDITOR" | "ASSISTANT" | "MANAGER"; | ||
active: boolean; | ||
createdAt: string; | ||
canBeActivated: boolean; | ||
canBeDeactivated: boolean; | ||
canSensitiveDataBeUpdated: boolean; | ||
}[]>; | ||
static updateExistingUser(userId: number, userData: User.Input): Promise<{ | ||
id: number; | ||
name: string; | ||
email: string; | ||
avatarUrls: { | ||
default: string; | ||
small: string; | ||
medium: string; | ||
large: string; | ||
}; | ||
bio: string; | ||
role: "EDITOR" | "ASSISTANT" | "MANAGER"; | ||
birthdate: string; | ||
phone: string; | ||
taxpayerId: string; | ||
pricePerWord: number; | ||
active: boolean; | ||
createdAt: string; | ||
bankAccount: { | ||
bankCode: string; | ||
agency: string; | ||
number: string; | ||
digit: string; | ||
type: "SAVING" | "CHECKING"; | ||
}; | ||
location: { | ||
country: string; | ||
state: string; | ||
city: string; | ||
}; | ||
skills: { | ||
name: string; | ||
percentage: number; | ||
}[] | null; | ||
metrics: { | ||
weeklyEarnings: number; | ||
monthlyEarnings: number; | ||
lifetimeEarnings: number; | ||
weeklyWords: number; | ||
monthlyWords: number; | ||
lifetimeWords: number; | ||
}; | ||
updatedAt: string; | ||
updatedBy: { | ||
id: number; | ||
name: string; | ||
avatarUrls: { | ||
default: string; | ||
small: string; | ||
medium: string; | ||
large: string; | ||
}; | ||
}; | ||
createdBy: { | ||
id: number; | ||
name: string; | ||
avatarUrls: { | ||
default: string; | ||
small: string; | ||
medium: string; | ||
large: string; | ||
}; | ||
}; | ||
canBeActivated: boolean; | ||
canBeDeactivated: boolean; | ||
canSensitiveDataBeUpdated: boolean; | ||
}>; | ||
static insertNewUser(userData: User.Input): Promise<{ | ||
id: number; | ||
name: string; | ||
email: string; | ||
avatarUrls: { | ||
default: string; | ||
small: string; | ||
medium: string; | ||
large: string; | ||
}; | ||
bio: string; | ||
role: "EDITOR" | "ASSISTANT" | "MANAGER"; | ||
birthdate: string; | ||
phone: string; | ||
taxpayerId: string; | ||
pricePerWord: number; | ||
active: boolean; | ||
createdAt: string; | ||
bankAccount: { | ||
bankCode: string; | ||
agency: string; | ||
number: string; | ||
digit: string; | ||
type: "SAVING" | "CHECKING"; | ||
}; | ||
location: { | ||
country: string; | ||
state: string; | ||
city: string; | ||
}; | ||
skills: { | ||
name: string; | ||
percentage: number; | ||
}[] | null; | ||
metrics: { | ||
weeklyEarnings: number; | ||
monthlyEarnings: number; | ||
lifetimeEarnings: number; | ||
weeklyWords: number; | ||
monthlyWords: number; | ||
lifetimeWords: number; | ||
}; | ||
updatedAt: string; | ||
updatedBy: { | ||
id: number; | ||
name: string; | ||
avatarUrls: { | ||
default: string; | ||
small: string; | ||
medium: string; | ||
large: string; | ||
}; | ||
}; | ||
createdBy: { | ||
id: number; | ||
name: string; | ||
avatarUrls: { | ||
default: string; | ||
small: string; | ||
medium: string; | ||
large: string; | ||
}; | ||
}; | ||
canBeActivated: boolean; | ||
canBeDeactivated: boolean; | ||
canSensitiveDataBeUpdated: boolean; | ||
}>; | ||
static activateExistingUser(userId: number): Promise<{}>; | ||
static deactivateExistingUser(userId: number): Promise<{}>; | ||
} | ||
export default UserService; |
@@ -28,18 +28,27 @@ "use strict"; | ||
UserService.getAllEditors = function () { | ||
return this.Http | ||
.get('/users/editors') | ||
.then(this.getData); | ||
return this.Http.get('/users/editors').then(this.getData); | ||
}; | ||
UserService.getExistingEditor = function (editorId) { | ||
return this.Http | ||
.get("/users/editors/" + editorId) | ||
.then(this.getData); | ||
return this.Http.get("/users/editors/" + editorId).then(this.getData); | ||
}; | ||
UserService.getDetailedUser = function (userId) { | ||
return this.Http | ||
.get("/users/" + userId) | ||
.then(this.getData); | ||
return this.Http.get("/users/" + userId).then(this.getData); | ||
}; | ||
UserService.getAllUsers = function () { | ||
return this.Http.get('/users').then(this.getData); | ||
}; | ||
UserService.updateExistingUser = function (userId, userData) { | ||
return this.Http.put("/users/" + userId, userData).then(this.getData); | ||
}; | ||
UserService.insertNewUser = function (userData) { | ||
return this.Http.post('/users', userData).then(this.getData); | ||
}; | ||
UserService.activateExistingUser = function (userId) { | ||
return this.Http.put("/users/" + userId + "/activation").then(this.getData); | ||
}; | ||
UserService.deactivateExistingUser = function (userId) { | ||
return this.Http.delete("/users/" + userId + "/activation").then(this.getData); | ||
}; | ||
return UserService; | ||
}(Service_1.default)); | ||
exports.default = UserService; |
{ | ||
"name": "danielbonifacio-sdk", | ||
"version": "2.2.0", | ||
"version": "2.3.0", | ||
"main": "dist/index.js", | ||
@@ -5,0 +5,0 @@ "types": "dist/index.d.ts", |
@@ -1,24 +0,60 @@ | ||
import { User } from "../@types"; | ||
import Service from "../Service"; | ||
// User.service.ts | ||
import { User } from '../@types'; | ||
import Service from '../Service'; | ||
class UserService extends Service { | ||
static getAllEditors () { | ||
return this.Http | ||
.get<User.EditorSummary[]>('/users/editors') | ||
.then(this.getData) | ||
static getAllEditors() { | ||
return this.Http.get<User.EditorSummary[]>( | ||
'/users/editors' | ||
).then(this.getData); | ||
} | ||
static getExistingEditor (editorId: number) { | ||
return this.Http | ||
.get<User.EditorDetailed>(`/users/editors/${editorId}`) | ||
.then(this.getData) | ||
static getExistingEditor(editorId: number) { | ||
return this.Http.get<User.EditorDetailed>( | ||
`/users/editors/${editorId}` | ||
).then(this.getData); | ||
} | ||
static getDetailedUser (userId: number) { | ||
return this.Http | ||
.get<User.Detailed>(`/users/${userId}`) | ||
.then(this.getData) | ||
static getDetailedUser(userId: number) { | ||
return this.Http.get<User.Detailed>( | ||
`/users/${userId}` | ||
).then(this.getData); | ||
} | ||
static getAllUsers() { | ||
return this.Http.get<User.Summary[]>('/users').then( | ||
this.getData | ||
); | ||
} | ||
static updateExistingUser( | ||
userId: number, | ||
userData: User.Input | ||
) { | ||
return this.Http.put<User.Detailed>( | ||
`/users/${userId}`, | ||
userData | ||
).then(this.getData); | ||
} | ||
static insertNewUser(userData: User.Input) { | ||
return this.Http.post<User.Detailed>( | ||
'/users', | ||
userData | ||
).then(this.getData); | ||
} | ||
static activateExistingUser(userId: number) { | ||
return this.Http.put<{}>( | ||
`/users/${userId}/activation` | ||
).then(this.getData); | ||
} | ||
static deactivateExistingUser(userId: number) { | ||
return this.Http.delete<{}>( | ||
`/users/${userId}/activation` | ||
).then(this.getData); | ||
} | ||
} | ||
export default UserService | ||
export default UserService; |
150369
4324