Skip to content

Commit

Permalink
[MT-9310] list unassigned account members (#523)
Browse files Browse the repository at this point in the history
* [MT-9310]list unassigned members

* [MT-9310]lint fix

* [MT-9310]
  • Loading branch information
mahsaelasticpath committed Aug 25, 2021
1 parent 0405f0d commit 8bb4914
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 2 deletions.
20 changes: 20 additions & 0 deletions src/endpoints/account-memberships.js
Expand Up @@ -30,6 +30,26 @@ class AccountMembershipsEndpoint extends BaseExtend {
return this.call
}

UnassignedAccountMembers(accountId, token = null) {
const { limit, offset } = this

this.call = this.request.send(
buildURL(
`accounts/${accountId}/account-memberships/unassigned-account-members`,
{
limit,
offset
}
),
'GET',
undefined,
token,
this
)

return this.call
}

Get(accountId, accountMembershipId, token = null) {
return this.request.send(
`accounts/${accountId}/account-memberships/${accountMembershipId}`,
Expand Down
13 changes: 11 additions & 2 deletions src/types/account-memberships.d.ts
Expand Up @@ -4,10 +4,10 @@
import {
CrudQueryableResource,
Identifiable,
Resource,
Resource, ResourceList,
ResourcePage,
} from "./core";
import { AccountMemberBase } from "./account-members";
import {AccountMember, AccountMemberBase} from "./account-members";

/**
* The Account Membership object Interface
Expand Down Expand Up @@ -80,6 +80,15 @@ export interface AccountMembershipsEndpoint
token?: string
): Promise<AccountMembershipsResponse>

/**
* Get Unassigned Account Members for an account
* @param accountId - The ID for the account
*/
UnassignedAccountMembers(
accountId: string,
token?: string
): Promise<ResourceList<AccountMember>>

/**
* Create an Account Membership
* @param accountId - The ID for the requested account,
Expand Down
15 changes: 15 additions & 0 deletions test/unit/account-memberships.ts
Expand Up @@ -46,6 +46,21 @@ describe('Moltin Account Memberships', () => {
})
})

it('Get all Unassigned Account Members for an account', () => {
nock(apiUrl, {})
.post('/oauth/access_token')
.reply(200, {
access_token: 'a550d8cbd4a4627013452359ab69694cd446615a'
})
.get(/accounts\/.*\/account-memberships\/unassigned-account-members/)
.reply(200, {})
const accountId = '64f35045-2a76-4bcf-b6ba-02bb12090d38'

return Moltin.AccountMemberships.UnassignedAccountMembers(accountId).then(res => {
assert.isObject(res)
})
})

it('Get all Account Memberships for an account using limit', () => {
nock(apiUrl, {})
.post('/oauth/access_token')
Expand Down

0 comments on commit 8bb4914

Please sign in to comment.