solidus_json_api 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (140) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +15 -0
  3. data/.rspec +2 -0
  4. data/CHANGELOG.md +224 -0
  5. data/Gemfile +6 -0
  6. data/LICENSE +26 -0
  7. data/README.md +94 -0
  8. data/Rakefile +38 -0
  9. data/app/controllers/concerns/spree/api/v2/renderable.rb +63 -0
  10. data/app/controllers/spree/api/v2/base_controller.rb +9 -0
  11. data/app/controllers/spree/api/v2/children_controller.rb +29 -0
  12. data/app/controllers/spree/api/v2/countries_controller.rb +21 -0
  13. data/app/controllers/spree/api/v2/images_controller.rb +29 -0
  14. data/app/controllers/spree/api/v2/line_items_controller.rb +36 -0
  15. data/app/controllers/spree/api/v2/option_types_controller.rb +31 -0
  16. data/app/controllers/spree/api/v2/option_values_controller.rb +29 -0
  17. data/app/controllers/spree/api/v2/orders_controller.rb +21 -0
  18. data/app/controllers/spree/api/v2/prices_controller.rb +27 -0
  19. data/app/controllers/spree/api/v2/products_controller.rb +37 -0
  20. data/app/controllers/spree/api/v2/states_controller.rb +29 -0
  21. data/app/controllers/spree/api/v2/taxonomies_controller.rb +21 -0
  22. data/app/controllers/spree/api/v2/taxons_controller.rb +40 -0
  23. data/app/controllers/spree/api/v2/variants_controller.rb +35 -0
  24. data/app/models/spree/base_decorator.rb +5 -0
  25. data/app/models/spree/image_decorator.rb +3 -0
  26. data/app/models/spree/line_item_decorator.rb +3 -0
  27. data/app/models/spree/order_decorator.rb +3 -0
  28. data/app/models/spree/price_decorator.rb +3 -0
  29. data/app/models/spree/state_decorator.rb +3 -0
  30. data/app/serializers/spree/address_serializer.rb +9 -0
  31. data/app/serializers/spree/base_serializer.rb +13 -0
  32. data/app/serializers/spree/country_serializer.rb +7 -0
  33. data/app/serializers/spree/error_serializer.rb +55 -0
  34. data/app/serializers/spree/image_serializer.rb +13 -0
  35. data/app/serializers/spree/line_item_serializer.rb +13 -0
  36. data/app/serializers/spree/option_type_serializer.rb +8 -0
  37. data/app/serializers/spree/option_value_serializer.rb +8 -0
  38. data/app/serializers/spree/order_serializer.rb +20 -0
  39. data/app/serializers/spree/price_serializer.rb +7 -0
  40. data/app/serializers/spree/product_serializer.rb +12 -0
  41. data/app/serializers/spree/role_serializer.rb +5 -0
  42. data/app/serializers/spree/state_serializer.rb +7 -0
  43. data/app/serializers/spree/store_serializer.rb +6 -0
  44. data/app/serializers/spree/taxon_serializer.rb +16 -0
  45. data/app/serializers/spree/taxonomy_serializer.rb +7 -0
  46. data/app/serializers/spree/user_serializer.rb +5 -0
  47. data/app/serializers/spree/variant_serializer.rb +12 -0
  48. data/circle.yml +12 -0
  49. data/config/locales/en.yml +25 -0
  50. data/config/routes.rb +53 -0
  51. data/docs/.nojekyll +0 -0
  52. data/docs/Dockerfile +12 -0
  53. data/docs/Gemfile +14 -0
  54. data/docs/README.md +12 -0
  55. data/docs/Rakefile +9 -0
  56. data/docs/config.rb +39 -0
  57. data/docs/font-selection.json +148 -0
  58. data/docs/source/CNAME +1 -0
  59. data/docs/source/fonts/slate.eot +0 -0
  60. data/docs/source/fonts/slate.svg +14 -0
  61. data/docs/source/fonts/slate.ttf +0 -0
  62. data/docs/source/fonts/slate.woff +0 -0
  63. data/docs/source/fonts/slate.woff2 +0 -0
  64. data/docs/source/images/favicon.ico +0 -0
  65. data/docs/source/images/navbar.png +0 -0
  66. data/docs/source/includes/_countries.md +133 -0
  67. data/docs/source/includes/_errors.md +17 -0
  68. data/docs/source/includes/_filtering.md +11 -0
  69. data/docs/source/includes/_images.md +201 -0
  70. data/docs/source/includes/_line_items.md +143 -0
  71. data/docs/source/includes/_option_types.md +267 -0
  72. data/docs/source/includes/_option_values.md +227 -0
  73. data/docs/source/includes/_orders.md +150 -0
  74. data/docs/source/includes/_pagination.md +10 -0
  75. data/docs/source/includes/_prices.md +188 -0
  76. data/docs/source/includes/_products.md +407 -0
  77. data/docs/source/includes/_states.md +96 -0
  78. data/docs/source/includes/_taxonomies.md +325 -0
  79. data/docs/source/includes/_taxons.md +414 -0
  80. data/docs/source/includes/_variants.md +430 -0
  81. data/docs/source/index.md +51 -0
  82. data/docs/source/javascripts/all.js +4 -0
  83. data/docs/source/javascripts/all_nosearch.js +3 -0
  84. data/docs/source/javascripts/app/_lang.js +162 -0
  85. data/docs/source/javascripts/app/_search.js +74 -0
  86. data/docs/source/javascripts/app/_toc.js +55 -0
  87. data/docs/source/javascripts/lib/_energize.js +169 -0
  88. data/docs/source/javascripts/lib/_imagesloaded.min.js +7 -0
  89. data/docs/source/javascripts/lib/_jquery.highlight.js +108 -0
  90. data/docs/source/javascripts/lib/_jquery.tocify.js +1042 -0
  91. data/docs/source/javascripts/lib/_jquery_ui.js +566 -0
  92. data/docs/source/javascripts/lib/_lunr.js +1910 -0
  93. data/docs/source/layouts/layout.erb +110 -0
  94. data/docs/source/stylesheets/_icon-font.scss +38 -0
  95. data/docs/source/stylesheets/_normalize.css +427 -0
  96. data/docs/source/stylesheets/_syntax.scss.erb +27 -0
  97. data/docs/source/stylesheets/_variables.scss +109 -0
  98. data/docs/source/stylesheets/print.css.scss +142 -0
  99. data/docs/source/stylesheets/screen.css.scss +622 -0
  100. data/lib/solidus_json_api/config.rb +8 -0
  101. data/lib/solidus_json_api/engine.rb +21 -0
  102. data/lib/solidus_json_api.rb +5 -0
  103. data/solidus_json_api.gemspec +36 -0
  104. data/spec/controllers/spree/api/v2/base_controller_spec.rb +46 -0
  105. data/spec/controllers/spree/api/v2/children_controller_spec.rb +28 -0
  106. data/spec/controllers/spree/api/v2/countries_controller_spec.rb +25 -0
  107. data/spec/controllers/spree/api/v2/images_controller_spec.rb +91 -0
  108. data/spec/controllers/spree/api/v2/line_items_controller_spec.rb +101 -0
  109. data/spec/controllers/spree/api/v2/option_types_controller_spec.rb +71 -0
  110. data/spec/controllers/spree/api/v2/option_values_controller_spec.rb +88 -0
  111. data/spec/controllers/spree/api/v2/orders_controller_spec.rb +61 -0
  112. data/spec/controllers/spree/api/v2/prices_controller_spec.rb +55 -0
  113. data/spec/controllers/spree/api/v2/products_controller_spec.rb +99 -0
  114. data/spec/controllers/spree/api/v2/states_controller_spec.rb +42 -0
  115. data/spec/controllers/spree/api/v2/taxonomies_controller_spec.rb +31 -0
  116. data/spec/controllers/spree/api/v2/taxons_controller_spec.rb +54 -0
  117. data/spec/controllers/spree/api/v2/variants_controller_spec.rb +106 -0
  118. data/spec/lib/solidus_json_api/config_spec.rb +10 -0
  119. data/spec/models/spree/base_decorator_spec.rb +9 -0
  120. data/spec/models/spree/price_decorator_spec.rb +3 -0
  121. data/spec/serializers/spree/address_serializer_spec.rb +35 -0
  122. data/spec/serializers/spree/country_serializer_spec.rb +27 -0
  123. data/spec/serializers/spree/error_serializer_spec.rb +141 -0
  124. data/spec/serializers/spree/image_serializer_spec.rb +30 -0
  125. data/spec/serializers/spree/line_item_serializer_spec.rb +40 -0
  126. data/spec/serializers/spree/option_type_serializer_spec.rb +27 -0
  127. data/spec/serializers/spree/option_value_serializer_spec.rb +29 -0
  128. data/spec/serializers/spree/order_serializer_spec.rb +68 -0
  129. data/spec/serializers/spree/price_serializer_spec.rb +28 -0
  130. data/spec/serializers/spree/product_serializer_spec.rb +47 -0
  131. data/spec/serializers/spree/role_serializer_spec.rb +17 -0
  132. data/spec/serializers/spree/state_serializer_spec.rb +25 -0
  133. data/spec/serializers/spree/store_serializer_spec.rb +25 -0
  134. data/spec/serializers/spree/taxon_serializer_spec.rb +44 -0
  135. data/spec/serializers/spree/taxonomy_serializer_spec.rb +27 -0
  136. data/spec/serializers/spree/user_serializer_spec.rb +17 -0
  137. data/spec/serializers/spree/variant_serializer_spec.rb +55 -0
  138. data/spec/spec_helper.rb +57 -0
  139. data/spec/support/shoulda_matchers.rb +6 -0
  140. metadata +442 -0
@@ -0,0 +1,21 @@
1
+ module Spree
2
+ module Api
3
+ module V2
4
+ class OrdersController < Spree::Api::V2::BaseController
5
+ def index
6
+ render_collection orders
7
+ end
8
+
9
+ def show
10
+ render_instance orders.find(params[:id])
11
+ end
12
+
13
+ private
14
+
15
+ def orders
16
+ @current_api_user.admin? ? Spree::Order : @current_api_user.orders
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,27 @@
1
+ module Spree
2
+ module Api
3
+ module V2
4
+ class PricesController < Spree::Api::V2::BaseController
5
+ skip_before_action :authenticate_user
6
+
7
+ def index
8
+ render_collection params[:variant_id] ? prices : prices.includes(:variant)
9
+ end
10
+
11
+ def show
12
+ render_instance prices.find(params[:id])
13
+ end
14
+
15
+ private
16
+
17
+ def prices
18
+ if params[:variant_id]
19
+ Spree::Variant.find(params[:variant_id]).prices
20
+ else
21
+ Spree::Price
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,37 @@
1
+ module Spree
2
+ module Api
3
+ module V2
4
+ class ProductsController < Spree::Api::V2::BaseController
5
+ skip_before_action :authenticate_user, only: [:index, :show]
6
+
7
+ def index
8
+ render_collection products.includes :variants, :master, :taxons, :option_types, master: :images
9
+ end
10
+
11
+ def show
12
+ if params[:price_id]
13
+ render_instance Spree::Price.find(params[:price_id]).product
14
+ elsif params[:variant_id]
15
+ render_instance Spree::Variant.find(params[:variant_id]).product
16
+ elsif params[:image_id]
17
+ render_instance Spree::Image.variants.find(params[:image_id]).viewable.product
18
+ else
19
+ render_instance products.friendly.find(params[:id])
20
+ end
21
+ end
22
+
23
+ private
24
+
25
+ def products
26
+ if params[:taxon_id].present?
27
+ Spree::Taxon.find(params[:taxon_id]).products
28
+ elsif params[:option_type_id]
29
+ Spree::OptionType.find(params[:option_type_id]).products
30
+ else
31
+ Spree::Product
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,29 @@
1
+ module Spree
2
+ module Api
3
+ module V2
4
+ class StatesController < Spree::Api::V2::BaseController
5
+ skip_before_action :authenticate_user
6
+
7
+ def index
8
+ render_collection states
9
+ end
10
+
11
+ def show
12
+ render_instance states.find(params[:id])
13
+ end
14
+
15
+ private
16
+
17
+ def states
18
+ @states ||= begin
19
+ if params[:country_id].present?
20
+ Spree::Country.find(params[:country_id]).states.includes(:country)
21
+ else
22
+ Spree::State.includes(:country)
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,21 @@
1
+ module Spree
2
+ module Api
3
+ module V2
4
+ class TaxonomiesController < Spree::Api::V2::BaseController
5
+ skip_before_action :authenticate_user, only: [:index, :show]
6
+
7
+ def index
8
+ render_collection Spree::Taxonomy.includes(:taxons)
9
+ end
10
+
11
+ def show
12
+ if params[:taxon_id].present?
13
+ render_instance Spree::Taxon.find(params[:taxon_id]).taxonomy
14
+ else
15
+ render_instance Spree::Taxonomy.find(params[:id])
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,40 @@
1
+ module Spree
2
+ module Api
3
+ module V2
4
+ class TaxonsController < Spree::Api::V2::BaseController
5
+ skip_before_action :authenticate_user, only: [:index, :show]
6
+
7
+ def index
8
+ render_collection taxons
9
+ end
10
+
11
+ def show
12
+ render_instance taxon
13
+ end
14
+
15
+ private
16
+
17
+ def taxon
18
+ if params[:taxon_id].present?
19
+ taxons.includes(parent: taxon_associations).find(params[:taxon_id]).parent
20
+ else
21
+ taxons.find(params[:id])
22
+ end
23
+ end
24
+
25
+ def taxons
26
+ if params[:taxonomy_id].present?
27
+ Spree::Taxonomy.find(params[:taxonomy_id]).taxons
28
+ .includes(*taxon_associations.-([:taxonomy]))
29
+ else
30
+ Spree::Taxon.includes(*taxon_associations)
31
+ end
32
+ end
33
+
34
+ def taxon_associations
35
+ [:products, :taxonomy, :parent]
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,35 @@
1
+ module Spree
2
+ module Api
3
+ module V2
4
+ class VariantsController < Spree::Api::V2::BaseController
5
+ skip_before_action :authenticate_user
6
+
7
+ def index
8
+ render_collection variants.includes(:default_price, :prices, :option_values, :product, :images)
9
+ end
10
+
11
+ def show
12
+ if params[:price_id]
13
+ render_instance Spree::Price.find(params[:price_id]).variant
14
+ elsif params[:image_id]
15
+ render_instance Spree::Image.variants.find(params[:image_id]).viewable
16
+ else
17
+ render_instance variants.find(params[:id])
18
+ end
19
+ end
20
+
21
+ private
22
+
23
+ def variants
24
+ if params[:product_id]
25
+ Spree::Product.find(params[:product_id]).variants_including_master
26
+ elsif params[:option_value_id]
27
+ Spree::OptionValue.find(params[:option_value_id]).variants
28
+ else
29
+ Spree::Variant
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,5 @@
1
+ Spree::Base.class_eval do
2
+ def self.paginate(page_attrs)
3
+ page(page_attrs[:number]).per(page_attrs[:size])
4
+ end
5
+ end
@@ -0,0 +1,3 @@
1
+ Spree::Image.class_eval do
2
+ scope :variants, -> { where(viewable_type: 'Spree::Variant') }
3
+ end
@@ -0,0 +1,3 @@
1
+ Spree::LineItem.class_eval do
2
+ before_save -> { order.send :validate_line_item_availability }
3
+ end
@@ -0,0 +1,3 @@
1
+ Spree::Order.class_eval do
2
+ money_methods :promo_total
3
+ end
@@ -0,0 +1,3 @@
1
+ Spree::Price.class_eval do
2
+ delegate :product, to: :variant
3
+ end
@@ -0,0 +1,3 @@
1
+ Spree::State.class_eval do
2
+ scope :find_country, -> (id) { includes(:country).find(id).country }
3
+ end
@@ -0,0 +1,9 @@
1
+ module Spree
2
+ class AddressSerializer < Spree::BaseSerializer
3
+ attributes :first_name, :last_name, :address1, :address2, :city, :zipcode,
4
+ :phone
5
+
6
+ belongs_to :state
7
+ belongs_to :country
8
+ end
9
+ end
@@ -0,0 +1,13 @@
1
+ module Spree
2
+ class BaseSerializer < SolidusJsonApi.parent_serializer
3
+ def image_links(object)
4
+ {
5
+ original: object.url(:original),
6
+ mini: object.url(:mini),
7
+ small: object.url(:small),
8
+ product: object.url(:product),
9
+ large: object.url(:large)
10
+ }
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,7 @@
1
+ module Spree
2
+ class CountrySerializer < Spree::BaseSerializer
3
+ attributes :iso_name, :iso, :iso3, :name, :numcode, :states_required
4
+
5
+ has_many :states
6
+ end
7
+ end
@@ -0,0 +1,55 @@
1
+ module Spree
2
+ class ErrorSerializer
3
+ attr_accessor :resource, :options, :response
4
+
5
+ def initialize(resource, options = {})
6
+ @resource = resource
7
+ @response = options.delete(:response)
8
+ @options = options
9
+ end
10
+
11
+ def as_json
12
+ { errors: error_messages }.to_json
13
+ end
14
+
15
+ private
16
+
17
+ def resource_error_objects(messages)
18
+ messages.map do |title, detail|
19
+ pointer = "data/attributes/#{title.to_s.split('.').join('/')}"
20
+ error_object title.to_s.gsub('.', ' '), detail.to_sentence, pointer: pointer
21
+ end
22
+ end
23
+
24
+ def error_messages
25
+ case resource
26
+ when Symbol
27
+ title_translation = Spree.t("api.errors.#{resource}.title")
28
+ detail_translation = Spree.t("api.errors.#{resource}.detail")
29
+ [error_object(title_translation, detail_translation)]
30
+ when Array
31
+ resource.map { |errors| resource_error_objects errors }.flatten
32
+ else
33
+ resource_error_objects resource.errors.messages
34
+ end
35
+ end
36
+
37
+ def error_object(title, detail, pointer: '')
38
+ error = {
39
+ detail: detail.gsub("\n", ' ').strip,
40
+ meta: options,
41
+ title: title.to_s.titleize
42
+ }
43
+
44
+ error.merge!(response_attributes) if response.present?
45
+ pointer.present? ? error.merge(pointer: pointer) : error
46
+ end
47
+
48
+ def response_attributes
49
+ {
50
+ status: response.status_message,
51
+ code: response.code
52
+ }
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,13 @@
1
+ module Spree
2
+ class ImageSerializer < Spree::BaseSerializer
3
+ attributes :position, :alt, :links
4
+
5
+ belongs_to :viewable
6
+
7
+ private
8
+
9
+ def links
10
+ image_links object.attachment
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,13 @@
1
+ module Spree
2
+ class LineItemSerializer < Spree::BaseSerializer
3
+ attributes :id, :quantity, :variant_id, :order_id, :currency, :cost_price,
4
+ :adjustment_total, :additional_tax_total, :price
5
+
6
+ %w(amount total).each do |money_method|
7
+ attributes money_method, "display_#{money_method}"
8
+ end
9
+
10
+ belongs_to :order
11
+ belongs_to :variant
12
+ end
13
+ end
@@ -0,0 +1,8 @@
1
+ module Spree
2
+ class OptionTypeSerializer < Spree::BaseSerializer
3
+ attributes :name, :presentation, :position
4
+
5
+ has_many :option_values
6
+ has_many :products
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ module Spree
2
+ class OptionValueSerializer < Spree::BaseSerializer
3
+ attributes :name, :presentation, :position
4
+
5
+ belongs_to :option_type
6
+ has_many :variants
7
+ end
8
+ end
@@ -0,0 +1,20 @@
1
+ module Spree
2
+ class OrderSerializer < Spree::BaseSerializer
3
+ attributes :email, :number, :state, :completed_at, :shipment_state,
4
+ :payment_state, :special_instructions, :currency, :channel,
5
+ :item_count, :approved_at, :confirmation_delivered, :canceled_at,
6
+ :payment_total, :total, :display_total
7
+
8
+ %w(
9
+ item adjustment shipment promo additional_tax included_tax
10
+ ).each do |money_method|
11
+ attributes "#{money_method}_total", "display_#{money_method}_total"
12
+ end
13
+
14
+ has_one :user
15
+ has_one :bill_address
16
+ has_one :ship_address
17
+
18
+ has_many :line_items
19
+ end
20
+ end
@@ -0,0 +1,7 @@
1
+ module Spree
2
+ class PriceSerializer < Spree::BaseSerializer
3
+ attributes :amount, :price, :display_amount, :display_price, :currency
4
+
5
+ belongs_to :variant
6
+ end
7
+ end
@@ -0,0 +1,12 @@
1
+ module Spree
2
+ class ProductSerializer < Spree::BaseSerializer
3
+ attributes :name, :description, :slug, :meta_description, :meta_keywords
4
+
5
+ has_one :master
6
+
7
+ has_many :variants
8
+ has_many :taxons
9
+ has_many :option_types
10
+ has_many :images
11
+ end
12
+ end
@@ -0,0 +1,5 @@
1
+ module Spree
2
+ class RoleSerializer < Spree::BaseSerializer
3
+ attributes :name
4
+ end
5
+ end
@@ -0,0 +1,7 @@
1
+ module Spree
2
+ class StateSerializer < Spree::BaseSerializer
3
+ attributes :name, :abbr
4
+
5
+ belongs_to :country
6
+ end
7
+ end
@@ -0,0 +1,6 @@
1
+ module Spree
2
+ class StoreSerializer < Spree::BaseSerializer
3
+ attributes :name, :url, :meta_description, :meta_keywords, :seo_title,
4
+ :mail_from_address, :default_currency, :code, :default
5
+ end
6
+ end
@@ -0,0 +1,16 @@
1
+ module Spree
2
+ class TaxonSerializer < Spree::BaseSerializer
3
+ attributes :name, :permalink, :position, :description, :meta_title, :links,
4
+ :meta_description, :meta_keywords, :depth
5
+
6
+ belongs_to :taxonomy
7
+ belongs_to :parent, serializer: TaxonSerializer
8
+ has_many :children, serializer: TaxonSerializer
9
+
10
+ private
11
+
12
+ def links
13
+ image_links object.icon
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,7 @@
1
+ module Spree
2
+ class TaxonomySerializer < Spree::BaseSerializer
3
+ attributes :name, :position
4
+
5
+ has_many :taxons
6
+ end
7
+ end
@@ -0,0 +1,5 @@
1
+ module Spree
2
+ class UserSerializer < Spree::BaseSerializer
3
+ attributes :id, :email
4
+ end
5
+ end
@@ -0,0 +1,12 @@
1
+ module Spree
2
+ class VariantSerializer < Spree::BaseSerializer
3
+ attributes :sku, :weight, :height, :width, :depth, :is_master, :position,
4
+ :name, :price, :display_price
5
+
6
+ has_many :prices
7
+ has_many :option_values
8
+ has_many :images
9
+
10
+ belongs_to :product
11
+ end
12
+ end
data/circle.yml ADDED
@@ -0,0 +1,12 @@
1
+ ---
2
+ machine:
3
+ environment:
4
+ DB: postgres
5
+ services:
6
+ - postgresql
7
+ ruby:
8
+ version: 2.3.0
9
+
10
+ test:
11
+ override:
12
+ - bundle exec rake
@@ -0,0 +1,25 @@
1
+ en:
2
+ spree:
3
+ api:
4
+ errors:
5
+ invalid_token:
6
+ detail: 'Your token is invalid, please use a different one.'
7
+ title: Invalid Token
8
+ order_complete:
9
+ detail: This order has been completed.
10
+ title: Order Complete
11
+ product_out_of_stock:
12
+ title: Product is out of Stock
13
+ detail: >
14
+ This product is out of stock for the selected quantity.
15
+ record_not_found:
16
+ title: Record Not Found
17
+ detail: >
18
+ One of the records that you were looking for could not be found.
19
+ Please check to see if the record exists or if you're permitted to
20
+ read it.
21
+ quantity_too_high:
22
+ title: Quantity is too High
23
+ detail: >
24
+ The quantity that you have submitted is astronomically high, please
25
+ tone it down a bit.
data/config/routes.rb ADDED
@@ -0,0 +1,53 @@
1
+ Spree::Core::Engine.routes.draw do
2
+ namespace :api, defaults: { format: :json } do
3
+ namespace :v2 do
4
+ resources :countries, only: [:index, :show] do
5
+ resources :states, only: [:index, :show]
6
+ end
7
+
8
+ resources :images, only: [:index, :show] do
9
+ resource :product, :variant, only: :show
10
+ end
11
+
12
+ resources :line_items, only: :create
13
+
14
+ resources :option_types, only: [:index, :show] do
15
+ resources :option_values, :products, only: [:index, :show]
16
+ end
17
+
18
+ resources :option_values, only: [:index, :show] do
19
+ resource :option_type, only: :show
20
+ resources :variants, only: [:index, :show]
21
+ end
22
+
23
+ resources :orders, only: [:index, :show]
24
+
25
+ resources :prices, only: [:index, :show] do
26
+ resource :variant, :product, only: :show
27
+ end
28
+
29
+ resources :products, only: [:index, :show] do
30
+ resources :option_types, :variants, :images, only: [:index, :show]
31
+ end
32
+
33
+ resources :states, only: [:index, :show] do
34
+ resource :country, only: :show
35
+ end
36
+
37
+ resources :taxonomies, only: [:index, :show] do
38
+ resources :taxons, only: [:index, :show]
39
+ end
40
+
41
+ resources :taxons, only: [:index, :show] do
42
+ resources :children, :products, only: [:index, :show]
43
+ resource :parent, only: :show, controller: 'taxons'
44
+ resource :taxonomy, only: :show
45
+ end
46
+
47
+ resources :variants, only: [:index, :show] do
48
+ resources :prices, :option_values, :images, only: [:index, :show]
49
+ resource :product, only: :show
50
+ end
51
+ end
52
+ end
53
+ end
data/docs/.nojekyll ADDED
File without changes
data/docs/Dockerfile ADDED
@@ -0,0 +1,12 @@
1
+ FROM ubuntu:trusty
2
+
3
+ RUN apt-get update
4
+ RUN apt-get install -yq ruby ruby-dev build-essential git
5
+ RUN gem install --no-ri --no-rdoc bundler
6
+ ADD Gemfile /app/Gemfile
7
+ ADD Gemfile.lock /app/Gemfile.lock
8
+ RUN cd /app; bundle install
9
+ ADD . /app
10
+ EXPOSE 4567
11
+ WORKDIR /app
12
+ CMD ["bundle", "exec", "middleman", "server"]
data/docs/Gemfile ADDED
@@ -0,0 +1,14 @@
1
+ source 'https://rubygems.org'
2
+ ruby '2.2.3'
3
+
4
+ # Middleman
5
+ gem 'middleman', '~> 3.3.10'
6
+ gem 'middleman-gh-pages', '~> 0.0.3'
7
+ gem 'middleman-syntax', '~> 2.0.0'
8
+ gem 'middleman-autoprefixer', '~> 2.4.4'
9
+
10
+ gem 'rouge', '~> 1.9.0'
11
+ gem 'redcarpet', '~> 3.3.2'
12
+
13
+ gem 'rake', '~> 10.4.2'
14
+ gem 'therubyracer', '~> 0.12.2', platforms: :ruby
data/docs/README.md ADDED
@@ -0,0 +1,12 @@
1
+ # Documentation for the Solidus JSON API
2
+
3
+ The documentation is hand written and forked from [Slate](https://github.com/tripit/slate).
4
+ Please update these docs when you make a contribution.
5
+
6
+ ## Setup
7
+
8
+ ```shell
9
+ cd docs
10
+ bundle
11
+ middleman server
12
+ ```
data/docs/Rakefile ADDED
@@ -0,0 +1,9 @@
1
+ ENV['MM_ROOT'] = File.expand_path '.'
2
+ ENV['BUNDLE_GEMFILE'] = File.expand_path './Gemfile'
3
+
4
+ require 'middleman-gh-pages'
5
+ require 'rake/clean'
6
+
7
+ CLOBBER.include('build')
8
+
9
+ task default: [:build]