Skip to content

Commit ce9a86a

Browse files
authored
!fix: supply accountManagementAuthenticationToken on update requests (#44)
BREAKING CHANGE: alters type and parameters of Update endpoint
1 parent cc94237 commit ce9a86a

File tree

3 files changed

+101
-62
lines changed

3 files changed

+101
-62
lines changed

src/endpoints/user-authentication-password-profile.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ class UserAuthenticationPasswordProfileEndpoint extends CRUDExtend {
6363
userAuthenticationInfoId,
6464
userAuthenticationPasswordProfileId,
6565
body,
66+
accountManagementAuthenticationToken,
6667
token = null
6768
) {
6869
return this.request.send(
@@ -74,7 +75,14 @@ class UserAuthenticationPasswordProfileEndpoint extends CRUDExtend {
7475
)}/${userAuthenticationPasswordProfileId}`,
7576
'PUT',
7677
body.data,
77-
token
78+
token,
79+
this,
80+
true,
81+
'v2',
82+
{
83+
'EP-Account-Management-Authentication-Token':
84+
accountManagementAuthenticationToken
85+
}
7886
)
7987
}
8088

src/types/user-authentication-password-profile.d.ts

Lines changed: 90 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -3,89 +3,119 @@
33
* Description: A User Authentication Password Profile Info resource represents username and password for user authentication info.
44
* DOCS: https://documentation.elasticpath.com/commerce-cloud/docs/api/single-sign-on/user-authentication-password-profiles/index.html
55
*/
6-
import {Identifiable, Resource, ResourceList} from './core'
6+
import { Identifiable, Resource, ResourceList } from './core'
77

88
/**
99
* The User Authentication Password Profile Info object
1010
* DOCS: https://documentation.elasticpath.com/commerce-cloud/docs/api/single-sign-on/user-authentication-password-profiles/index.html#The-User-Authentication-Password-Profile-Object
1111
*/
1212

1313
export interface UserAuthenticationPasswordProfileBody {
14-
type: string
15-
password_profile_id: string
16-
username: string
17-
password : string
14+
type: string
15+
password_profile_id: string
16+
username: string
17+
password: string
1818
}
1919

2020
export interface UserAuthenticationPasswordProfileUpdateBody {
21-
type: string
22-
username: string
23-
password : string
21+
type: string
22+
username: string
23+
password: string
2424
}
2525

26-
export interface UserAuthenticationPasswordProfile extends UserAuthenticationPasswordProfileBody, Identifiable {
27-
meta: {
28-
timestamps: {
29-
created_at: string
30-
updated_at: string
31-
}
26+
export interface UserAuthenticationPasswordProfile
27+
extends UserAuthenticationPasswordProfileBody,
28+
Identifiable {
29+
meta: {
30+
timestamps: {
31+
created_at: string
32+
updated_at: string
3233
}
33-
links: {}
34-
relationships: {}
34+
}
35+
links: {}
36+
relationships: {}
3537
}
3638

37-
export interface UserAuthenticationPasswordProfileResponse extends Resource<UserAuthenticationPasswordProfile> {
38-
links: {
39-
self: string
40-
}
39+
export interface UserAuthenticationPasswordProfileResponse
40+
extends Resource<UserAuthenticationPasswordProfile> {
41+
links: {
42+
self: string
43+
}
4144
}
4245

4346
/**
4447
* User Authentication Password Profile Info Endpoints
4548
* DOCS: https://documentation.elasticpath.com/commerce-cloud/docs/api/single-sign-on/user-authentication-password-profiles/index.html
4649
*/
4750
export interface UserAuthenticationPasswordProfileEndpoint {
48-
/**
49-
* Read All User Authentication Password Info Profile
50-
* DOCS: https://documentation.elasticpath.com/commerce-cloud/docs/api/single-sign-on/user-authentication-password-profiles/get-all-user-authentication-password-profile.html
51-
* @param realmId - The ID for the authentication-realm.
52-
* @param userAuthenticationInfoId - The ID for the user authentication info.
53-
*/
54-
All(realmId: string, userAuthenticationInfoId: string, token?: string, headers?): Promise<ResourceList<UserAuthenticationPasswordProfile>>
55-
/**
56-
* Get a User Authentication Password Info Profile
57-
* DOCS: https://documentation.elasticpath.com/commerce-cloud/docs/api/single-sign-on/user-authentication-password-profiles/get-a-user-authentication-password-profile.html
58-
* @param realmId - The ID for the authentication-realm.
59-
* @param userAuthenticationInfoId - The ID for the user authentication info.
60-
* @param userAuthenticationPasswordProfileId - The ID for the user authentication password profile info.
61-
*/
62-
Get(realmId: string, userAuthenticationInfoId: string, userAuthenticationPasswordProfileId: string, token?: string): Promise<UserAuthenticationPasswordProfileResponse>
51+
/**
52+
* Read All User Authentication Password Info Profile
53+
* DOCS: https://documentation.elasticpath.com/commerce-cloud/docs/api/single-sign-on/user-authentication-password-profiles/get-all-user-authentication-password-profile.html
54+
* @param realmId - The ID for the authentication-realm.
55+
* @param userAuthenticationInfoId - The ID for the user authentication info.
56+
*/
57+
All(
58+
realmId: string,
59+
userAuthenticationInfoId: string,
60+
token?: string,
61+
headers?
62+
): Promise<ResourceList<UserAuthenticationPasswordProfile>>
63+
/**
64+
* Get a User Authentication Password Info Profile
65+
* DOCS: https://documentation.elasticpath.com/commerce-cloud/docs/api/single-sign-on/user-authentication-password-profiles/get-a-user-authentication-password-profile.html
66+
* @param realmId - The ID for the authentication-realm.
67+
* @param userAuthenticationInfoId - The ID for the user authentication info.
68+
* @param userAuthenticationPasswordProfileId - The ID for the user authentication password profile info.
69+
*/
70+
Get(
71+
realmId: string,
72+
userAuthenticationInfoId: string,
73+
userAuthenticationPasswordProfileId: string,
74+
token?: string
75+
): Promise<UserAuthenticationPasswordProfileResponse>
6376

64-
/**
65-
* Create an User Authentication Password Info Profile
66-
* DOCS: https://documentation.elasticpath.com/commerce-cloud/docs/api/single-sign-on/user-authentication-password-profiles/create-a-user-authentication-password-profile.html
67-
* @param realmId - The ID for the authentication-realm.
68-
* @param userAuthenticationInfoId - The ID for the user authentication info.
69-
* @param body - The User Authentication Password Profile Info object
70-
*/
71-
Create(realmId: string, userAuthenticationInfoId: string, body: { data: UserAuthenticationPasswordProfileBody }, token?: string): Promise<UserAuthenticationPasswordProfileResponse>
77+
/**
78+
* Create an User Authentication Password Info Profile
79+
* DOCS: https://documentation.elasticpath.com/commerce-cloud/docs/api/single-sign-on/user-authentication-password-profiles/create-a-user-authentication-password-profile.html
80+
* @param realmId - The ID for the authentication-realm.
81+
* @param userAuthenticationInfoId - The ID for the user authentication info.
82+
* @param body - The User Authentication Password Profile Info object
83+
*/
84+
Create(
85+
realmId: string,
86+
userAuthenticationInfoId: string,
87+
body: { data: UserAuthenticationPasswordProfileBody },
88+
token?: string
89+
): Promise<UserAuthenticationPasswordProfileResponse>
7290

73-
/**
74-
* Update an User Authentication Password Profile Info
75-
* DOCS: https://documentation.elasticpath.com/commerce-cloud/docs/api/single-sign-on/user-authentication-password-profiles/update-a-user-authentication-password-profile.html
76-
* @param realmId - The ID for the authentication-realm.
77-
* @param userAuthenticationInfoId - The ID for the user authentication info.
78-
* @param userAuthenticationPasswordProfileId - The ID for the user authentication password profile info.
79-
* @param body - The User Authentication Password Profile Info object
80-
*/
81-
Update(realmId: string, userAuthenticationInfoId: string,userAuthenticationPasswordProfileId: string, body: { data: UserAuthenticationPasswordProfileUpdateBody }, token?: string): Promise<UserAuthenticationPasswordProfileResponse>
91+
/**
92+
* Update an User Authentication Password Profile Info
93+
* DOCS: https://documentation.elasticpath.com/commerce-cloud/docs/api/single-sign-on/user-authentication-password-profiles/update-a-user-authentication-password-profile.html
94+
* @param realmId - The ID for the authentication-realm.
95+
* @param userAuthenticationInfoId - The ID for the user authentication info.
96+
* @param userAuthenticationPasswordProfileId - The ID for the user authentication password profile info.
97+
* @param body - The User Authentication Password Profile Info object
98+
*/
99+
Update(
100+
realmId: string,
101+
userAuthenticationInfoId: string,
102+
userAuthenticationPasswordProfileId: string,
103+
body: { data: UserAuthenticationPasswordProfileUpdateBody },
104+
accountManagementAuthenticationToken: string,
105+
token?: string
106+
): Promise<UserAuthenticationPasswordProfileResponse>
82107

83-
/**
84-
* Delete an User Authentication Password Profile Info
85-
* DOCS: https://documentation.elasticpath.com/commerce-cloud/docs/api/single-sign-on/password-profiles/delete-a-user-authentication-password-profile.html
86-
* @param realmId - The ID for the authentication-realm containing the Password profiles.
87-
* @param userAuthenticationInfoId - The ID for the user authentication info.
88-
* @param userAuthenticationPasswordProfileId - The ID for the user authentication password profile info.
89-
*/
90-
Delete(realmId: string, userAuthenticationInfoId: string, userAuthenticationPasswordProfileId: string, token?: string)
108+
/**
109+
* Delete an User Authentication Password Profile Info
110+
* DOCS: https://documentation.elasticpath.com/commerce-cloud/docs/api/single-sign-on/password-profiles/delete-a-user-authentication-password-profile.html
111+
* @param realmId - The ID for the authentication-realm containing the Password profiles.
112+
* @param userAuthenticationInfoId - The ID for the user authentication info.
113+
* @param userAuthenticationPasswordProfileId - The ID for the user authentication password profile info.
114+
*/
115+
Delete(
116+
realmId: string,
117+
userAuthenticationInfoId: string,
118+
userAuthenticationPasswordProfileId: string,
119+
token?: string
120+
)
91121
}

test/unit/user-authentication-password-profile.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,8 @@ describe('User Authentication Password Profile Info', () => {
8888
userAuthenticationPasswordProfileId,
8989
{
9090
data: body
91-
}
91+
},
92+
'dummy-token'
9293
).then(res => {
9394
assert.isObject(res)
9495
})

0 commit comments

Comments
 (0)