Skip to content

Commit 61cc5b2

Browse files
Merge pull request #23 from latitudesh/feat/pd-4343/get-storage-plans
[PD-4343] feat: implemented storage plans
2 parents 1949c9b + d9501fa commit 61cc5b2

File tree

3 files changed

+38
-0
lines changed

3 files changed

+38
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ latitudeShApi.Profile.get().then((response) => {
4848
- `Plans.get`. Params: `(planId, searchParams)`. [Reference](https://docs.latitude.sh/reference/get-plan)
4949
- `Plans.list`. Params: `(searchParams)`. [Reference](https://docs.latitude.sh/reference/get-plans)
5050
- `Plans.operatingSystems`. Params: `(searchParams)`. [Reference](https://docs.latitude.sh/reference/get-plans-operating-system)
51+
- `Plans.storage`. Params: `(searchParams)`. [Reference](https://docs.latitude.sh/reference/get-storage-plans)
5152

5253
- `Projects.Members.list`. Params: `(projectIdOrSlug, searchParams)`. [Reference](https://docs.latitude.sh/reference/get-team-members)
5354

lib/resources/plans/index.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,15 @@ class Plans {
4242
searchParams
4343
);
4444
}
45+
46+
storage(searchParams = '') {
47+
searchParams = new URLSearchParams(searchParams).toString();
48+
return this.LatitudeSh._get(
49+
'/plans/storage',
50+
this.LatitudeSh._headers,
51+
searchParams
52+
);
53+
}
4554
}
4655

4756
module.exports = LatitudeSh => {

lib/resources/plans/test.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,3 +109,31 @@ describe('get operating systems', () => {
109109
});
110110
});
111111
});
112+
113+
describe('get storage', () => {
114+
it('call get request with right params', async () => {
115+
const path = '/plans/storage';
116+
LatitudeSh._get = jest.fn(() => {
117+
return {
118+
body: {
119+
success: true,
120+
},
121+
};
122+
});
123+
LatitudeShApi.Plans.storage(searchParams);
124+
await expect(LatitudeSh._get).toHaveBeenCalledWith(
125+
path,
126+
LatitudeSh._headers,
127+
searchParamsParsed
128+
);
129+
});
130+
131+
it('call get request with wrong params', async () => {
132+
const path = '/plans/storage';
133+
const error = new Error('Async error');
134+
LatitudeSh._get = jest.fn().mockRejectedValue(error);
135+
await LatitudeShApi.Plans.storage().catch(e => {
136+
expect(e).toBe(error);
137+
});
138+
});
139+
});

0 commit comments

Comments
 (0)