Skip to content

Commit 7e53321

Browse files
authored
update sdks (#23)
1 parent b5178e2 commit 7e53321

File tree

6 files changed

+82
-8
lines changed

6 files changed

+82
-8
lines changed

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,16 @@ 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.4.0] - 2020-02-15
9+
10+
### Added
11+
12+
- Adds Sustainable Development Goals (SDGs) field to projects
13+
14+
### Changed
15+
16+
- vehicle estimates now support optional `make`, `model` and `year` fields.
17+
818
## [1.3.0] - 2020-02-08
919

1020
### Added

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.3.0",
3+
"version": "1.4.0",
44
"description": "JavaScript wrapper for the Patch API",
55
"license": "MIT",
66
"repository": {

src/model/CreateVehicleEstimateRequest.js

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,12 @@
88
import ApiClient from '../ApiClient';
99

1010
class CreateVehicleEstimateRequest {
11-
constructor(distanceM, make, model, year) {
12-
CreateVehicleEstimateRequest.initialize(this, distanceM, make, model, year);
11+
constructor(distanceM) {
12+
CreateVehicleEstimateRequest.initialize(this, distanceM);
1313
}
1414

15-
static initialize(obj, distanceM, make, model, year) {
15+
static initialize(obj, distanceM) {
1616
obj['distance_m'] = distanceM;
17-
obj['make'] = make;
18-
obj['model'] = model;
19-
obj['year'] = year;
2017
}
2118

2219
static constructFromObject(data, obj) {

src/model/Project.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
import ApiClient from '../ApiClient';
99
import Photo from './Photo';
10+
import Sdg from './Sdg';
1011
import Standard from './Standard';
1112

1213
class Project {
@@ -113,6 +114,10 @@ class Project {
113114
if (data.hasOwnProperty('standard')) {
114115
obj['standard'] = ApiClient.convertToType(data['standard'], Standard);
115116
}
117+
118+
if (data.hasOwnProperty('sdgs')) {
119+
obj['sdgs'] = ApiClient.convertToType(data['sdgs'], [Sdg]);
120+
}
116121
}
117122
return obj;
118123
}
@@ -140,4 +145,6 @@ Project.prototype['remaining_mass_g'] = undefined;
140145

141146
Project.prototype['standard'] = undefined;
142147

148+
Project.prototype['sdgs'] = undefined;
149+
143150
export default Project;

src/model/Sdg.js

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
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 Sdg {
11+
constructor(title, _number, description, url) {
12+
Sdg.initialize(this, title, _number, description, url);
13+
}
14+
15+
static initialize(obj, title, _number, description, url) {
16+
obj['title'] = title;
17+
obj['number'] = _number;
18+
obj['description'] = description;
19+
obj['url'] = url;
20+
}
21+
22+
static constructFromObject(data, obj) {
23+
if (data) {
24+
obj = obj || new Sdg();
25+
26+
if (data.hasOwnProperty('title')) {
27+
obj['title'] = ApiClient.convertToType(data['title'], 'String');
28+
}
29+
30+
if (data.hasOwnProperty('number')) {
31+
obj['number'] = ApiClient.convertToType(data['number'], 'Number');
32+
}
33+
34+
if (data.hasOwnProperty('description')) {
35+
obj['description'] = ApiClient.convertToType(
36+
data['description'],
37+
'String'
38+
);
39+
}
40+
41+
if (data.hasOwnProperty('url')) {
42+
obj['url'] = ApiClient.convertToType(data['url'], 'String');
43+
}
44+
}
45+
return obj;
46+
}
47+
}
48+
49+
Sdg.prototype['title'] = undefined;
50+
51+
Sdg.prototype['number'] = undefined;
52+
53+
Sdg.prototype['description'] = undefined;
54+
55+
Sdg.prototype['url'] = undefined;
56+
57+
export default Sdg;

test/integration/orders.test.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,10 @@ describe('Orders Integration', function () {
2323
project_id: biomass_test_project_id
2424
});
2525

26-
expect(createOrderResponse.data.price_cents_usd).to.equal('500.0');
26+
expect(parseFloat(createOrderResponse.data.price_cents_usd)).to.be.closeTo(
27+
500,
28+
1
29+
)
2730
expect(createOrderResponse.data.patch_fee_cents_usd).to.equal('0.0');
2831
expect(createOrderResponse.data.mass_g).to.equal(500000);
2932
});

0 commit comments

Comments
 (0)