Skip to content

Commit

Permalink
Adds highlights to projects response (#51)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
alianam and pcothenet authored Nov 15, 2021
1 parent 94512d7 commit 30456e9
Show file tree
Hide file tree
Showing 7 changed files with 74 additions and 7 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [1.15.2] - 2021-11-08

### Added

- Adds highlights to project responses

## [1.15.1] - 2021-11-04

### Added
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@patch-technology/patch",
"version": "1.15.1",
"version": "1.15.2",
"description": "Node.js wrapper for the Patch API",
"license": "MIT",
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion src/ApiClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class ApiClient {
};

this.defaultHeaders = {
'User-Agent': 'patch-node/1.15.1'
'User-Agent': 'patch-node/1.15.2'
};

/**
Expand Down
47 changes: 47 additions & 0 deletions src/model/Highlight.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/**
* Patch API V1
* The core API used to integrate with Patch's service
*
* Contact: [email protected]
*/

import ApiClient from '../ApiClient';

class Highlight {
constructor(slug, title, iconUrl) {
Highlight.initialize(this, slug, title, iconUrl);
}

static initialize(obj, slug, title, iconUrl) {
obj['slug'] = slug;
obj['title'] = title;
obj['icon_url'] = iconUrl;
}

static constructFromObject(data, obj) {
if (data) {
obj = obj || new Highlight();

if (data.hasOwnProperty('slug')) {
obj['slug'] = ApiClient.convertToType(data['slug'], 'String');
}

if (data.hasOwnProperty('title')) {
obj['title'] = ApiClient.convertToType(data['title'], 'String');
}

if (data.hasOwnProperty('icon_url')) {
obj['icon_url'] = ApiClient.convertToType(data['icon_url'], 'String');
}
}
return obj;
}
}

Highlight.prototype['slug'] = undefined;

Highlight.prototype['title'] = undefined;

Highlight.prototype['icon_url'] = undefined;

export default Highlight;
19 changes: 16 additions & 3 deletions src/model/Project.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*/

import ApiClient from '../ApiClient';
import Highlight from './Highlight';
import Photo from './Photo';
import Sdg from './Sdg';
import Standard from './Standard';
Expand All @@ -21,7 +22,8 @@ class Project {
developer,
averagePricePerTonneCentsUsd,
remainingMassG,
technologyType
technologyType,
highlights
) {
Project.initialize(
this,
Expand All @@ -33,7 +35,8 @@ class Project {
developer,
averagePricePerTonneCentsUsd,
remainingMassG,
technologyType
technologyType,
highlights
);
}

Expand All @@ -47,7 +50,8 @@ class Project {
developer,
averagePricePerTonneCentsUsd,
remainingMassG,
technologyType
technologyType,
highlights
) {
obj['id'] = id;
obj['production'] = production;
Expand All @@ -58,6 +62,7 @@ class Project {
obj['average_price_per_tonne_cents_usd'] = averagePricePerTonneCentsUsd;
obj['remaining_mass_g'] = remainingMassG;
obj['technology_type'] = technologyType;
obj['highlights'] = highlights;
}

static constructFromObject(data, obj) {
Expand Down Expand Up @@ -153,6 +158,12 @@ class Project {
data['technology_type']
);
}

if (data.hasOwnProperty('highlights')) {
obj['highlights'] = ApiClient.convertToType(data['highlights'], [
Highlight
]);
}
}
return obj;
}
Expand Down Expand Up @@ -196,4 +207,6 @@ Project.prototype['tagline'] = undefined;

Project.prototype['technology_type'] = undefined;

Project.prototype['highlights'] = undefined;

export default Project;
1 change: 1 addition & 0 deletions test/integration/projects.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ describe('Project Integration', function () {
expect(projectResponse.data.mechanism).to.be.a('string');
expect(projectResponse.data.latitude).to.be.a('number');
expect(projectResponse.data.longitude).to.be.a('number');
expect(projectResponse.data.highlights).to.be.an('array');

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

0 comments on commit 30456e9

Please sign in to comment.