Skip to content

Commit 2daf3f2

Browse files
committed
add new methods
1 parent b4c2660 commit 2daf3f2

File tree

3 files changed

+78
-5
lines changed

3 files changed

+78
-5
lines changed

CHANGELOG.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
## 0.1.0 - 2018-12-03
2+
- **BREAKING** rename `getAddressInfo()` to `getAddressInfoByContact`
3+
- add new methods: `getAddressInfo()`, `getAddressListInfo()` and `getUserInfo()`
14

2-
## 0.0.1 - 2018-11-07
3-
- wip
5+
## 0.0.4 - 2018-11-15
6+
- initial

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "minter-js-org",
3-
"version": "0.0.4",
3+
"version": "0.1.0",
44
"description": "Communicate with minter.org user database through it API",
55
"main": "src/index.js",
66
"files": [

src/index.js

Lines changed: 72 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ export default function MinterOrg(options) {
2929
};
3030

3131
/**
32+
* POST `register`
3233
* @param {Object} data
3334
* @param {string} data.username
3435
* @param {string} data.password
@@ -77,6 +78,7 @@ export default function MinterOrg(options) {
7778
};
7879

7980
/**
81+
* POST `login`
8082
* @param username
8183
* @param password
8284
* @param {AxiosRequestConfig} [axiosConfig]
@@ -98,6 +100,7 @@ export default function MinterOrg(options) {
98100

99101
/**
100102
* Requires auth
103+
* GET `profile`
101104
* @param {AxiosRequestConfig} [axiosConfig]
102105
* @return {Promise<User>}
103106
*/
@@ -108,6 +111,7 @@ export default function MinterOrg(options) {
108111

109112
/**
110113
* Requires auth
114+
* PUT `profile`
111115
* @param profile
112116
* @param {string} [profile.username]
113117
* @param {string} [profile.name]
@@ -124,6 +128,8 @@ export default function MinterOrg(options) {
124128
/**
125129
* Update profile password and re encrypt stored mnemonics, return updated AddressList
126130
* Requires auth
131+
* GET `addresses/encrypted`
132+
* POST `profile/password'`
127133
* @param {string} oldPasswordToStore
128134
* @param {string} newPasswordToStore
129135
* @param {AxiosRequestConfig} [axiosConfig]
@@ -152,6 +158,7 @@ export default function MinterOrg(options) {
152158

153159
/**
154160
* Requires auth
161+
* POST `profile/avatar`
155162
* @param {Blob|File} avatar - image, max 0.5 MB, max 500x500
156163
* @param {AxiosRequestConfig} [axiosConfig]
157164
* @return {Promise<UserAvatar>}
@@ -167,6 +174,7 @@ export default function MinterOrg(options) {
167174

168175
/**
169176
* Requires auth
177+
* DELETE `profile/avatar`
170178
* @param {AxiosRequestConfig} [axiosConfig]
171179
* @return {Promise<UserAvatar>}
172180
*/
@@ -177,6 +185,7 @@ export default function MinterOrg(options) {
177185
/**
178186
* Get profile address by id without encrypted data
179187
* Requires auth
188+
* GET `addresses/{id}`
180189
* @param {number} id
181190
* @param {AxiosRequestConfig} [axiosConfig]
182191
* @return {Promise<Address>}
@@ -189,6 +198,7 @@ export default function MinterOrg(options) {
189198
/**
190199
* Get profile address by id with encrypted data
191200
* Requires auth
201+
* GET `addresses/{id}/encrypted`
192202
* @param {number} id
193203
* @param {AxiosRequestConfig} [axiosConfig]
194204
* @return {Promise<Address>}
@@ -200,6 +210,7 @@ export default function MinterOrg(options) {
200210

201211
/**
202212
* Requires auth
213+
* POST `addresses`
203214
* @param {Address} address
204215
* @param {AxiosRequestConfig} [axiosConfig]
205216
* @return {Promise}
@@ -210,6 +221,7 @@ export default function MinterOrg(options) {
210221

211222
/**
212223
* Requires auth
224+
* PUT `addresses/{id}`
213225
* @param {number} id
214226
* @param {Address} address
215227
* @param {AxiosRequestConfig} [axiosConfig]
@@ -221,6 +233,7 @@ export default function MinterOrg(options) {
221233

222234
/**
223235
* Requires auth
236+
* DELETE `addresses/{id}`
224237
* @param {number} id
225238
* @param {AxiosRequestConfig} [axiosConfig]
226239
* @return {Promise}
@@ -232,6 +245,7 @@ export default function MinterOrg(options) {
232245
/**
233246
* Get addresses saved in profile without encrypted data
234247
* Requires auth
248+
* GET `addresses`
235249
* @param {AxiosRequestConfig} [axiosConfig]
236250
* @return {Promise<Array<Address>>}
237251
*/
@@ -241,8 +255,10 @@ export default function MinterOrg(options) {
241255
};
242256

243257
/**
258+
*
244259
* Get addresses saved in profile with encrypted data
245260
* Requires auth
261+
* GET `addresses/encrypted`
246262
* @param {AxiosRequestConfig} [axiosConfig]
247263
* @return {Promise<Array<Address>>}
248264
*/
@@ -252,20 +268,68 @@ export default function MinterOrg(options) {
252268
};
253269

254270
/**
271+
* GET `info/by/addresses`
272+
* @param {string} address
273+
* @param {AxiosRequestConfig} [axiosConfig]
274+
* @return {Promise<UserInfo>}
275+
*/
276+
this.getAddressInfo = function getAddressListInfo(address, axiosConfig) {
277+
return instance
278+
.get(`info/by/address/${address}`, {
279+
...axiosConfig,
280+
})
281+
.then((response) => response.data.data);
282+
};
283+
284+
/**
285+
* GET `info/by/addresses`
286+
* @param {Array<string>} addressList
287+
* @param {AxiosRequestConfig} [axiosConfig]
288+
* @return {Promise<Array<UserInfo>>}
289+
*/
290+
this.getAddressListInfo = function getAddressListInfo(addressList, axiosConfig) {
291+
return instance
292+
.get('info/by/addresses?perPage=99999', {
293+
params: {
294+
addresses: addressList,
295+
},
296+
...axiosConfig,
297+
})
298+
.then((response) => response.data.data);
299+
};
300+
301+
/**
302+
* GET `info/address/by/contact`
255303
* @param {Object} params
256304
* @param {string} [params.username]
257305
* @param {string} [params.email]
258306
* @param {AxiosRequestConfig} [axiosConfig]
259-
* @return {Promise<Object>}
307+
* @return {Promise<UserInfo>}
260308
*/
261-
this.getAddressInfo = function getAddressInfo(params, axiosConfig) {
309+
this.getAddressInfoByContact = function getAddressInfoByContact(params, axiosConfig) {
262310
return instance
263311
.get('info/address/by/contact', {
264312
params,
265313
...axiosConfig,
266314
})
267315
.then((response) => response.data.data);
268316
};
317+
318+
/**
319+
* GET `info/by/username/{username}`
320+
* @param {string} username
321+
* @param {AxiosRequestConfig} [axiosConfig]
322+
* @return {Promise<User>}
323+
*/
324+
this.getUserInfo = function getAddressInfoByContact(username, axiosConfig) {
325+
return instance
326+
.get(`info/by/username/${username}`, {
327+
...axiosConfig,
328+
})
329+
.then((response) => response.data.data);
330+
};
331+
332+
269333
}
270334

271335

@@ -298,6 +362,12 @@ function makeFormData(data) {
298362
* @property {Address} mainAddress
299363
*/
300364

365+
/**
366+
* @typedef {Object} UserInfo
367+
* @property {string} address
368+
* @property {User} user
369+
*/
370+
301371
/**
302372
* @typedef {Object} UserAvatar
303373
* @property {string} src

0 commit comments

Comments
 (0)