Skip to content

Commit 464cbd9

Browse files
author
Lovisa Svallingson
authored
Update to v1.2.0 (#8)
1 parent 2ad621e commit 464cbd9

12 files changed

+261
-29
lines changed

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
## [1.2.0] - 2020-09-17
11+
12+
### Added
13+
14+
- `photos` field to `projects`
15+
- `average_price_per_tonne_cents_usd` field to `projects`
16+
- `remaining_mass_g` field to `projects`
17+
- `standard` field to `projects`
18+
- validations on `mass_g` field (has to be greater than 1 and less than 2,000,000,000) to `orders` and `estimates` creation
19+
1020
## [1.1.1] - 2020-09-01
1121

1222
### Security

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

src/ApiClient.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@ class ApiClient {
411411
hostSettings() {
412412
return [
413413
{
414-
url: 'https://api.usepatch.com',
414+
url: 'https://{api.usepatch.com}',
415415
description: 'No description provided',
416416

417417
variables: {

src/model/Allocation.js

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

1010
class Allocation {
11-
constructor() {
12-
Allocation.initialize(this);
11+
constructor(id, production, massG) {
12+
Allocation.initialize(this, id, production, massG);
1313
}
1414

15-
static initialize(obj) {}
15+
static initialize(obj, id, production, massG) {
16+
obj['id'] = id;
17+
obj['production'] = production;
18+
obj['mass_g'] = massG;
19+
}
1620

1721
static constructFromObject(data, obj) {
1822
if (data) {

src/model/CreateMassEstimateRequest.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,20 @@ class CreateMassEstimateRequest {
2323
if (data.hasOwnProperty('mass_g')) {
2424
obj['mass_g'] = ApiClient.convertToType(data['mass_g'], 'Number');
2525
}
26+
27+
if (data.hasOwnProperty('project_id')) {
28+
obj['project_id'] = ApiClient.convertToType(
29+
data['project_id'],
30+
'String'
31+
);
32+
}
2633
}
2734
return obj;
2835
}
2936
}
3037

3138
CreateMassEstimateRequest.prototype['mass_g'] = undefined;
3239

40+
CreateMassEstimateRequest.prototype['project_id'] = undefined;
41+
3342
export default CreateMassEstimateRequest;

src/model/CreateOrderRequest.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,26 @@ class CreateOrderRequest {
2323
if (data.hasOwnProperty('mass_g')) {
2424
obj['mass_g'] = ApiClient.convertToType(data['mass_g'], 'Number');
2525
}
26+
27+
if (data.hasOwnProperty('project_id')) {
28+
obj['project_id'] = ApiClient.convertToType(
29+
data['project_id'],
30+
'String'
31+
);
32+
}
33+
34+
if (data.hasOwnProperty('metadata')) {
35+
obj['metadata'] = ApiClient.convertToType(data['metadata'], Object);
36+
}
2637
}
2738
return obj;
2839
}
2940
}
3041

3142
CreateOrderRequest.prototype['mass_g'] = undefined;
3243

44+
CreateOrderRequest.prototype['project_id'] = undefined;
45+
46+
CreateOrderRequest.prototype['metadata'] = undefined;
47+
3348
export default CreateOrderRequest;

src/model/Estimate.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,15 @@ import ApiClient from '../ApiClient';
99
import Order from './Order';
1010

1111
class Estimate {
12-
constructor() {
13-
Estimate.initialize(this);
12+
constructor(id, production, type) {
13+
Estimate.initialize(this, id, production, type);
1414
}
1515

16-
static initialize(obj) {}
16+
static initialize(obj, id, production, type) {
17+
obj['id'] = id;
18+
obj['production'] = production;
19+
obj['type'] = type;
20+
}
1721

1822
static constructFromObject(data, obj) {
1923
if (data) {

src/model/Order.js

Lines changed: 47 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,49 @@ import ApiClient from '../ApiClient';
99
import Allocation from './Allocation';
1010

1111
class Order {
12-
constructor() {
13-
Order.initialize(this);
12+
constructor(
13+
id,
14+
massG,
15+
production,
16+
state,
17+
allocationState,
18+
priceCentsUsd,
19+
allocations,
20+
metadata
21+
) {
22+
Order.initialize(
23+
this,
24+
id,
25+
massG,
26+
production,
27+
state,
28+
allocationState,
29+
priceCentsUsd,
30+
allocations,
31+
metadata
32+
);
1433
}
1534

16-
static initialize(obj) {}
35+
static initialize(
36+
obj,
37+
id,
38+
massG,
39+
production,
40+
state,
41+
allocationState,
42+
priceCentsUsd,
43+
allocations,
44+
metadata
45+
) {
46+
obj['id'] = id;
47+
obj['mass_g'] = massG;
48+
obj['production'] = production;
49+
obj['state'] = state;
50+
obj['allocation_state'] = allocationState;
51+
obj['price_cents_usd'] = priceCentsUsd;
52+
obj['allocations'] = allocations;
53+
obj['metadata'] = metadata;
54+
}
1755

1856
static constructFromObject(data, obj) {
1957
if (data) {
@@ -57,6 +95,10 @@ class Order {
5795
Allocation
5896
]);
5997
}
98+
99+
if (data.hasOwnProperty('metadata')) {
100+
obj['metadata'] = ApiClient.convertToType(data['metadata'], Object);
101+
}
60102
}
61103
return obj;
62104
}
@@ -76,4 +118,6 @@ Order.prototype['price_cents_usd'] = undefined;
76118

77119
Order.prototype['allocations'] = undefined;
78120

121+
Order.prototype['metadata'] = undefined;
122+
79123
export default Order;

src/model/Photo.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
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 Photo {
11+
constructor() {
12+
Photo.initialize(this);
13+
}
14+
15+
static initialize(obj) {}
16+
17+
static constructFromObject(data, obj) {
18+
if (data) {
19+
obj = obj || new Photo();
20+
21+
if (data.hasOwnProperty('file')) {
22+
obj['file'] = ApiClient.convertToType(data['file'], 'String');
23+
}
24+
}
25+
return obj;
26+
}
27+
}
28+
29+
Photo.prototype['file'] = undefined;
30+
31+
export default Photo;

src/model/Preference.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,15 @@ import ApiClient from '../ApiClient';
99
import Project from './Project';
1010

1111
class Preference {
12-
constructor() {
13-
Preference.initialize(this);
12+
constructor(id, allocationPercentage, project) {
13+
Preference.initialize(this, id, allocationPercentage, project);
1414
}
1515

16-
static initialize(obj) {}
16+
static initialize(obj, id, allocationPercentage, project) {
17+
obj['id'] = id;
18+
obj['allocation_percentage'] = allocationPercentage;
19+
obj['project'] = project;
20+
}
1721

1822
static constructFromObject(data, obj) {
1923
if (data) {

src/model/Project.js

Lines changed: 76 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,53 @@
66
*/
77

88
import ApiClient from '../ApiClient';
9+
import OneOfstandard from './OneOfstandard';
10+
import Photo from './Photo';
911

1012
class Project {
11-
constructor() {
12-
Project.initialize(this);
13+
constructor(
14+
id,
15+
production,
16+
name,
17+
description,
18+
country,
19+
developer,
20+
averagePricePerTonneCentsUsd,
21+
remainingMassG
22+
) {
23+
Project.initialize(
24+
this,
25+
id,
26+
production,
27+
name,
28+
description,
29+
country,
30+
developer,
31+
averagePricePerTonneCentsUsd,
32+
remainingMassG
33+
);
1334
}
1435

15-
static initialize(obj) {}
36+
static initialize(
37+
obj,
38+
id,
39+
production,
40+
name,
41+
description,
42+
country,
43+
developer,
44+
averagePricePerTonneCentsUsd,
45+
remainingMassG
46+
) {
47+
obj['id'] = id;
48+
obj['production'] = production;
49+
obj['name'] = name;
50+
obj['description'] = description;
51+
obj['country'] = country;
52+
obj['developer'] = developer;
53+
obj['average_price_per_tonne_cents_usd'] = averagePricePerTonneCentsUsd;
54+
obj['remaining_mass_g'] = remainingMassG;
55+
}
1656

1757
static constructFromObject(data, obj) {
1858
if (data) {
@@ -40,24 +80,41 @@ class Project {
4080
);
4181
}
4282

83+
if (data.hasOwnProperty('type')) {
84+
obj['type'] = ApiClient.convertToType(data['type'], 'String');
85+
}
86+
4387
if (data.hasOwnProperty('country')) {
4488
obj['country'] = ApiClient.convertToType(data['country'], 'String');
4589
}
4690

47-
if (data.hasOwnProperty('longitude')) {
48-
obj['longitude'] = ApiClient.convertToType(data['longitude'], 'Number');
91+
if (data.hasOwnProperty('developer')) {
92+
obj['developer'] = ApiClient.convertToType(data['developer'], 'String');
4993
}
5094

51-
if (data.hasOwnProperty('latitude')) {
52-
obj['latitude'] = ApiClient.convertToType(data['latitude'], 'Number');
95+
if (data.hasOwnProperty('photos')) {
96+
obj['photos'] = ApiClient.convertToType(data['photos'], [Photo]);
5397
}
5498

55-
if (data.hasOwnProperty('verifier')) {
56-
obj['verifier'] = ApiClient.convertToType(data['verifier'], 'String');
99+
if (data.hasOwnProperty('average_price_per_tonne_cents_usd')) {
100+
obj['average_price_per_tonne_cents_usd'] = ApiClient.convertToType(
101+
data['average_price_per_tonne_cents_usd'],
102+
'Number'
103+
);
57104
}
58105

59-
if (data.hasOwnProperty('developer')) {
60-
obj['developer'] = ApiClient.convertToType(data['developer'], 'String');
106+
if (data.hasOwnProperty('remaining_mass_g')) {
107+
obj['remaining_mass_g'] = ApiClient.convertToType(
108+
data['remaining_mass_g'],
109+
'Number'
110+
);
111+
}
112+
113+
if (data.hasOwnProperty('standard')) {
114+
obj['standard'] = ApiClient.convertToType(
115+
data['standard'],
116+
OneOfstandard
117+
);
61118
}
62119
}
63120
return obj;
@@ -72,14 +129,18 @@ Project.prototype['name'] = undefined;
72129

73130
Project.prototype['description'] = undefined;
74131

132+
Project.prototype['type'] = undefined;
133+
75134
Project.prototype['country'] = undefined;
76135

77-
Project.prototype['longitude'] = undefined;
136+
Project.prototype['developer'] = undefined;
137+
138+
Project.prototype['photos'] = undefined;
78139

79-
Project.prototype['latitude'] = undefined;
140+
Project.prototype['average_price_per_tonne_cents_usd'] = undefined;
80141

81-
Project.prototype['verifier'] = undefined;
142+
Project.prototype['remaining_mass_g'] = undefined;
82143

83-
Project.prototype['developer'] = undefined;
144+
Project.prototype['standard'] = undefined;
84145

85146
export default Project;

0 commit comments

Comments
 (0)