Releases: BenMorganIO/solidus_json_api
Solidus JSON API 0.3.1
- Bump Active Model Serializer from rc2 to rc4.
Solidus JSON API 0.3.0
- Support
statusandcodefor 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_v2tosolidus_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_riskyfrom the JSON response since Solidus doesn't support this anymore. Spree::Variant#depth,Spree::Variant#width, andSpree::Variant#heightnow returnnullinstead 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_totalandSpree::LineItem#adjustment_totalnow 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_itemsnow 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]=1Spree/Solidus API V2 0.2.2
0.2.2
- The parent serializer for
Spree::BaseSerializeris now configurable.
In some instances, you may have anApplicationSerializer.
To make theSpree::BaseSerializeruse anApplicationSerializerinstead
of theActiveModel::Serializer:
# config/initializers/spree_api_v2.rb; or
# config/initializers/solidus_api_v2.rb
SpreeApiV2.setup do |config|
config.parent_serializer = ApplicationSerializer
endSpree/Solidus API V2 0.2.1
Fixes an issue with the user serializer extending from the ActiveModel::Serializer instead of the Spree::BaseSerializer.
Spree/Solidus API V2
Please see the Changelog for more information: https://github.com/spree-contrib/spree_api_v2/blob/master/CHANGELOG.md#020
Initial Release of the Spree V2 API
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.
