@plade/sdk
Advanced tools
Comparing version 0.0.24 to 0.0.25
@@ -126,3 +126,3 @@ 'use strict'; | ||
var version = "0.0.24"; | ||
var version = "0.0.25"; | ||
@@ -332,2 +332,46 @@ var LocalStorageFactory = | ||
} | ||
function buildSearchQueryParams(_ref2) { | ||
var queryBy = _ref2.queryBy, | ||
filterBy = _ref2.filterBy, | ||
sortBy = _ref2.sortBy, | ||
limit = _ref2.limit, | ||
excludeFields = _ref2.excludeFields, | ||
page = _ref2.page, | ||
highlightFields = _ref2.highlightFields, | ||
perPage = _ref2.perPage; | ||
var query = _objectSpread({}, queryBy ? { | ||
queryBy: Array.isArray(queryBy) ? queryBy.map(encode) : encode(queryBy) | ||
} : null, filterBy ? { | ||
filterBy: Array.isArray(filterBy) ? filterBy.map(encode) : encode(filterBy) | ||
} : null, excludeFields ? { | ||
excludeFields: Array.isArray(excludeFields) ? excludeFields.map(encode) : encode(excludeFields) | ||
} : null, highlightFields ? { | ||
highlightFields: Array.isArray(highlightFields) ? highlightFields.map(encode) : encode(highlightFields) | ||
} : null, sortBy ? { | ||
sortBy: Array.isArray(sortBy) ? sortBy.map(encode) : encode(sortBy) | ||
} : null, query ? { | ||
query: query | ||
} : null, limit ? { | ||
limit: limit | ||
} : null, page ? { | ||
page: page | ||
} : null, perPage ? { | ||
perPage: perPage | ||
} : null); | ||
return Object.keys(query).map(function (k) { | ||
return formatQueryString(k, query[k]); | ||
}).join('&'); | ||
} | ||
function buildSearchURL(collection, params) { | ||
if (params.query || params.queryBy || params.filterBy || params.sortBy || params.limit || params.page || params.perPage || params.highlightFields || params.excludeFields) { | ||
var paramsString = buildSearchQueryParams(params); | ||
return "".concat(collection, "?").concat(paramsString); | ||
} | ||
return endpoint; | ||
} | ||
function buildRequestBody(body) { | ||
@@ -1181,2 +1225,21 @@ var parsedBody; | ||
var SearchEndpoint = | ||
/*#__PURE__*/ | ||
function () { | ||
function SearchEndpoint() { | ||
_classCallCheck(this, SearchEndpoint); | ||
this.endpoint = 'search'; | ||
} | ||
_createClass(SearchEndpoint, [{ | ||
key: "search", | ||
value: function search(collection, query) { | ||
return this.request.send("".concat(this.endpoint, "/").concat(buildSearchURL(collection, query)), 'GET', null, this); | ||
} | ||
}]); | ||
return SearchEndpoint; | ||
}(); | ||
var AddressesEndpoint = | ||
@@ -1403,2 +1466,3 @@ /*#__PURE__*/ | ||
this.Products = new ProductsEndpoint(config); | ||
this.Search = new SearchEndpoint(config); | ||
this.Scopes = new ScopeEndpoint(config); | ||
@@ -1405,0 +1469,0 @@ this.Files = new FilesEndpoint(config); |
@@ -122,3 +122,3 @@ import { pluralize } from 'inflected'; | ||
var version = "0.0.24"; | ||
var version = "0.0.25"; | ||
@@ -328,2 +328,46 @@ var LocalStorageFactory = | ||
} | ||
function buildSearchQueryParams(_ref2) { | ||
var queryBy = _ref2.queryBy, | ||
filterBy = _ref2.filterBy, | ||
sortBy = _ref2.sortBy, | ||
limit = _ref2.limit, | ||
excludeFields = _ref2.excludeFields, | ||
page = _ref2.page, | ||
highlightFields = _ref2.highlightFields, | ||
perPage = _ref2.perPage; | ||
var query = _objectSpread({}, queryBy ? { | ||
queryBy: Array.isArray(queryBy) ? queryBy.map(encode) : encode(queryBy) | ||
} : null, filterBy ? { | ||
filterBy: Array.isArray(filterBy) ? filterBy.map(encode) : encode(filterBy) | ||
} : null, excludeFields ? { | ||
excludeFields: Array.isArray(excludeFields) ? excludeFields.map(encode) : encode(excludeFields) | ||
} : null, highlightFields ? { | ||
highlightFields: Array.isArray(highlightFields) ? highlightFields.map(encode) : encode(highlightFields) | ||
} : null, sortBy ? { | ||
sortBy: Array.isArray(sortBy) ? sortBy.map(encode) : encode(sortBy) | ||
} : null, query ? { | ||
query: query | ||
} : null, limit ? { | ||
limit: limit | ||
} : null, page ? { | ||
page: page | ||
} : null, perPage ? { | ||
perPage: perPage | ||
} : null); | ||
return Object.keys(query).map(function (k) { | ||
return formatQueryString(k, query[k]); | ||
}).join('&'); | ||
} | ||
function buildSearchURL(collection, params) { | ||
if (params.query || params.queryBy || params.filterBy || params.sortBy || params.limit || params.page || params.perPage || params.highlightFields || params.excludeFields) { | ||
var paramsString = buildSearchQueryParams(params); | ||
return "".concat(collection, "?").concat(paramsString); | ||
} | ||
return endpoint; | ||
} | ||
function buildRequestBody(body) { | ||
@@ -1177,2 +1221,21 @@ var parsedBody; | ||
var SearchEndpoint = | ||
/*#__PURE__*/ | ||
function () { | ||
function SearchEndpoint() { | ||
_classCallCheck(this, SearchEndpoint); | ||
this.endpoint = 'search'; | ||
} | ||
_createClass(SearchEndpoint, [{ | ||
key: "search", | ||
value: function search(collection, query) { | ||
return this.request.send("".concat(this.endpoint, "/").concat(buildSearchURL(collection, query)), 'GET', null, this); | ||
} | ||
}]); | ||
return SearchEndpoint; | ||
}(); | ||
var AddressesEndpoint = | ||
@@ -1399,2 +1462,3 @@ /*#__PURE__*/ | ||
this.Products = new ProductsEndpoint(config); | ||
this.Search = new SearchEndpoint(config); | ||
this.Scopes = new ScopeEndpoint(config); | ||
@@ -1401,0 +1465,0 @@ this.Files = new FilesEndpoint(config); |
@@ -124,3 +124,3 @@ (function (global, factory) { | ||
var version = "0.0.24"; | ||
var version = "0.0.25"; | ||
@@ -704,2 +704,46 @@ var LocalStorageFactory = | ||
} | ||
function buildSearchQueryParams(_ref2) { | ||
var queryBy = _ref2.queryBy, | ||
filterBy = _ref2.filterBy, | ||
sortBy = _ref2.sortBy, | ||
limit = _ref2.limit, | ||
excludeFields = _ref2.excludeFields, | ||
page = _ref2.page, | ||
highlightFields = _ref2.highlightFields, | ||
perPage = _ref2.perPage; | ||
var query = _objectSpread({}, queryBy ? { | ||
queryBy: Array.isArray(queryBy) ? queryBy.map(encode) : encode(queryBy) | ||
} : null, filterBy ? { | ||
filterBy: Array.isArray(filterBy) ? filterBy.map(encode) : encode(filterBy) | ||
} : null, excludeFields ? { | ||
excludeFields: Array.isArray(excludeFields) ? excludeFields.map(encode) : encode(excludeFields) | ||
} : null, highlightFields ? { | ||
highlightFields: Array.isArray(highlightFields) ? highlightFields.map(encode) : encode(highlightFields) | ||
} : null, sortBy ? { | ||
sortBy: Array.isArray(sortBy) ? sortBy.map(encode) : encode(sortBy) | ||
} : null, query ? { | ||
query: query | ||
} : null, limit ? { | ||
limit: limit | ||
} : null, page ? { | ||
page: page | ||
} : null, perPage ? { | ||
perPage: perPage | ||
} : null); | ||
return Object.keys(query).map(function (k) { | ||
return formatQueryString(k, query[k]); | ||
}).join('&'); | ||
} | ||
function buildSearchURL(collection, params) { | ||
if (params.query || params.queryBy || params.filterBy || params.sortBy || params.limit || params.page || params.perPage || params.highlightFields || params.excludeFields) { | ||
var paramsString = buildSearchQueryParams(params); | ||
return "".concat(collection, "?").concat(paramsString); | ||
} | ||
return endpoint; | ||
} | ||
function buildRequestBody(body) { | ||
@@ -1553,2 +1597,21 @@ var parsedBody; | ||
var SearchEndpoint = | ||
/*#__PURE__*/ | ||
function () { | ||
function SearchEndpoint() { | ||
_classCallCheck(this, SearchEndpoint); | ||
this.endpoint = 'search'; | ||
} | ||
_createClass(SearchEndpoint, [{ | ||
key: "search", | ||
value: function search(collection, query) { | ||
return this.request.send("".concat(this.endpoint, "/").concat(buildSearchURL(collection, query)), 'GET', null, this); | ||
} | ||
}]); | ||
return SearchEndpoint; | ||
}(); | ||
var AddressesEndpoint = | ||
@@ -1775,2 +1838,3 @@ /*#__PURE__*/ | ||
this.Products = new ProductsEndpoint(config); | ||
this.Search = new SearchEndpoint(config); | ||
this.Scopes = new ScopeEndpoint(config); | ||
@@ -1777,0 +1841,0 @@ this.Files = new FilesEndpoint(config); |
{ | ||
"name": "@plade/sdk", | ||
"description": "SDK for the Plade API", | ||
"version": "0.0.24", | ||
"version": "0.0.25", | ||
"homepage": "https://gitlab.com/plade/sdks/js", | ||
@@ -6,0 +6,0 @@ "author": "Plade (https://plade.io)", |
@@ -19,2 +19,3 @@ export as namespace plade | ||
Scopes: plade.ScopesEndpoint; | ||
Search: plade.SearchEndpoint; | ||
Transactions: plade.TransactionsEndpoint; | ||
@@ -43,11 +44,23 @@ | ||
export interface ConfigOptions { | ||
application?: string | ||
clientId: string | ||
clientSecret?: string | ||
currency?: string | ||
host?: string | ||
protocol?: string | ||
version?: string | ||
application?: string; | ||
clientId: string; | ||
clientSecret?: string; | ||
currency?: string; | ||
host?: string; | ||
protocol?: string; | ||
version?: string; | ||
} | ||
export interface ISearchQuery { | ||
query: string; | ||
queryBy?: string[]; | ||
filterBy?: string[]; | ||
page: number; | ||
perPage: number; | ||
sortBy?: string[]; | ||
limit?: number; | ||
excludeFields?: string[]; | ||
highlightFields?: string[]; | ||
} | ||
export class Config { | ||
@@ -88,7 +101,7 @@ application?: string; | ||
export interface AuthenticateResponseBody { | ||
expires: number | ||
identifier: GrantType | ||
expiresIn: number | ||
accessToken: string | ||
tokenType: 'Bearer' | ||
expires: number; | ||
identifier: GrantType; | ||
expiresIn: number; | ||
accessToken: string; | ||
tokenType: 'Bearer'; | ||
} | ||
@@ -229,2 +242,8 @@ | ||
export class SearchEndpoint { | ||
endpoint: 'search'; | ||
search<ResponseBody = any>(collection: string, query: ISearchQuery): Promise<ResponseBody> | ||
} | ||
export class OrdersEndpoint extends BaseExtend { | ||
@@ -294,13 +313,13 @@ endpoint: 'orders'; | ||
interface ScopeField { | ||
name: string | ||
type: fieldType | ||
required?: boolean | ||
unique?: boolean | ||
default?: any | ||
enum?: any[] | ||
min?: number | ||
max?: number | ||
minLength?: number | ||
maxLength?: number | ||
relative?: string | ||
name: string; | ||
type: fieldType; | ||
required?: boolean; | ||
unique?: boolean; | ||
default?: any; | ||
enum?: any[]; | ||
min?: number; | ||
max?: number; | ||
minLength?: number; | ||
maxLength?: number; | ||
relative?: string; | ||
} | ||
@@ -371,28 +390,28 @@ | ||
export interface CheckoutCustomer { | ||
id: string | ||
id: string; | ||
} | ||
export interface CheckoutCustomerObject { | ||
email: string | ||
name: string | ||
email: string; | ||
name: string; | ||
} | ||
export interface Address { | ||
name: string | ||
companyName?: string | ||
line1: string | ||
line2?: string | ||
city: string | ||
county: string | ||
country: string | ||
threeWords?: string | ||
phoneNumber: string | ||
instructions?: string | ||
name: string; | ||
companyName?: string; | ||
line1: string; | ||
line2?: string; | ||
city: string; | ||
county: string; | ||
country: string; | ||
threeWords?: string; | ||
phoneNumber: string; | ||
instructions?: string; | ||
} | ||
export interface ItemTaxObject { | ||
name: string | ||
jurisdiction: string | ||
code: string | ||
rate: number | ||
name: string; | ||
jurisdiction: string; | ||
code: string; | ||
rate: number; | ||
} | ||
@@ -399,0 +418,0 @@ |
158537
4523