Skip to content

Commit

Permalink
Update to 2.1.1 for issuance_type and disclaimers (#88)
Browse files Browse the repository at this point in the history
  • Loading branch information
venalen authored Apr 18, 2023
1 parent b4c8085 commit 2219a4b
Show file tree
Hide file tree
Showing 7 changed files with 101 additions and 4 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ 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).

## [2.1.1] - 2023-04-18

### Added

- Adds `issuance_type` to `project` responses
- Adds `disclaimers` to `project` responses

## [2.1.0] - 2023-04-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": "2.1.0",
"version": "2.1.1",
"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/2.1.0',
'User-Agent': 'patch-node/2.1.1',
'Patch-Version': 2
};

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

import ApiClient from '../ApiClient';

class Disclaimer {
constructor(header, severity) {
Disclaimer.initialize(this, header, severity);
}

static initialize(obj, header, severity) {
obj['header'] = header;
obj['severity'] = severity;
}

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

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

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

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

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

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

Disclaimer.prototype['body'] = undefined;

Disclaimer.prototype['header'] = undefined;

Disclaimer.prototype['severity'] = undefined;

Disclaimer.prototype['link_text'] = undefined;

Disclaimer.prototype['link_destination'] = undefined;

export default Disclaimer;
18 changes: 18 additions & 0 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 Disclaimer from './Disclaimer';
import Highlight from './Highlight';
import Inventory from './Inventory';
import Photo from './Photo';
Expand Down Expand Up @@ -100,6 +101,13 @@ class Project {
obj['state'] = ApiClient.convertToType(data['state'], 'String');
}

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

if (data.hasOwnProperty('latitude')) {
obj['latitude'] = ApiClient.convertToType(data['latitude'], 'Number');
}
Expand Down Expand Up @@ -152,6 +160,12 @@ class Project {
Inventory
]);
}

if (data.hasOwnProperty('disclaimers')) {
obj['disclaimers'] = ApiClient.convertToType(data['disclaimers'], [
Disclaimer
]);
}
}
return obj;
}
Expand All @@ -171,6 +185,8 @@ Project.prototype['country'] = undefined;

Project.prototype['state'] = undefined;

Project.prototype['issuance_type'] = undefined;

Project.prototype['latitude'] = undefined;

Project.prototype['longitude'] = undefined;
Expand All @@ -193,4 +209,6 @@ Project.prototype['highlights'] = undefined;

Project.prototype['inventory'] = undefined;

Project.prototype['disclaimers'] = undefined;

export default Project;
11 changes: 11 additions & 0 deletions test/integration/projects.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,17 @@ describe('Project Integration', function () {
expect(inventory[0].price).to.be.a('number');
expect(inventory[0].currency).to.be.a('string');
expect(inventory[0].unit).to.be.a('string');

const issuance_type = projectResponse.data.issuance_type;
expect(issuance_type).to.be.a('string');

const disclaimers = projectResponse.data.disclaimers;
expect(disclaimers).to.be.a('array');
expect(disclaimers[0].header).to.be.a('string');
expect(disclaimers[0].body).to.be.a('string');
expect(disclaimers[0].severity).to.be.a('string');
expect(disclaimers[0].link_text).to.be.a('string');
expect(disclaimers[0].link_destination).to.be.a('string');
});

it('supports fetching a single project in a different language', async function () {
Expand Down

0 comments on commit 2219a4b

Please sign in to comment.