cloudesire.js v1.0.0
cloudesire.js
The official low-level ClouDesire client for Node.js and the browser.
Use in Node.js
Install via npm
npm install cloudesire.js --save
and use it
var CDClient = require('cloudesire.js')
var client = new CDClient()
var products = client.product.all()
Use in the Browser
Install via bower
bower install cloudesire.js --save
Include the library in your application
<script src="bower_components/cloudesire.js/lib/client.web.js"></script>
and use it
var client = cloudesire.Client()
var products = client.product.all()
API Usage
Options
Properties
PaginatedResponse
An array plus the the pagination properties
Properties
The
totalPages on the serverThe
pageSize of the current pageThe
totalItems number of the total pagesThe
pageNumber of the current page
Category
Extends BaseResource
Product
Extends BaseResource
Methods to retrieve and filter products
allByCategory
Retrieve products filtered by category
Parameters
category
Number id of the categoryoptions
Options= the options to pass to the request (optional, default{}
)
Examples
var client = new cloudesire.Client()
var productOfCategory2 = client.product.allByCategory(2, {pageSize: 5, pageNumber: 1})
Returns PaginatedResponse the list of products retrieved
allByCategoryAndFeatured
Retrieve featured products filtered by category
Parameters
category
Number id of the categoryoptions
Options= the options to pass to the request (optional, default{}
)
Examples
var client = new cloudesire.Client()
var featuredProductsOfCategory5 = client.product.allByCategoryAndFeatured(5)
Returns PaginatedResponse the list of products retrieved
allByNameOrVendorName
Retrieve all the products filtered by name or by vendor name
Parameters
name
String the name of the product or the vendoroptions
Options= the options to pass to the request (optional, default{}
)
Examples
var client = new cloudesire.Client()
var productsByCloudesire = client.product.allByNameOrVendorName('cloudesire')
var wordpressProducts = client.product.allByNameOrVendorName('wordpress')
Returns PaginatedResponse the list of products retrieved
allFeatured
Retrieve all the featured products
Parameters
options
Options= the options to pass to the request (optional, default{}
)
Examples
var client = new cloudesire.Client()
var featuredProducts = client.product.allFeatured({pageSize: 50, pageNumber: 2})
Returns PaginatedResponse the list of products retrieved
allOwned
Retrieve all the owned products
Parameters
options
Options= the options to pass to the request (optional, default{}
)
Examples
var client = new cloudesire.Client()
var mineProducts = client.product.allOwned()
Returns PaginatedResponse the list of products retrieved
searchAndSort
Search products by parts of the name, category, tags and sort results by top sold or top tried
Parameters
name
String= the part of the name of the product (optional, default'%'
)category
Number= id of the category (optional, defaultundefined
)tag
String= tag of the product (optional, defaultundefined
)ordering
String= can beTOPTRIED
orTOPSOLD
(optional, defaultundefined
)options
Options= the options to pass to the request
Examples
var client = new cloudesire.Client()
var productsThatContainsGAME = client.product.searchAndSort('game')
var productsThatContainsGAMEInCategory10 = client.product.searchAndSort('game', 10)
var productsInCategory5TaggedWithOPEN_SOURCE = client.product.searchAndSort(null, 10, 'OPEN_SOURCE')
var secondPageOfAllProductsOrderedByTopTried = client.product.searchAndSort(null, null, null, 'TOPTRIED', {pageNumber: 2})
Returns PaginatedResponse The result of the search
ProductVersion
Extends BaseResource
Methods to retrieve and filter products versions
ofProduct
Retrieve all the versions that belongs to a product
Parameters
id
Number=(default this.mandatory('id')) the id the productoptions
Options= (optional, default{}
)
Examples
var client = new cloudesire.Client()
var productVersions = client.productVersion.ofProduct(5)
Returns PaginatedResponse the list of product versions retrieved
BaseResource
Commons methods to all the resources
all
Retrieve a list of resources
Parameters
options
Options= (optional, default{}
)queryParams
Object= query parameters object (optional, default{}
)
Examples
var client = new cloudesire.Client()
var products = client.product.all({pageSize: 5, pageNumber: 1})
var currentPage = products.pageNumber
var totalPages = products.totalPages
var categories = client.category.all()
Returns PaginatedResponse the list of JSON repesentation of the objects retrieved
one
Retrieve a single resource
Parameters
Examples
var client = new cloudesire.Client()
var product = client.product.one(10, {featured: true})
Returns Object the JSON repesentation of the object retrieved
8 years ago