Skip to content

Commit fe35490

Browse files
authored
Adds mechanism, tagline, state, latitude, longitude, and technology_type to project responses (#48)
1 parent c78ffe1 commit fe35490

File tree

8 files changed

+149
-4
lines changed

8 files changed

+149
-4
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [1.14.0] - 2021-09-27
9+
10+
### Added
11+
12+
- Adds mechanism, tagline, state, latitude, longitude, and technology_type to project responses
13+
814
## [1.13.0] - 2021-09-10
915

1016
### Added

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@patch-technology/patch",
3-
"version": "1.13.0",
3+
"version": "1.14.0",
44
"description": "Node.js wrapper for the Patch API",
55
"license": "MIT",
66
"repository": {

src/ApiClient.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class ApiClient {
1616
};
1717

1818
this.defaultHeaders = {
19-
'User-Agent': 'patch-node/1.13.0'
19+
'User-Agent': 'patch-node/1.14.0'
2020
};
2121

2222
/**

src/model/ParentTechnologyType.js

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/**
2+
* Patch API V1
3+
* The core API used to integrate with Patch's service
4+
*
5+
* Contact: [email protected]
6+
*/
7+
8+
import ApiClient from '../ApiClient';
9+
10+
class ParentTechnologyType {
11+
constructor() {
12+
ParentTechnologyType.initialize(this);
13+
}
14+
15+
static initialize(obj) {}
16+
17+
static constructFromObject(data, obj) {
18+
if (data) {
19+
obj = obj || new ParentTechnologyType();
20+
21+
if (data.hasOwnProperty('slug')) {
22+
obj['slug'] = ApiClient.convertToType(data['slug'], 'String');
23+
}
24+
25+
if (data.hasOwnProperty('name')) {
26+
obj['name'] = ApiClient.convertToType(data['name'], 'String');
27+
}
28+
}
29+
return obj;
30+
}
31+
}
32+
33+
ParentTechnologyType.prototype['slug'] = undefined;
34+
35+
ParentTechnologyType.prototype['name'] = undefined;
36+
37+
export default ParentTechnologyType;

src/model/Project.js

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import ApiClient from '../ApiClient';
99
import Photo from './Photo';
1010
import Sdg from './Sdg';
1111
import Standard from './Standard';
12+
import TechnologyType from './TechnologyType';
1213

1314
class Project {
1415
constructor(
@@ -85,10 +86,26 @@ class Project {
8586
obj['type'] = ApiClient.convertToType(data['type'], 'String');
8687
}
8788

89+
if (data.hasOwnProperty('mechanism')) {
90+
obj['mechanism'] = ApiClient.convertToType(data['mechanism'], 'String');
91+
}
92+
8893
if (data.hasOwnProperty('country')) {
8994
obj['country'] = ApiClient.convertToType(data['country'], 'String');
9095
}
9196

97+
if (data.hasOwnProperty('state')) {
98+
obj['state'] = ApiClient.convertToType(data['state'], 'String');
99+
}
100+
101+
if (data.hasOwnProperty('latitude')) {
102+
obj['latitude'] = ApiClient.convertToType(data['latitude'], 'Number');
103+
}
104+
105+
if (data.hasOwnProperty('longitude')) {
106+
obj['longitude'] = ApiClient.convertToType(data['longitude'], 'Number');
107+
}
108+
92109
if (data.hasOwnProperty('developer')) {
93110
obj['developer'] = ApiClient.convertToType(data['developer'], 'String');
94111
}
@@ -118,6 +135,16 @@ class Project {
118135
if (data.hasOwnProperty('sdgs')) {
119136
obj['sdgs'] = ApiClient.convertToType(data['sdgs'], [Sdg]);
120137
}
138+
139+
if (data.hasOwnProperty('technology_type')) {
140+
obj['technology_type'] = TechnologyType.constructFromObject(
141+
data['technology_type']
142+
);
143+
}
144+
145+
if (data.hasOwnProperty('tagline')) {
146+
obj['tagline'] = ApiClient.convertToType(data['tagline'], 'String');
147+
}
121148
}
122149
return obj;
123150
}
@@ -133,8 +160,16 @@ Project.prototype['description'] = undefined;
133160

134161
Project.prototype['type'] = undefined;
135162

163+
Project.prototype['mechanism'] = undefined;
164+
136165
Project.prototype['country'] = undefined;
137166

167+
Project.prototype['state'] = undefined;
168+
169+
Project.prototype['latitude'] = undefined;
170+
171+
Project.prototype['longitude'] = undefined;
172+
138173
Project.prototype['developer'] = undefined;
139174

140175
Project.prototype['photos'] = undefined;
@@ -147,4 +182,8 @@ Project.prototype['standard'] = undefined;
147182

148183
Project.prototype['sdgs'] = undefined;
149184

185+
Project.prototype['technology_type'] = undefined;
186+
187+
Project.prototype['tagline'] = undefined;
188+
150189
export default Project;

src/model/TechnologyType.js

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/**
2+
* Patch API V1
3+
* The core API used to integrate with Patch's service
4+
*
5+
* Contact: [email protected]
6+
*/
7+
8+
import ApiClient from '../ApiClient';
9+
import ParentTechnologyType from './ParentTechnologyType';
10+
11+
class TechnologyType {
12+
constructor() {
13+
TechnologyType.initialize(this);
14+
}
15+
16+
static initialize(obj) {}
17+
18+
static constructFromObject(data, obj) {
19+
if (data) {
20+
obj = obj || new TechnologyType();
21+
22+
if (data.hasOwnProperty('slug')) {
23+
obj['slug'] = ApiClient.convertToType(data['slug'], 'String');
24+
}
25+
26+
if (data.hasOwnProperty('name')) {
27+
obj['name'] = ApiClient.convertToType(data['name'], 'String');
28+
}
29+
30+
if (data.hasOwnProperty('parent_technology_type')) {
31+
obj['parent_technology_type'] =
32+
ParentTechnologyType.constructFromObject(
33+
data['parent_technology_type']
34+
);
35+
}
36+
}
37+
return obj;
38+
}
39+
}
40+
41+
TechnologyType.prototype['slug'] = undefined;
42+
43+
TechnologyType.prototype['name'] = undefined;
44+
45+
TechnologyType.prototype['parent_technology_type'] = undefined;
46+
47+
export default TechnologyType;

test/integration/projects.test.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,22 @@ describe('Project Integration', function () {
1313
const projectId = data[0].id;
1414
const projectResponse = await patch.projects.retrieveProject(projectId);
1515
expect(projectResponse.data.id).to.equal(projectId);
16+
17+
// tagline can be null but should always be present in the payload
18+
expect(projectResponse.data).to.be.have.property('tagline');
19+
20+
expect(projectResponse.data.mechanism).to.be.a('string');
21+
expect(projectResponse.data.state).to.be.a('string');
22+
expect(projectResponse.data.latitude).to.be.a('number');
23+
expect(projectResponse.data.longitude).to.be.a('number');
24+
25+
const technology_type = projectResponse.data.technology_type;
26+
expect(technology_type.slug).to.be.a('string');
27+
expect(technology_type.name).to.be.a('string');
28+
29+
const parent_technology_type = technology_type.parent_technology_type;
30+
expect(parent_technology_type.slug).to.be.a('string');
31+
expect(parent_technology_type.name).to.be.a('string');
1632
});
1733

1834
it('supports fetching all projects from the United States', async function () {

0 commit comments

Comments
 (0)