-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #30 from mathewmeconry/feature/v3_jwt
Adds Items/Article endpoint
- Loading branch information
Showing
5 changed files
with
184 additions
and
120 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
export namespace ItemsStatic { | ||
export interface Item { | ||
id: number; | ||
user_id: number; | ||
article_type_id: number; | ||
contact_id: number; | ||
deliverer_code?: string; | ||
deliverer_name?: string; | ||
deliverer_description?: string; | ||
intern_code: string; | ||
intern_name: string; | ||
intern_description?: string; | ||
purchase_price?: number; | ||
sale_price?: number; | ||
purchase_total?: number; | ||
sale_total?: number; | ||
currency_id?: number; | ||
tax_income_id?: number; | ||
tax_id?: number; | ||
tax_expense_id?: number; | ||
unit_id?: number; | ||
is_stock: boolean; | ||
stock_id?: number; | ||
stock_place_id?: number; | ||
stock_nr: number; | ||
stock_min_nr: number; | ||
stock_reserved_nr: number; | ||
stock_available_nr: number; | ||
stock_picked_nr: number; | ||
stock_disposed_nr: number; | ||
stock_ordered_nr: number; | ||
width?: number; | ||
height?: number; | ||
weight?: number; | ||
volume?: number; | ||
html_text?: string; | ||
remarks?: string; | ||
delivery_price?: number; | ||
article_group_id?: number; | ||
} | ||
|
||
export interface ItemCreate { | ||
user_id: number; | ||
article_type_id: number; | ||
contact_id: number; | ||
deliverer_code?: string; | ||
deliverer_name?: string; | ||
deliverer_description?: string; | ||
intern_code: string; | ||
intern_name: string; | ||
intern_description?: string; | ||
purchase_price?: number; | ||
sale_price?: number; | ||
purchase_total?: number; | ||
sale_total?: number; | ||
currency_id?: number; | ||
tax_income_id?: number; | ||
tax_id?: number; | ||
tax_expense_id?: number; | ||
unit_id?: number; | ||
is_stock: boolean; | ||
stock_id?: number; | ||
stock_place_id?: number; | ||
stock_nr: number; | ||
stock_min_nr: number; | ||
stock_reserved_nr: number; | ||
stock_available_nr: number; | ||
stock_picked_nr: number; | ||
stock_disposed_nr: number; | ||
stock_ordered_nr: number; | ||
width?: number; | ||
height?: number; | ||
weight?: number; | ||
volume?: number; | ||
html_text?: string; | ||
remarks?: string; | ||
delivery_price?: number; | ||
article_group_id?: number; | ||
} | ||
|
||
export interface ItemOverwrite extends ItemCreate {} | ||
|
||
export enum ItemSearchParameters { | ||
id = "id", | ||
user_id = "user_id", | ||
article_type_id = "article_type_id", | ||
contact_id = "contact_id", | ||
deliverer_code = "deliverer_code", | ||
deliverer_name = "deliverer_name", | ||
deliverer_description = "deliverer_description", | ||
intern_code = "intern_code", | ||
intern_name = "intern_name", | ||
intern_description = "intern_description", | ||
purchase_price = "purchase_price", | ||
sale_price = "sale_price", | ||
purchase_total = "purchase_total", | ||
sale_total = "sale_total", | ||
currency_id = "currency_id", | ||
tax_income_id = "tax_income_id", | ||
tax_id = "tax_id", | ||
tax_expense_id = "tax_expense_id", | ||
unit_id = "unit_id", | ||
is_stock = "is_stock", | ||
stock_id = "stock_id", | ||
stock_place_id = "stock_place_id", | ||
stock_nr = "stock_nr", | ||
stock_min_nr = "stock_min_nr", | ||
stock_reserved_nr = "stock_reserved_nr", | ||
stock_available_nr = "stock_available_nr", | ||
stock_picked_nr = "stock_picked_nr", | ||
stock_disposed_nr = "stock_disposed_nr", | ||
stock_ordered_nr = "stock_ordered_nr", | ||
width = "width", | ||
height = "height", | ||
weight = "weight", | ||
volume = "volume", | ||
html_text = "html_text", | ||
remarks = "remarks", | ||
delivery_price = "delivery_price", | ||
article_group_id = "article_group_id", | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { ItemsStatic } from "../interfaces/ItemsStatic"; | ||
import BaseCrud from "./BaseCrud"; | ||
|
||
export default class Items extends BaseCrud< | ||
ItemsStatic.Item, | ||
ItemsStatic.Item, | ||
ItemsStatic.Item, | ||
ItemsStatic.ItemSearchParameters, | ||
ItemsStatic.ItemCreate, | ||
ItemsStatic.ItemOverwrite | ||
> { | ||
constructor(apiToken: string) { | ||
super(apiToken, "/article"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import BaseCrud from "../resources/BaseCrud"; | ||
import { mocked } from "ts-jest/utils"; | ||
import Chance from "chance"; | ||
import Items from "../resources/Items"; | ||
|
||
jest.mock("../resources/BaseCrud"); | ||
const mockedBase = mocked(BaseCrud, true); | ||
|
||
const seedgenerator = new Chance(); | ||
const seed = seedgenerator.hash(); | ||
console.log(`using chance seed ${seed}`); | ||
const chance = new Chance(seed); | ||
|
||
describe("Items", () => { | ||
it("Should use init the base correctly", () => { | ||
const token = chance.string(); | ||
new Items(token); | ||
expect(mockedBase).toHaveBeenCalledWith(token, "/article"); | ||
}); | ||
}); |