Skip to content
This repository was archived by the owner on Jul 24, 2024. It is now read-only.

Commit 332de22

Browse files
[MT-14128] update account auth setttings api (#786)
* [MT-14128] update account auth setttings api * [MT-14128] update account auth setttings api * [MT-14128] update account auth setttings api * [MT-14128] update account auth setttings api
1 parent 21428ba commit 332de22

File tree

3 files changed

+77
-0
lines changed

3 files changed

+77
-0
lines changed

src/endpoints/account-authentication-settings.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,13 @@ class AccountAuthenticationSettingsEndpoint {
99
Get() {
1010
return this.request.send(`${this.endpoint}`, 'GET', undefined)
1111
}
12+
13+
Update(body) {
14+
return this.request.send(this.endpoint, 'PUT', {
15+
type: 'account_authentication_settings',
16+
...body
17+
})
18+
}
1219
}
1320

1421
export default AccountAuthenticationSettingsEndpoint

src/types/account-authentication-settings.d.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ import { Resource, RelationshipToOne, Identifiable } from './core'
1212
*/
1313
export interface AccountAuthenticationSettingsBase {
1414
type: string
15+
enable_self_signup: boolean,
16+
auto_create_account_for_account_members: boolean,
17+
account_member_self_management: string
1518
meta: object
1619
relationships: {
1720
'authentication_realm': RelationshipToOne<'authentication_realm'>
@@ -29,4 +32,6 @@ export interface AccountAuthenticationSettingsEndpoint {
2932
* DOCS: https://documentation.elasticpath.com/commerce-cloud/docs/api/advanced/settings/account-authentication-settings/get-account-authentication-settings.html
3033
*/
3134
Get(): Promise<Resource<AccountAuthenticationSettings>>
35+
36+
Update(body: Partial<AccountAuthenticationSettings>): Promise<Resource<AccountAuthenticationSettings>>
3237
}

test/unit/account-authentication-settings.ts

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,69 @@ describe('Moltin Account Authentication Settings', () => {
1818
assert.isObject(res)
1919
})
2020
})
21+
22+
it('should update account authentication settings', () => {
23+
nock(apiUrl, {
24+
reqheaders: {
25+
Authorization: 'Bearer a550d8cbd4a4627013452359ab69694cd446615a'
26+
}
27+
})
28+
.put('/settings/account-authentication', {
29+
data: {
30+
type: 'account_authentication_settings',
31+
enable_self_signup: true,
32+
auto_create_account_for_account_members: true,
33+
account_member_self_management: 'update_only'
34+
}
35+
})
36+
.reply(200, {
37+
data: {
38+
id: '775c934a-b54b-4846-9a7e-21844f4700a4',
39+
type: 'account_authentication_settings',
40+
enable_self_signup: true,
41+
auto_create_account_for_account_members: true,
42+
account_member_self_management: 'update_only',
43+
relationships: {
44+
authentication_realm: {
45+
data: {
46+
id: "775c934a-b54b-4846-9a7e-21844f4700a5",
47+
type: "authentication_realm"
48+
}
49+
}
50+
},
51+
meta: {
52+
client_id: "account-management"
53+
}
54+
}
55+
})
56+
const body = {
57+
type: 'account_authentication_settings',
58+
enable_self_signup: true,
59+
auto_create_account_for_account_members: true,
60+
account_member_self_management: 'update_only'
61+
}
62+
63+
return Moltin.AccountAuthenticationSettings.Update(body).then(response => {
64+
assert.deepEqual(response, {
65+
data: {
66+
id: '775c934a-b54b-4846-9a7e-21844f4700a4',
67+
type: 'account_authentication_settings',
68+
enable_self_signup: true,
69+
auto_create_account_for_account_members: true,
70+
account_member_self_management: 'update_only',
71+
relationships: {
72+
authentication_realm: {
73+
data: {
74+
id: "775c934a-b54b-4846-9a7e-21844f4700a5",
75+
type: "authentication_realm"
76+
}
77+
}
78+
},
79+
meta: {
80+
client_id: "account-management"
81+
}
82+
}
83+
})
84+
})
85+
})
2186
})

0 commit comments

Comments
 (0)