Skip to content

Commit

Permalink
Update to v1.2.0 (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
Lovisa Svallingson authored Sep 18, 2020
1 parent 2ad621e commit 464cbd9
Show file tree
Hide file tree
Showing 12 changed files with 261 additions and 29 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [1.2.0] - 2020-09-17

### Added

- `photos` field to `projects`
- `average_price_per_tonne_cents_usd` field to `projects`
- `remaining_mass_g` field to `projects`
- `standard` field to `projects`
- validations on `mass_g` field (has to be greater than 1 and less than 2,000,000,000) to `orders` and `estimates` creation

## [1.1.1] - 2020-09-01

### Security
Expand Down
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.1.1",
"version": "1.2.0",
"description": "Javascript 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 @@ -411,7 +411,7 @@ class ApiClient {
hostSettings() {
return [
{
url: 'https://api.usepatch.com',
url: 'https://{api.usepatch.com}',
description: 'No description provided',

variables: {
Expand Down
10 changes: 7 additions & 3 deletions src/model/Allocation.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,15 @@
import ApiClient from '../ApiClient';

class Allocation {
constructor() {
Allocation.initialize(this);
constructor(id, production, massG) {
Allocation.initialize(this, id, production, massG);
}

static initialize(obj) {}
static initialize(obj, id, production, massG) {
obj['id'] = id;
obj['production'] = production;
obj['mass_g'] = massG;
}

static constructFromObject(data, obj) {
if (data) {
Expand Down
9 changes: 9 additions & 0 deletions src/model/CreateMassEstimateRequest.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,20 @@ class CreateMassEstimateRequest {
if (data.hasOwnProperty('mass_g')) {
obj['mass_g'] = ApiClient.convertToType(data['mass_g'], 'Number');
}

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

CreateMassEstimateRequest.prototype['mass_g'] = undefined;

CreateMassEstimateRequest.prototype['project_id'] = undefined;

export default CreateMassEstimateRequest;
15 changes: 15 additions & 0 deletions src/model/CreateOrderRequest.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,26 @@ class CreateOrderRequest {
if (data.hasOwnProperty('mass_g')) {
obj['mass_g'] = ApiClient.convertToType(data['mass_g'], 'Number');
}

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

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

CreateOrderRequest.prototype['mass_g'] = undefined;

CreateOrderRequest.prototype['project_id'] = undefined;

CreateOrderRequest.prototype['metadata'] = undefined;

export default CreateOrderRequest;
10 changes: 7 additions & 3 deletions src/model/Estimate.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,15 @@ import ApiClient from '../ApiClient';
import Order from './Order';

class Estimate {
constructor() {
Estimate.initialize(this);
constructor(id, production, type) {
Estimate.initialize(this, id, production, type);
}

static initialize(obj) {}
static initialize(obj, id, production, type) {
obj['id'] = id;
obj['production'] = production;
obj['type'] = type;
}

static constructFromObject(data, obj) {
if (data) {
Expand Down
50 changes: 47 additions & 3 deletions src/model/Order.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,49 @@ import ApiClient from '../ApiClient';
import Allocation from './Allocation';

class Order {
constructor() {
Order.initialize(this);
constructor(
id,
massG,
production,
state,
allocationState,
priceCentsUsd,
allocations,
metadata
) {
Order.initialize(
this,
id,
massG,
production,
state,
allocationState,
priceCentsUsd,
allocations,
metadata
);
}

static initialize(obj) {}
static initialize(
obj,
id,
massG,
production,
state,
allocationState,
priceCentsUsd,
allocations,
metadata
) {
obj['id'] = id;
obj['mass_g'] = massG;
obj['production'] = production;
obj['state'] = state;
obj['allocation_state'] = allocationState;
obj['price_cents_usd'] = priceCentsUsd;
obj['allocations'] = allocations;
obj['metadata'] = metadata;
}

static constructFromObject(data, obj) {
if (data) {
Expand Down Expand Up @@ -57,6 +95,10 @@ class Order {
Allocation
]);
}

if (data.hasOwnProperty('metadata')) {
obj['metadata'] = ApiClient.convertToType(data['metadata'], Object);
}
}
return obj;
}
Expand All @@ -76,4 +118,6 @@ Order.prototype['price_cents_usd'] = undefined;

Order.prototype['allocations'] = undefined;

Order.prototype['metadata'] = undefined;

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

import ApiClient from '../ApiClient';

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

static initialize(obj) {}

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

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

Photo.prototype['file'] = undefined;

export default Photo;
10 changes: 7 additions & 3 deletions src/model/Preference.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,15 @@ import ApiClient from '../ApiClient';
import Project from './Project';

class Preference {
constructor() {
Preference.initialize(this);
constructor(id, allocationPercentage, project) {
Preference.initialize(this, id, allocationPercentage, project);
}

static initialize(obj) {}
static initialize(obj, id, allocationPercentage, project) {
obj['id'] = id;
obj['allocation_percentage'] = allocationPercentage;
obj['project'] = project;
}

static constructFromObject(data, obj) {
if (data) {
Expand Down
91 changes: 76 additions & 15 deletions src/model/Project.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,53 @@
*/

import ApiClient from '../ApiClient';
import OneOfstandard from './OneOfstandard';
import Photo from './Photo';

class Project {
constructor() {
Project.initialize(this);
constructor(
id,
production,
name,
description,
country,
developer,
averagePricePerTonneCentsUsd,
remainingMassG
) {
Project.initialize(
this,
id,
production,
name,
description,
country,
developer,
averagePricePerTonneCentsUsd,
remainingMassG
);
}

static initialize(obj) {}
static initialize(
obj,
id,
production,
name,
description,
country,
developer,
averagePricePerTonneCentsUsd,
remainingMassG
) {
obj['id'] = id;
obj['production'] = production;
obj['name'] = name;
obj['description'] = description;
obj['country'] = country;
obj['developer'] = developer;
obj['average_price_per_tonne_cents_usd'] = averagePricePerTonneCentsUsd;
obj['remaining_mass_g'] = remainingMassG;
}

static constructFromObject(data, obj) {
if (data) {
Expand Down Expand Up @@ -40,24 +80,41 @@ class Project {
);
}

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

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

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

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

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

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

if (data.hasOwnProperty('standard')) {
obj['standard'] = ApiClient.convertToType(
data['standard'],
OneOfstandard
);
}
}
return obj;
Expand All @@ -72,14 +129,18 @@ Project.prototype['name'] = undefined;

Project.prototype['description'] = undefined;

Project.prototype['type'] = undefined;

Project.prototype['country'] = undefined;

Project.prototype['longitude'] = undefined;
Project.prototype['developer'] = undefined;

Project.prototype['photos'] = undefined;

Project.prototype['latitude'] = undefined;
Project.prototype['average_price_per_tonne_cents_usd'] = undefined;

Project.prototype['verifier'] = undefined;
Project.prototype['remaining_mass_g'] = undefined;

Project.prototype['developer'] = undefined;
Project.prototype['standard'] = undefined;

export default Project;
Loading

0 comments on commit 464cbd9

Please sign in to comment.