Skip to content

Commit 30456e9

Browse files
alianampcothenet
andauthored
Adds highlights to projects response (#51)
* Adds highlights to projects response * update a to an * Use docker for build stage * Tweak * Reran make build after merging in pc/docker branch * Add icon_url Co-authored-by: Paul Cothenet <[email protected]>
1 parent 94512d7 commit 30456e9

File tree

7 files changed

+74
-7
lines changed

7 files changed

+74
-7
lines changed

CHANGELOG.md

+6
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.15.2] - 2021-11-08
9+
10+
### Added
11+
12+
- Adds highlights to project responses
13+
814
## [1.15.1] - 2021-11-04
915

1016
### Added

package-lock.json

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

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

src/ApiClient.js

+1-1
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.15.1'
19+
'User-Agent': 'patch-node/1.15.2'
2020
};
2121

2222
/**

src/model/Highlight.js

+47
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+
10+
class Highlight {
11+
constructor(slug, title, iconUrl) {
12+
Highlight.initialize(this, slug, title, iconUrl);
13+
}
14+
15+
static initialize(obj, slug, title, iconUrl) {
16+
obj['slug'] = slug;
17+
obj['title'] = title;
18+
obj['icon_url'] = iconUrl;
19+
}
20+
21+
static constructFromObject(data, obj) {
22+
if (data) {
23+
obj = obj || new Highlight();
24+
25+
if (data.hasOwnProperty('slug')) {
26+
obj['slug'] = ApiClient.convertToType(data['slug'], 'String');
27+
}
28+
29+
if (data.hasOwnProperty('title')) {
30+
obj['title'] = ApiClient.convertToType(data['title'], 'String');
31+
}
32+
33+
if (data.hasOwnProperty('icon_url')) {
34+
obj['icon_url'] = ApiClient.convertToType(data['icon_url'], 'String');
35+
}
36+
}
37+
return obj;
38+
}
39+
}
40+
41+
Highlight.prototype['slug'] = undefined;
42+
43+
Highlight.prototype['title'] = undefined;
44+
45+
Highlight.prototype['icon_url'] = undefined;
46+
47+
export default Highlight;

src/model/Project.js

+16-3
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
*/
77

88
import ApiClient from '../ApiClient';
9+
import Highlight from './Highlight';
910
import Photo from './Photo';
1011
import Sdg from './Sdg';
1112
import Standard from './Standard';
@@ -21,7 +22,8 @@ class Project {
2122
developer,
2223
averagePricePerTonneCentsUsd,
2324
remainingMassG,
24-
technologyType
25+
technologyType,
26+
highlights
2527
) {
2628
Project.initialize(
2729
this,
@@ -33,7 +35,8 @@ class Project {
3335
developer,
3436
averagePricePerTonneCentsUsd,
3537
remainingMassG,
36-
technologyType
38+
technologyType,
39+
highlights
3740
);
3841
}
3942

@@ -47,7 +50,8 @@ class Project {
4750
developer,
4851
averagePricePerTonneCentsUsd,
4952
remainingMassG,
50-
technologyType
53+
technologyType,
54+
highlights
5155
) {
5256
obj['id'] = id;
5357
obj['production'] = production;
@@ -58,6 +62,7 @@ class Project {
5862
obj['average_price_per_tonne_cents_usd'] = averagePricePerTonneCentsUsd;
5963
obj['remaining_mass_g'] = remainingMassG;
6064
obj['technology_type'] = technologyType;
65+
obj['highlights'] = highlights;
6166
}
6267

6368
static constructFromObject(data, obj) {
@@ -153,6 +158,12 @@ class Project {
153158
data['technology_type']
154159
);
155160
}
161+
162+
if (data.hasOwnProperty('highlights')) {
163+
obj['highlights'] = ApiClient.convertToType(data['highlights'], [
164+
Highlight
165+
]);
166+
}
156167
}
157168
return obj;
158169
}
@@ -196,4 +207,6 @@ Project.prototype['tagline'] = undefined;
196207

197208
Project.prototype['technology_type'] = undefined;
198209

210+
Project.prototype['highlights'] = undefined;
211+
199212
export default Project;

test/integration/projects.test.js

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ describe('Project Integration', function () {
2020
expect(projectResponse.data.mechanism).to.be.a('string');
2121
expect(projectResponse.data.latitude).to.be.a('number');
2222
expect(projectResponse.data.longitude).to.be.a('number');
23+
expect(projectResponse.data.highlights).to.be.an('array');
2324

2425
const technology_type = projectResponse.data.technology_type;
2526
expect(technology_type.slug).to.be.a('string');

0 commit comments

Comments
 (0)