Skip to content

Commit

Permalink
Merge pull request #448 from ripe-tech/dva/271-add_quantity_param
Browse files Browse the repository at this point in the history
#271 Add quantity param to import order
  • Loading branch information
joao-conde authored Dec 7, 2022
2 parents a1b0671 + 64f416a commit 00717bd
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Added

*
* Add `quantity` param to `_importOrder` method - [ripe-pulse/#271](https://github.com/ripe-tech/ripe-pulse/issues/271)

### Changed

Expand Down
2 changes: 2 additions & 0 deletions src/js/api/order.js
Original file line number Diff line number Diff line change
Expand Up @@ -2377,6 +2377,7 @@ ripe.Ripe.prototype._getOrderImageURL = function(number, key, options) {
ripe.Ripe.prototype._importOrder = function(ffOrderId, options = {}) {
const dku = options.dku === undefined ? null : options.dku;
const type = options.type === undefined ? null : options.type;
const quantity = options.quantity === undefined ? null : options.quantity;
const brand = options.brand === undefined ? this.brand : options.brand;
const factory = options.factory === undefined ? null : options.factory;
const model = options.model === undefined ? this.model : options.model;
Expand Down Expand Up @@ -2437,6 +2438,7 @@ ripe.Ripe.prototype._importOrder = function(ffOrderId, options = {}) {
if (Object.keys(contents).length > 0) params.contents = JSON.stringify(contents);
if (dku) params.dku = dku;
if (type) params.type = type;
if (quantity) params.quantity = quantity;
if (country) params.country = country;
if (currency) params.currency = currency;
if (meta) params.meta = meta;
Expand Down
26 changes: 26 additions & 0 deletions test/js/api/order.js
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,32 @@ describe("OrderAPI", function() {

await remote.deleteOrderP(result.number);
});

it("should be able to set the quantity", async () => {
let result = null;

const remote = ripe.RipeAPI({ url: config.TEST_URL });
const ffOrderId = uuid.v4();

result = await remote.authAdminP(config.TEST_USERNAME, config.TEST_PASSWORD);

assert.strictEqual(result.username, config.TEST_USERNAME);
assert.notStrictEqual(typeof result.sid, undefined);

result = await remote.importOrderP(ffOrderId, {
type: "buildless",
brand: "dummy",
model: "dummy",
quantity: 22
});
assert.strictEqual(result.ff_order_id, ffOrderId);
assert.strictEqual(result.type, "buildless");
assert.strictEqual(result.brand, "dummy");
assert.strictEqual(result.shoe, "dummy");
assert.strictEqual(result.quantity, 22);

await remote.deleteOrderP(result.number);
});
});

describe("#preCustomization()", function() {
Expand Down

0 comments on commit 00717bd

Please sign in to comment.