Sha256: 0178fc6c91d399cc98856c1e8d71f2585d62a442ab26906a0529d629d90fafa0

Contents?: true

Size: 1.14 KB

Versions: 77

Compression:

Stored size: 1.14 KB

Contents

//= require spree

var SpreeAPI = {
  oauthToken: null, // user Bearer token to authorize operations for the given user
  orderToken: null // order token to authorize operations on current order (cart)
}

SpreeAPI.Storefront = {}
SpreeAPI.Platform = {}

// API routes
Spree.routes.api_v2_storefront_cart_create = Spree.pathFor('api/v2/storefront/cart')
Spree.routes.api_v2_storefront_cart_add_item = Spree.pathFor('api/v2/storefront/cart/add_item')
Spree.routes.api_v2_storefront_cart_apply_coupon_code = Spree.pathFor('api/v2/storefront/cart/apply_coupon_code')

// helpers
SpreeAPI.handle500error = function () {
  alert('Internal Server Error')
}

SpreeAPI.prepareHeaders = function (headers) {
  if (typeof headers === 'undefined') {
    headers = {}
  }

  // if signed in we need to pass the Bearer authorization token
  // so backend will recognize that actions are authorized in scope of this user
  if (SpreeAPI.oauthToken) {
    headers['Authorization'] = 'Bearer ' + SpreeAPI.oauthToken
  }

  // default headers, required for POST/PATCH/DELETE requests
  headers['Accept'] = 'application/json'
  headers['Content-Type'] = 'application/json'
  return headers
}

Version data entries

77 entries across 77 versions & 2 rubygems

Version Path
spree_api-4.2.3 app/assets/javascripts/spree/api/main.js
spree_api-4.2.2 app/assets/javascripts/spree/api/main.js
spree_api-4.2.1 app/assets/javascripts/spree/api/main.js
spree_api-4.0.7 app/assets/javascripts/spree/api/main.js
spree_api-3.7.14 app/assets/javascripts/spree/api/main.js
spree_api-4.2.0 app/assets/javascripts/spree/api/main.js
spree_api-4.2.0.rc5 app/assets/javascripts/spree/api/main.js
spree_api-4.2.0.rc4 app/assets/javascripts/spree/api/main.js
spree_api-4.2.0.rc3 app/assets/javascripts/spree/api/main.js
spree_api-4.1.13 app/assets/javascripts/spree/api/main.js
spree_api-4.0.6 app/assets/javascripts/spree/api/main.js
spree_api-4.2.0.rc2 app/assets/javascripts/spree/api/main.js
spree_api-3.7.13 app/assets/javascripts/spree/api/main.js
spree_api-4.0.5 app/assets/javascripts/spree/api/main.js
spree_api-4.1.12 app/assets/javascripts/spree/api/main.js
spree_api-3.7.12 app/assets/javascripts/spree/api/main.js
spree_api-4.2.0.rc1 app/assets/javascripts/spree/api/main.js
spree_api-4.0.4 app/assets/javascripts/spree/api/main.js
spree_api-3.7.11 app/assets/javascripts/spree/api/main.js
spree_api-4.1.11 app/assets/javascripts/spree/api/main.js