Skip to content

Commit 4b0e99e

Browse files
authored
Add filtering for remaining inventory (#25)
1 parent d6f8cd7 commit 4b0e99e

File tree

5 files changed

+19
-3
lines changed

5 files changed

+19
-3
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1010
### Added
1111

1212
- Adds Sustainable Development Goals (SDGs) field to projects
13-
- Adds filtering to Projects on type, country
13+
- Adds filtering to Projects on type, country, minimum_available_mass
1414

1515
### Changed
1616

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ When fetching Projects, you can add filters to the query to narrow the result. C
145145

146146
- `country`
147147
- `type`
148+
- `minimumAvailableMass`
148149

149150
[API Reference](https://docs.usepatch.com/#/?id=projects)
150151

@@ -166,6 +167,10 @@ patch.projects.retrieveProjects({ country });
166167
// Retrieve a filtered list of projects
167168
const type = 'biomass'; // Pass in the project type you'd like to filter by
168169
patch.projects.retrieveProjects({ type });
170+
171+
// Retrieve a filtered list of projects
172+
const minimumAvailableMass = 100; // Pass in the minimum available inventory the projects should have
173+
patch.projects.retrieveProjects({ minimumAvailableMass });
169174
```
170175

171176
### Preferences

src/api/ProjectsApi.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,9 @@ export default class ProjectsApi {
7575

7676
country: opts['country'],
7777

78-
type: opts['type']
78+
type: opts['type'],
79+
80+
minimum_available_mass: opts['minimumAvailableMass']
7981
};
8082
let headerParams = {};
8183
let formParams = {};

test/integration/preferences.test.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ describe('Preferences Integration', async function () {
3030
const createdPreference = await patch.preferences.createPreference({
3131
project_id: projectId
3232
});
33-
console.log(createdPreference);
3433

3534
expect(createdPreference.data.projectId).to.eq(projectId);
3635

test/integration/projects.test.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,14 @@ describe('Project Integration', function () {
3030
expect(project.type).to.equal(type);
3131
});
3232
});
33+
34+
it('supports fetching all projects with more than 100 grams of available inventory', async function () {
35+
const minimumAvailableMass = 100;
36+
const { data } = await patch.projects.retrieveProjects({
37+
minimumAvailableMass
38+
});
39+
data.map((project) => {
40+
expect(project.remaining_mass_g >= minimumAvailableMass).to.be.true;
41+
});
42+
});
3343
});

0 commit comments

Comments
 (0)