Skip to content

Releases: BenMorganIO/solidus_json_api

Solidus JSON API 0.3.1

04 Feb 06:27
Compare
Choose a tag to compare
  • Bump Active Model Serializer from rc2 to rc4.

Ben A. Morgan

Solidus JSON API 0.3.0

24 Jan 12:53
Compare
Choose a tag to compare
  • Support status and code for Error Objects

When an error is handed back to the user, we now provide the status and the code keys. This adds another feature to the API that is supported by the JSON API specification.

  • Add Friendly ID Support for Spree::Product

When a request came in for /api/v2/products/example-product and there was a product in the DB with a corresponding slug, it would return a 404. The controller now calls Spree::Product.friendly before rendering any instance.

  • Drop Spree Support

After trying to get the spree support working, I’ve concluded that its just not worth it. I know there’s a lot of you out there that really want this. If you truly need to keep using Spree, please fork this repo and make the necessary changes.

  • The project has been renamed from spree_api_v2 to solidus_json_api. Since the Spree project is no longer maintained, then there's no reason to give Spree a second API version. This means that you need to update the following code:
### Before ###

# Gemfile
gem 'spree_api_v2'

# config/initializers/spree_api_v2.rb
SolidusApiV2.setup do |config|
  config.parent_serializer = ApplicationSerializer
end

### After ###

# Gemfile
gem 'solidus_json_api'

# config/initializers/solidus_json_api.rb
SolidusJsonApi.setup do |config|
  config.parent_serializer = ApplicationSerializer
end
  • In Spree, you will receive an error if the stock is not sufficient when updating a line item. This is done in this project since the API requires it. However, when transition to Solidus, we discovered that this feature was constrained to the complete state. We've added a validation check before saving a line item. Please open an issue if you believe this to be an anti-pattern.
  • Removed Spree::Order#considered_risky from the JSON response since Solidus doesn't support this anymore.
  • Spree::Variant#depth, Spree::Variant#width, and Spree::Variant#height now return null instead of "" when empty.
// Before
{
  "type" : "spree_variant",
  "data" : {
    "attributes" : {
      "depth" : "",
      "width" : "",
      "height" : "",
      ...
    }
  }
}

// After
{
  "type" : "spree_variant",
  "data" : {
    "attributes" : {
      "depth" : null,
      "width" : null,
      "height" : null,
      ...
    }
  }
}
  • Spree::LineItem#additional_tax_total and Spree::LineItem#adjustment_total now return as strings instead of floats in the api:
// Before
{
  "type" : "spree_line_item",
  "data" : {
    "attributes" : {
      "additional_tax_total" : 0,
      "adjustment_total" : 0.0,
      ...
    }
  }
}

// After
{
  "type" : "spree_line_item",
  "data" : {
    "attributes" : {
      "additional_tax_total" : "0",
      "adjustment_total" : "0.0",
      ...
    }
  }
}
  • For Orders, you can now list them. A user can only view their own orders. If the user is an admin, they can view all of the orders.
  • POST /api/v2/line_items now requires JSON API format instead of the rails format.
# Before
curl "https://example.com/api/v2/line_items"
  -X POST
  -d token=abc123
  -d line_item[order_id]=1
  -d line_item[variant_id]=1
  -d line_item[quantity]=1

# After
curl "https://example.com/api/v2/line_items"
  -X POST
  -d token=abc123
  -d data[attributes][order_id]=1
  -d data[attributes][variant_id]=1
  -d data[attributes][quantity]=1

Spree/Solidus API V2 0.2.2

30 Oct 22:04
Compare
Choose a tag to compare

0.2.2

  • The parent serializer for Spree::BaseSerializer is now configurable.
    In some instances, you may have an ApplicationSerializer.
    To make the Spree::BaseSerializer use an ApplicationSerializer instead
    of the ActiveModel::Serializer:
# config/initializers/spree_api_v2.rb; or
# config/initializers/solidus_api_v2.rb
SpreeApiV2.setup do |config|
  config.parent_serializer = ApplicationSerializer
end

Ben A. Morgan

Spree/Solidus API V2 0.2.1

17 Oct 22:35
Compare
Choose a tag to compare

Fixes an issue with the user serializer extending from the ActiveModel::Serializer instead of the Spree::BaseSerializer.

Spree/Solidus API V2

17 Oct 22:30
Compare
Choose a tag to compare

Initial Release of the Spree V2 API

23 Sep 00:42
Compare
Choose a tag to compare

There's still tons of work to do, but hey, why not get a 0.1 to code with?

This code is production ready and is being used over at Kabuni.

Sponsored by:

Kabuni