Skip to content

Commit

Permalink
revert last changes & add fileupload type
Browse files Browse the repository at this point in the history
  • Loading branch information
ankitdas13 committed Jun 28, 2023
1 parent b3f2666 commit 821d9e0
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 14 deletions.
15 changes: 8 additions & 7 deletions lib/resources/accounts.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,24 @@ module.exports = function (api) {

return {
create(params, callback) {
let { notes, ...rest } = params
let data = Object.assign(rest, normalizeNotes(notes));

return api.post({
version: 'v2',
url: `${BASE_URL}`,
data: params
data: data
}, callback);
},

edit(accountId, params, callback) {
let { notes, ...rest } = params
let data = Object.assign(rest, normalizeNotes(notes));

return api.patch({
version: 'v2',
url: `${BASE_URL}/${accountId}`,
data: params
data: data
}, callback);
},

Expand All @@ -38,11 +44,6 @@ module.exports = function (api) {
},

uploadAccountDoc(accountId, params, callback) {

if (!accountId) {
return Promise.reject("Account Id is mandatroy");
}

return api.post({
version: 'v2',
url: `${BASE_URL}/${accountId}/documents`,
Expand Down
8 changes: 4 additions & 4 deletions lib/resources/stakeholders.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ module.exports = function (api) {
return {
create(accountId, params, callback) {

let { relationship, ...rest } = params
let { relationship, notes, ...rest } = params

if(params.hasOwnProperty('relationship')){
if(params.relationship.hasOwnProperty('executive')){
Expand All @@ -21,7 +21,7 @@ module.exports = function (api) {
}
}

let data = Object.assign({relationship: relationship}, rest);
let data = Object.assign({relationship: relationship}, normalizeNotes(notes), rest);

return api.post({
version: 'v2',
Expand All @@ -31,7 +31,7 @@ module.exports = function (api) {
},

edit(accountId, stakeholderId, params, callback) {
let { relationship, ...rest } = params
let { notes, relationship, ...rest } = params

if(params.hasOwnProperty('relationship')){
if(params.relationship.hasOwnProperty('executive')){
Expand All @@ -43,7 +43,7 @@ module.exports = function (api) {
}
}

let data = Object.assign({relationship: relationship}, rest);
let data = Object.assign({relationship: relationship}, normalizeNotes(notes), rest);

return api.patch({
version: 'v2',
Expand Down
12 changes: 11 additions & 1 deletion lib/types/accounts.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { IMap, INormalizeError, PartialOptional, RazorpayPaginationOptions } from "./api";
import * as fs from 'fs';

export declare namespace Accounts {
interface RazorpayAccountBaseRequestBody {
Expand Down Expand Up @@ -217,7 +218,16 @@ export declare namespace Accounts {
created_at: number;
}

interface FileCreateParams {}
interface FileCreateParams {
file: {
value: fs.ReadStream;
options: {
filename: string;
contentType: string | null;
};
};
document_type: string;
}

interface RazorpayAccountDocuments {
business_proof_of_identification: [
Expand Down
14 changes: 12 additions & 2 deletions lib/types/stakeholders.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Accounts } from "./accounts";
import { IMap, INormalizeError, PartialOptional, RazorpayPaginationOptions } from "./api";
import * as fs from "fs";

export declare namespace Stakeholders {
interface RazorpayStakeholderBaseRequestBody {
Expand Down Expand Up @@ -47,7 +48,7 @@ export declare namespace Stakeholders {

interface RazorpayStakeholderCreateRequestBody extends RazorpayStakeholderBaseRequestBody { }

interface RazorpayStakeholderUpdateRequestBody extends Omit<RazorpayStakeholderBaseRequestBody, 'email'> { }
interface RazorpayStakeholderUpdateRequestBody extends Partial<Omit<RazorpayStakeholderBaseRequestBody, 'email'>> { }

interface RazorpayStakeholder extends RazorpayStakeholderBaseRequestBody {
/**
Expand Down Expand Up @@ -86,7 +87,16 @@ export declare namespace Stakeholders {
director?: boolean;
}

interface FileCreateParams {}
interface FileCreateParams {
file: {
value: fs.ReadStream;
options: {
filename: string;
contentType: string | null;
};
};
document_type: string;
}

interface RazorpayStakeholderDocuments {
individual_proof_of_address: [
Expand Down

0 comments on commit 821d9e0

Please sign in to comment.