Module: Spree::Api::ApiHelpers
- Defined in:
- app/helpers/spree/api/api_helpers.rb
Instance Method Summary collapse
- #address_attributes ⇒ Object
- #adjustment_attributes ⇒ Object
- #country_attributes ⇒ Object
- #creditcard_attributes ⇒ Object
- #image_attributes ⇒ Object
- #inventory_unit_attributes ⇒ Object
- #line_item_attributes ⇒ Object
- #option_type_attributes ⇒ Object
- #option_value_attributes ⇒ Object
- #order_attributes ⇒ Object
- #payment_attributes ⇒ Object
- #payment_method_attributes ⇒ Object
- #product_attributes ⇒ Object
- #product_property_attributes ⇒ Object
- #property_attributes ⇒ Object
- #required_fields_for(model) ⇒ Object
- #return_authorization_attributes ⇒ Object
- #shipment_attributes ⇒ Object
- #state_attributes ⇒ Object
- #stock_item_attributes ⇒ Object
- #stock_location_attributes ⇒ Object
- #stock_movement_attributes ⇒ Object
- #taxon_attributes ⇒ Object
- #taxonomy_attributes ⇒ Object
- #user_attributes ⇒ Object
- #variant_attributes ⇒ Object
Instance Method Details
#address_attributes ⇒ Object
74 75 76 |
# File 'app/helpers/spree/api/api_helpers.rb', line 74 def address_attributes [:id, :firstname, :lastname, :full_name, :address1, :address2, :city, :zipcode, :phone, :company, :alternative_phone, :country_id, :state_id, :state_name] end |
#adjustment_attributes ⇒ Object
86 87 88 |
# File 'app/helpers/spree/api/api_helpers.rb', line 86 def adjustment_attributes [:id, :source_type, :source_id, :adjustable_type, :adjustable_id, :originator_type, :originator_id, :amount, :label, :mandatory, :locked, :eligible, :created_at, :updated_at] end |
#country_attributes ⇒ Object
78 79 80 |
# File 'app/helpers/spree/api/api_helpers.rb', line 78 def country_attributes [:id, :iso_name, :iso, :iso3, :name, :numcode] end |
#creditcard_attributes ⇒ Object
90 91 92 |
# File 'app/helpers/spree/api/api_helpers.rb', line 90 def creditcard_attributes [:id, :month, :year, :cc_type, :last_digits, :first_name, :last_name, :gateway_customer_profile_id, :gateway_payment_profile_id] end |
#image_attributes ⇒ Object
26 27 28 |
# File 'app/helpers/spree/api/api_helpers.rb', line 26 def image_attributes [:id, :position, :attachment_content_type, :attachment_file_name, :type, :attachment_updated_at, :attachment_width, :attachment_height, :alt] end |
#inventory_unit_attributes ⇒ Object
66 67 68 |
# File 'app/helpers/spree/api/api_helpers.rb', line 66 def inventory_unit_attributes [:id, :lock_version, :state, :variant_id, :shipment_id, :return_authorization_id] end |
#line_item_attributes ⇒ Object
38 39 40 |
# File 'app/helpers/spree/api/api_helpers.rb', line 38 def line_item_attributes [:id, :quantity, :price, :variant_id] end |
#option_type_attributes ⇒ Object
42 43 44 |
# File 'app/helpers/spree/api/api_helpers.rb', line 42 def option_type_attributes [:id, :name, :presentation, :position] end |
#option_value_attributes ⇒ Object
30 31 32 |
# File 'app/helpers/spree/api/api_helpers.rb', line 30 def option_value_attributes [:id, :name, :presentation, :option_type_name, :option_type_id, :option_type_presentation] end |
#order_attributes ⇒ Object
34 35 36 |
# File 'app/helpers/spree/api/api_helpers.rb', line 34 def order_attributes [:id, :number, :item_total, :total, :ship_total, :state, :adjustment_total, :user_id, :created_at, :updated_at, :completed_at, :payment_total, :shipment_state, :payment_state, :email, :special_instructions, :token, :channel, :currency] end |
#payment_attributes ⇒ Object
46 47 48 |
# File 'app/helpers/spree/api/api_helpers.rb', line 46 def payment_attributes [:id, :source_type, :source_id, :amount, :display_amount, :payment_method_id, :response_code, :state, :avs_response, :created_at, :updated_at] end |
#payment_method_attributes ⇒ Object
50 51 52 |
# File 'app/helpers/spree/api/api_helpers.rb', line 50 def payment_method_attributes [:id, :name, :description] end |
#product_attributes ⇒ Object
14 15 16 |
# File 'app/helpers/spree/api/api_helpers.rb', line 14 def product_attributes [:id, :name, :description, :price, :available_on, :permalink, :meta_description, :meta_keywords, :shipping_category_id, :taxon_ids] end |
#product_property_attributes ⇒ Object
18 19 20 |
# File 'app/helpers/spree/api/api_helpers.rb', line 18 def product_property_attributes [:id, :product_id, :property_id, :value, :property_name] end |
#property_attributes ⇒ Object
98 99 100 |
# File 'app/helpers/spree/api/api_helpers.rb', line 98 def property_attributes [:id, :name, :presentation] end |
#required_fields_for(model) ⇒ Object
4 5 6 7 8 9 10 11 12 |
# File 'app/helpers/spree/api/api_helpers.rb', line 4 def required_fields_for(model) required_fields = model._validators.select do |field, validations| validations.any? { |v| v.is_a?(ActiveModel::Validations::PresenceValidator) } end.map(&:first) # get fields that are invalid # Permalinks presence is validated, but are really automatically generated # Therefore we shouldn't tell API clients that they MUST send one through required_fields.map!(&:to_s).delete("permalink") required_fields end |
#return_authorization_attributes ⇒ Object
70 71 72 |
# File 'app/helpers/spree/api/api_helpers.rb', line 70 def [:id, :number, :state, :amount, :order_id, :reason, :created_at, :updated_at] end |
#shipment_attributes ⇒ Object
54 55 56 |
# File 'app/helpers/spree/api/api_helpers.rb', line 54 def shipment_attributes [:id, :tracking, :number, :cost, :shipped_at, :state] end |
#state_attributes ⇒ Object
82 83 84 |
# File 'app/helpers/spree/api/api_helpers.rb', line 82 def state_attributes [:id, :name, :abbr, :country_id] end |
#stock_item_attributes ⇒ Object
110 111 112 |
# File 'app/helpers/spree/api/api_helpers.rb', line 110 def stock_item_attributes [:id, :count_on_hand, :backorderable, :lock_version, :stock_location_id, :variant_id] end |
#stock_location_attributes ⇒ Object
102 103 104 |
# File 'app/helpers/spree/api/api_helpers.rb', line 102 def stock_location_attributes [:id, :name, :address1, :address2, :city, :state_id, :state_name, :country_id, :zipcode, :phone, :active] end |
#stock_movement_attributes ⇒ Object
106 107 108 |
# File 'app/helpers/spree/api/api_helpers.rb', line 106 def stock_movement_attributes [:id, :quantity, :stock_item_id] end |
#taxon_attributes ⇒ Object
62 63 64 |
# File 'app/helpers/spree/api/api_helpers.rb', line 62 def taxon_attributes [:id, :name, :pretty_name, :permalink, :parent_id, :taxonomy_id] end |
#taxonomy_attributes ⇒ Object
58 59 60 |
# File 'app/helpers/spree/api/api_helpers.rb', line 58 def taxonomy_attributes [:id, :name] end |
#user_attributes ⇒ Object
94 95 96 |
# File 'app/helpers/spree/api/api_helpers.rb', line 94 def user_attributes [:id, :email, :created_at, :updated_at] end |
#variant_attributes ⇒ Object
22 23 24 |
# File 'app/helpers/spree/api/api_helpers.rb', line 22 def variant_attributes [:id, :name, :sku, :price, :weight, :height, :width, :depth, :is_master, :cost_price, :permalink] end |