lightrail-client
Advanced tools
Comparing version 2.0.17 to 2.0.18
import { LightrailResponse } from "../LightrailResponse"; | ||
import { Contact } from "../../model"; | ||
export interface GetContactParams { | ||
} | ||
export interface GetContactResponse extends LightrailResponse<Contact> { | ||
} |
import { LightrailResponse } from "../LightrailResponse"; | ||
import { Success } from "../../model/Success"; | ||
export interface DeleteProgramParams { | ||
programId: string; | ||
} | ||
export interface DeleteProgramResponse extends LightrailResponse<Success> { | ||
} |
import { LightrailResponse } from "../LightrailResponse"; | ||
import { Program } from "../../model"; | ||
export interface GetProgramParams { | ||
programId: string; | ||
} | ||
export interface GetProgramResponse extends LightrailResponse<Program> { | ||
} |
@@ -6,3 +6,3 @@ import { RedemptionRule } from "../../../model/RedemptionRule"; | ||
import { Issuance } from "../../../model/Issuance"; | ||
export interface CreateIssuanceValues { | ||
export interface CreateIssuanceParams { | ||
id: string; | ||
@@ -23,7 +23,3 @@ count: number; | ||
} | ||
export interface CreateIssuanceParams { | ||
programId: string; | ||
values: CreateIssuanceValues; | ||
} | ||
export interface CreateIssuanceResponse extends LightrailResponse<Issuance> { | ||
} |
import { LightrailResponse } from "../../LightrailResponse"; | ||
import { Issuance } from "../../../model/Issuance"; | ||
export interface GetIssuanceParams { | ||
programId: string; | ||
issuanceId: string; | ||
} | ||
export interface GetIssuanceResponse extends LightrailResponse<Issuance> { | ||
} |
import { PaginatedLightrailResponse } from "../../LightrailResponse"; | ||
import { Issuance } from "../../../model/Issuance"; | ||
import { PaginationParams } from "../../PaginationParams"; | ||
export interface ListIssuancesParams { | ||
programId: string; | ||
options?: PaginationParams; | ||
export interface ListIssuancesParams extends PaginationParams { | ||
} | ||
export interface ListIssuancesResponse extends PaginatedLightrailResponse<Issuance[]> { | ||
} |
import { Program } from "../../model"; | ||
import { LightrailResponse } from "../LightrailResponse"; | ||
export interface UpdateProgramValues { | ||
export interface UpdateProgramParams { | ||
name?: string; | ||
@@ -16,7 +16,3 @@ active?: boolean; | ||
} | ||
export interface UpdateProgramParams { | ||
programId: string; | ||
values: UpdateProgramValues; | ||
} | ||
export interface UpdateProgramResponse extends LightrailResponse<Program> { | ||
} |
import { LightrailResponse } from "../LightrailResponse"; | ||
import { Value } from "../../model/Value"; | ||
export interface ChangeValuesCodeValues { | ||
export interface ChangeValuesCodeParams { | ||
code: string; | ||
} | ||
export interface ChangeValuesCodeParams { | ||
valueId: string; | ||
values?: ChangeValuesCodeValues; | ||
} | ||
export interface ChangeValuesCodeResponse extends LightrailResponse<Value> { | ||
} |
import { LightrailResponse } from "../LightrailResponse"; | ||
import { Success } from "../../model/Success"; | ||
export interface DeleteValueParams { | ||
valueId: string; | ||
} | ||
export interface DeleteValueResponse extends LightrailResponse<Success> { | ||
} |
import { LightrailResponse } from "../LightrailResponse"; | ||
import { Value } from "../../model/Value"; | ||
export interface GetValueOptions { | ||
export interface GetValueParams { | ||
showCode?: boolean; | ||
} | ||
export interface GetValueParams { | ||
valueId: string; | ||
options?: GetValueOptions; | ||
} | ||
export interface GetValueResponse extends LightrailResponse<Value> { | ||
} |
@@ -5,3 +5,4 @@ import { PaginatedLightrailResponse } from "../LightrailResponse"; | ||
import { PaginationParams } from "../PaginationParams"; | ||
export interface ListValuesOptions extends PaginationParams { | ||
export interface ListValuesParams extends PaginationParams { | ||
csv?: string; | ||
issuanceId?: string; | ||
@@ -25,7 +26,3 @@ showCode?: boolean; | ||
} | ||
export interface ListValuesParams extends PaginationParams { | ||
getCSV?: string; | ||
options?: ListValuesOptions; | ||
} | ||
export interface ListValuesResponse extends PaginatedLightrailResponse<Array<Value>> { | ||
} |
@@ -5,3 +5,3 @@ import { LightrailResponse } from "../LightrailResponse"; | ||
import { RedemptionRule } from "../../model/RedemptionRule"; | ||
export interface UpdateValueValues { | ||
export interface UpdateValueParams { | ||
contactId?: string; | ||
@@ -21,7 +21,3 @@ preTax?: boolean; | ||
} | ||
export interface UpdateValueParams { | ||
valueId: string; | ||
values: UpdateValueValues; | ||
} | ||
export interface UpdateValueResponse extends LightrailResponse<Value> { | ||
} |
@@ -1,2 +0,2 @@ | ||
import { DeleteProgramParams, GetProgramParams, ListProgramsParams, ListProgramsResponse } from "./params"; | ||
import { ListProgramsParams, ListProgramsResponse } from "./params"; | ||
import { CreateProgramParams, CreateProgramResponse } from "./params/programs/CreateProgramParams"; | ||
@@ -9,12 +9,12 @@ import { DeleteProgramResponse } from "./params/programs/DeleteProgramParams"; | ||
import { ListIssuancesParams, ListIssuancesResponse } from "./params/programs/issuance/ListIssuancesParams"; | ||
import { GetIssuanceParams, GetIssuanceResponse } from "./params/programs/issuance/GetIssuanceParams"; | ||
import { GetIssuanceResponse } from "./params/programs/issuance/GetIssuanceParams"; | ||
import { Issuance } from "./model/Issuance"; | ||
export declare function createProgram(params: CreateProgramParams): Promise<CreateProgramResponse>; | ||
export declare function listPrograms(params?: ListProgramsParams): Promise<ListProgramsResponse>; | ||
export declare function getProgram(params: GetProgramParams): Promise<GetProgramResponse>; | ||
export declare function updateProgram(params: UpdateProgramParams): Promise<UpdateProgramResponse>; | ||
export declare function deleteProgram(params: DeleteProgramParams): Promise<DeleteProgramResponse>; | ||
export declare function createIssuance(params: CreateIssuanceParams): Promise<CreateIssuanceResponse>; | ||
export declare function listIssuances(params: ListIssuancesParams): Promise<ListIssuancesResponse>; | ||
export declare function getIssuance(params: GetIssuanceParams): Promise<GetIssuanceResponse>; | ||
export declare function getProgram(program: string | Program): Promise<GetProgramResponse>; | ||
export declare function updateProgram(program: string | Program, params: UpdateProgramParams): Promise<UpdateProgramResponse>; | ||
export declare function deleteProgram(program: string | Program): Promise<DeleteProgramResponse>; | ||
export declare function createIssuance(program: string | Program, params: CreateIssuanceParams): Promise<CreateIssuanceResponse>; | ||
export declare function listIssuances(program: string | Program, params?: ListIssuancesParams): Promise<ListIssuancesResponse>; | ||
export declare function getIssuance(program: string | Program, issuance: string | Issuance): Promise<GetIssuanceResponse>; | ||
/** | ||
@@ -21,0 +21,0 @@ * Get programId from the string (as the ID itself) or Program object. |
@@ -42,5 +42,6 @@ "use strict"; | ||
exports.listPrograms = listPrograms; | ||
function getProgram(params) { | ||
function getProgram(program) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const resp = yield lightrail.request("GET", `programs/${encodeURIComponent(params.programId)}`); | ||
const programId = getProgramId(program); | ||
const resp = yield lightrail.request("GET", `programs/${encodeURIComponent(programId)}`); | ||
if (resp.status === 200) { | ||
@@ -57,11 +58,9 @@ return requestUtils_1.formatResponse(resp); | ||
// UPDATE | ||
function updateProgram(params) { | ||
function updateProgram(program, params) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const programId = getProgramId(program); | ||
if (!params) { | ||
throw new Error("params not set"); | ||
} | ||
else if (!params.programId) { | ||
throw new Error("programId in updateProgram({programId, params:{}}) is no set!"); | ||
} | ||
const resp = yield lightrail.request("PATCH", `programs/${encodeURIComponent(params.programId)}`).send(params.values); | ||
const resp = yield lightrail.request("PATCH", `programs/${encodeURIComponent(programId)}`).send(params); | ||
if (resp.status === 200) { | ||
@@ -78,8 +77,6 @@ return requestUtils_1.formatResponse(resp); | ||
// DELETE | ||
function deleteProgram(params) { | ||
function deleteProgram(program) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
if (!params || !params.programId) { | ||
throw new Error("programId missing in deleteProgram({programId}) is not set!"); | ||
} | ||
const resp = yield lightrail.request("DELETE", `programs/${encodeURIComponent(params.programId)}`); | ||
const programId = getProgramId(program); | ||
const resp = yield lightrail.request("DELETE", `programs/${encodeURIComponent(programId)}`); | ||
if (resp.status === 200) { | ||
@@ -98,17 +95,12 @@ return requestUtils_1.formatResponse(resp); | ||
// CREATE | ||
function createIssuance(params) { | ||
function createIssuance(program, params) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const programId = getProgramId(program); | ||
if (!params) { | ||
throw new Error("createIssuance({programId, params:{}}) param object not set"); | ||
throw new Error("createIssuance(p) params not set"); | ||
} | ||
else if (!params.programId) { | ||
throw new Error("programId in createIssuance({programId, params:{}}) is no set!"); | ||
} | ||
else if (!params.values) { | ||
throw new Error("params in createIssuance({programId, params:{}}) is no set!"); | ||
} | ||
else { | ||
requestUtils_1.validateRequiredParams(["id"], params.values); | ||
requestUtils_1.validateRequiredParams(["id"], params); | ||
} | ||
const resp = yield lightrail.request("POST", `programs/${encodeURIComponent(params.programId)}/issuances`).send(params.values); | ||
const resp = yield lightrail.request("POST", `programs/${encodeURIComponent(programId)}/issuances`).send(params); | ||
if (resp.status === 200 || resp.status === 201) { | ||
@@ -122,8 +114,6 @@ return requestUtils_1.formatResponse(resp); | ||
// READ | ||
function listIssuances(params) { | ||
function listIssuances(program, params) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
if (!params.programId) { | ||
throw new Error("programId in listIssuances({programId}) is no set!"); | ||
} | ||
const resp = yield lightrail.request("GET", `programs/${encodeURIComponent(params.programId)}/issuances`).query(params.options); | ||
const programId = getProgramId(program); | ||
const resp = yield lightrail.request("GET", `programs/${encodeURIComponent(programId)}/issuances`).query(params); | ||
if (resp.status === 200) { | ||
@@ -136,11 +126,10 @@ return requestUtils_1.formatResponse(resp); | ||
exports.listIssuances = listIssuances; | ||
function getIssuance(params) { | ||
function getIssuance(program, issuance) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
if (!params.programId) { | ||
throw new Error("programId in getIssuance({programId, issuanceId}) is no set!"); | ||
const programId = getProgramId(program); | ||
const issuanceId = getIssuanceId(issuance); | ||
if (!issuanceId) { | ||
throw new Error("issuanceId in getIssuance(program, issuanceId) is no set!"); | ||
} | ||
if (!params.issuanceId) { | ||
throw new Error("issuanceId in getIssuance({programId, issuanceId}) is no set!"); | ||
} | ||
const resp = yield lightrail.request("GET", `programs/${encodeURIComponent(params.programId)}/issuances/${encodeURIComponent(params.issuanceId)}`); | ||
const resp = yield lightrail.request("GET", `programs/${encodeURIComponent(programId)}/issuances/${encodeURIComponent(issuanceId)}`); | ||
if (resp.status === 200) { | ||
@@ -147,0 +136,0 @@ return requestUtils_1.formatResponse(resp); |
@@ -7,9 +7,9 @@ import { CreateValueParams, CreateValueRespone } from "./params/values/CreateValueParams"; | ||
import { ChangeValuesCodeParams, ChangeValuesCodeResponse } from "./params/values/ChangeValuesCodeParams"; | ||
import { DeleteValueParams, DeleteValueResponse } from "./params/values/DeleteValueParams"; | ||
import { DeleteValueResponse } from "./params/values/DeleteValueParams"; | ||
export declare function createValue(params: CreateValueParams): Promise<CreateValueRespone>; | ||
export declare function listValues(params?: ListValuesParams): Promise<ListValuesResponse>; | ||
export declare function getValue(params?: GetValueParams): Promise<GetValueResponse>; | ||
export declare function updateValue(params: UpdateValueParams): Promise<UpdateValueResponse>; | ||
export declare function changeValuesCode(params: ChangeValuesCodeParams): Promise<ChangeValuesCodeResponse>; | ||
export declare function deleteValue(params: DeleteValueParams): Promise<DeleteValueResponse>; | ||
export declare function getValue(value: string | Value, params?: GetValueParams): Promise<GetValueResponse>; | ||
export declare function updateValue(value: string | Value, params: UpdateValueParams): Promise<UpdateValueResponse>; | ||
export declare function changeValuesCode(value: string | Value, params: ChangeValuesCodeParams): Promise<ChangeValuesCodeResponse>; | ||
export declare function deleteValue(value: string | Value): Promise<DeleteValueResponse>; | ||
/** | ||
@@ -16,0 +16,0 @@ * Get contactId from the string (as the ID itself) or Contact object. |
@@ -34,3 +34,3 @@ "use strict"; | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const resp = yield lightrail.request("GET", "values").set("accept", (!!params && !!params.getCSV) ? "text/csv" : "application/json").query(requestUtils_1.formatFilterParams(params)); | ||
const resp = yield lightrail.request("GET", "values").set("accept", (!!params && !!params.csv) ? "text/csv" : "application/json").query(requestUtils_1.formatFilterParams(params)); | ||
if (resp.status === 200) { | ||
@@ -43,5 +43,6 @@ return (requestUtils_1.formatResponse(resp)); | ||
exports.listValues = listValues; | ||
function getValue(params) { | ||
function getValue(value, params) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const resp = yield lightrail.request("GET", `values/${encodeURIComponent(params.valueId)}`).query(params.options); | ||
const valueId = getValueId(value); | ||
const resp = yield lightrail.request("GET", `values/${encodeURIComponent(valueId)}`).query(params); | ||
if (resp.status === 200) { | ||
@@ -58,5 +59,6 @@ return (requestUtils_1.formatResponse(resp)); | ||
// UPDATE | ||
function updateValue(params) { | ||
function updateValue(value, params) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const resp = yield lightrail.request("PATCH", `values/${encodeURIComponent(params.valueId)}`).send(params.values); | ||
const valueId = getValueId(value); | ||
const resp = yield lightrail.request("PATCH", `values/${encodeURIComponent(valueId)}`).send(params); | ||
if (resp.status === 200) { | ||
@@ -72,5 +74,6 @@ return (requestUtils_1.formatResponse(resp)); | ||
exports.updateValue = updateValue; | ||
function changeValuesCode(params) { | ||
function changeValuesCode(value, params) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const resp = yield lightrail.request("POST", `values/${encodeURIComponent(params.valueId)}/changeCode`).send(params.values); | ||
const valueId = getValueId(value); | ||
const resp = yield lightrail.request("POST", `values/${encodeURIComponent(valueId)}/changeCode`).send(params); | ||
if (resp.status === 200) { | ||
@@ -87,5 +90,6 @@ return (requestUtils_1.formatResponse(resp)); | ||
// DELETE | ||
function deleteValue(params) { | ||
function deleteValue(value) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const resp = yield lightrail.request("DELETE", `values/${encodeURIComponent(params.valueId)}`); | ||
const valueId = getValueId(value); | ||
const resp = yield lightrail.request("DELETE", `values/${encodeURIComponent(valueId)}`); | ||
if (resp.status === 200) { | ||
@@ -92,0 +96,0 @@ return (requestUtils_1.formatResponse(resp)); |
{ | ||
"name": "lightrail-client", | ||
"version": "2.0.17", | ||
"version": "2.0.18", | ||
"description": "A Javascript and Typescript client for Lightrail", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
63751
1356