npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

spree-frontend-integration

v1.0.3

Published

This is a JS API to integrate with spree

Downloads

9

Readme

Spree Frontend Integration

spree-frontend-integration is a JavaScript library which allows easy access to Spree API. It can be integrated with any frontend framework, or can also be used with simple JS.

Dependency

You need to install Spree AMS gem.

To access all endpoints add below line of code in your routes.rb.

namespace :api do
  match '*path' => 'ams/cors#preflight_check', via: [:options]
end

Installation

Node:

npm install --save spree-themes-integration

Bower:

bower install spree-themes-integration

You may need to use browserify to properly install the package in case of bower. You can take the help of the following tutorial

Configurations

Spree Frontend Integration Provides a number of configurations which allow you to customize the integration according to your needs.

| Option | Description | Example | --- | --- | --- | | domain | In case your your backend & frontend are on different servers you will need to use this option & pass your backend domain to the integration when invoking the class. | (new SpreeApi.productsList('www.vinsol.com')) | callback | To handle the response returned from the API, you need to pass a callback method, which will be invoked after successfull API call | (new SpreeApi.productsList('www.vinsol.com')).sendRequest({cb: myCallback}) | | path | If you don't want to use default path(relative URL to the backend domain) for any of the API call you can overide this option. | (new SpreeApi.productsList('www.vinsol.com')).sendRequest({path: '/api/xx/products' }) | | method | If you don't want to use default method. HTTP method to be used when hitting the API endpoint. | (new SpreeApi.productsList('www.vinsol.com')).sendRequest({method: 'GET' }) |

List of JS methods

SpreeApi.login

Use this method to login into Spree Backend. This methods needs to essential parameters email & password to successfully login. It actually saves token returned by Spree API to the cookie in encrypted form.

(new SpreeApi.login()).sendRequest({params: {
  users: {
    email: '[email protected]',
    password: 'spree123'
  }
}})

SpreeApi.signUp

Use this method to signUp into Spree Backend. This methods needs to essential parameters email & password to successfully create a new user.

(new SpreeApi.signUp()).sendRequest({params: {
  users: {
    email: '[email protected]',
    password: 'spree123'
  }
}})

SpreeApi.profile*

Use this method to get user details from Spree Backend.

(new SpreeApi.profile()).sendRequest({})

SpreeApi.productsList

Use this method to get a list of products from Spree Backend.

(new SpreeApi.productsList()).sendRequest({params:{ per_page: 25, page: 1}})

SpreeApi.productShow

Use this method to get details of a specific product from Spree Backend.

(new SpreeApi.productShow()).sendRequest({params:{ id: 1 }})
Note: here id is product id/slug.

SpreeApi.taxonsList

Use this method to get the taxon list from Spree Backend.

(new SpreeApi.taxonsList()).sendRequest({})

SpreeApi.taxonomyList

Use this method to get the taxonomy & taxons list from Spree Backend.

(new SpreeApi.taxonomyList()).sendRequest({})

SpreeApi.countryLists

Use this method to get a list of countries from Spree Backend.

(new SpreeApi.countryLists()).sendRequest({})

SpreeApi.statesList

Use this method to get a list of states for a specific country from Spree Backend.

(new SpreeApi.statesList()).sendRequest({params: { id: 1 }})
Note: here id is country_id

SpreeApi.optionTypesList

Use this method to get a list of option types from Spree Backend.

(new SpreeApi.optionTypesList()).sendRequest({})

SpreeApi.createOrder*

This method is to create a new order at Spree Backend and returns order response.

(new SpreeApi.createOrder()).sendRequest({})

SpreeApi.updateOrder*

This method is to update(Add a line item) a prevously created order at Spree Backend and returns order response.

(new SpreeApi.updateOrder()).sendRequest({})

SpreeApi.checkoutOrder*

This method should be used for checkout steps, with valid & complete information the order will be automatically proceeded to the next step. It returns the order response.

(new SpreeApi.checkoutOrder()).sendRequest({params: {
  id: 1,
  bill_address_attributes: {...},
  ship_address_attributes: {...},
  payments_attributes: {...},
  shipments_attributes: {...}
}})

SpreeApi.myOrders*

This method returns all completed orders of the loggedIn user.

(new SpreeApi.myOrders()).sendRequest({})

SpreeApi.currentOrder*

This method returns the current order in progress of the loggedIn user.

(new SpreeApi.currentOrder()).sendRequest({})

SpreeApi.emptyOrder*

This method removes all the line items from the current order.

(new SpreeApi.emptyOrder()).sendRequest({params: {id: 1}})

SpreeApi.deleteOrder*

This method deletes the current order.

(new SpreeApi.deleteOrder()).sendRequest({params: {id: 1}})

*= Login Required