Skip to content

Adds mechanism, tagline, state, latitude, longitude, and technology_type to project responses #48

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.14.0] - 2021-09-27

### Added

- Adds mechanism, tagline, state, latitude, longitude, and technology_type to project responses

## [1.13.0] - 2021-09-10

### 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.13.0",
"version": "1.14.0",
"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.13.0'
'User-Agent': 'patch-node/1.14.0'
};

/**
Expand Down
37 changes: 37 additions & 0 deletions src/model/ParentTechnologyType.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/**
* Patch API V1
* The core API used to integrate with Patch's service
*
* Contact: developers@usepatch.com
*/

import ApiClient from '../ApiClient';

class ParentTechnologyType {
constructor() {
ParentTechnologyType.initialize(this);
}

static initialize(obj) {}

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

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

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

ParentTechnologyType.prototype['slug'] = undefined;

ParentTechnologyType.prototype['name'] = undefined;

export default ParentTechnologyType;
39 changes: 39 additions & 0 deletions src/model/Project.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import ApiClient from '../ApiClient';
import Photo from './Photo';
import Sdg from './Sdg';
import Standard from './Standard';
import TechnologyType from './TechnologyType';

class Project {
constructor(
Expand Down Expand Up @@ -85,10 +86,26 @@ class Project {
obj['type'] = ApiClient.convertToType(data['type'], 'String');
}

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

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

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

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

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

if (data.hasOwnProperty('developer')) {
obj['developer'] = ApiClient.convertToType(data['developer'], 'String');
}
Expand Down Expand Up @@ -118,6 +135,16 @@ class Project {
if (data.hasOwnProperty('sdgs')) {
obj['sdgs'] = ApiClient.convertToType(data['sdgs'], [Sdg]);
}

if (data.hasOwnProperty('technology_type')) {
obj['technology_type'] = TechnologyType.constructFromObject(
data['technology_type']
);
}

if (data.hasOwnProperty('tagline')) {
obj['tagline'] = ApiClient.convertToType(data['tagline'], 'String');
}
}
return obj;
}
Expand All @@ -133,8 +160,16 @@ Project.prototype['description'] = undefined;

Project.prototype['type'] = undefined;

Project.prototype['mechanism'] = undefined;

Project.prototype['country'] = undefined;

Project.prototype['state'] = undefined;

Project.prototype['latitude'] = undefined;

Project.prototype['longitude'] = undefined;

Project.prototype['developer'] = undefined;

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

Project.prototype['sdgs'] = undefined;

Project.prototype['technology_type'] = undefined;

Project.prototype['tagline'] = undefined;

export default Project;
47 changes: 47 additions & 0 deletions src/model/TechnologyType.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: developers@usepatch.com
*/

import ApiClient from '../ApiClient';
import ParentTechnologyType from './ParentTechnologyType';

class TechnologyType {
constructor() {
TechnologyType.initialize(this);
}

static initialize(obj) {}

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

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

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

if (data.hasOwnProperty('parent_technology_type')) {
obj['parent_technology_type'] =
ParentTechnologyType.constructFromObject(
data['parent_technology_type']
);
}
}
return obj;
}
}

TechnologyType.prototype['slug'] = undefined;

TechnologyType.prototype['name'] = undefined;

TechnologyType.prototype['parent_technology_type'] = undefined;

export default TechnologyType;
16 changes: 16 additions & 0 deletions test/integration/projects.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,22 @@ describe('Project Integration', function () {
const projectId = data[0].id;
const projectResponse = await patch.projects.retrieveProject(projectId);
expect(projectResponse.data.id).to.equal(projectId);

// tagline can be null but should always be present in the payload
expect(projectResponse.data).to.be.have.property('tagline');

expect(projectResponse.data.mechanism).to.be.a('string');
expect(projectResponse.data.state).to.be.a('string');
expect(projectResponse.data.latitude).to.be.a('number');
expect(projectResponse.data.longitude).to.be.a('number');

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

const parent_technology_type = technology_type.parent_technology_type;
expect(parent_technology_type.slug).to.be.a('string');
expect(parent_technology_type.name).to.be.a('string');
});

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