Class: NewStoreApi::ProductExportController

Inherits:
BaseController show all
Defined in:
lib/new_store_api/controllers/product_export_controller.rb

Overview

ProductExportController

Constant Summary

Constants inherited from BaseController

BaseController::GLOBAL_ERRORS

Instance Attribute Summary

Attributes inherited from BaseController

#config, #http_call_back

Instance Method Summary collapse

Methods inherited from BaseController

#initialize, #new_parameter, #new_request_builder, #new_response_handler, user_agent

Constructor Details

This class inherits a constructor from NewStoreApi::BaseController

Instance Method Details

#list_products(catalog, locale: 'en-us', accept: AcceptEnum::ENUM_TEXTCSV, redirect: true) ⇒ DownloadResponse

Use this resource to download products in a file. The export can be requested in CSV.

  • CSV delimiter is \t (tab)
  • CSV line is ended with \n (end line)
  • CSV cell is escaped when containing special characters \t (tab) \n (new line) \r (carriage return) with \\t \\n \\r
  • CSV cell is escaped with " (double quote) when contain double quote originally (relevant to json fields) RFC 4180 Schema:
  • product_id (string)
  • variant_group_id (string)
  • is_available (bool) - true if product ATP > 0. This value is synchronized from Order Management. This field is eventually consistent. There is no SLA how old this value can be. Please consider using OM directly for use-cases requiring strict consistency.
  • categories (json array)
    • path (string)
    • position (int32)
  • main_category_path (string)
  • main_category_position (int32)
  • external_identifiers (json array)
    • type (string)
    • value (string)
  • extended_attributes (json array)
    • name (string)
    • value (string)
  • title (string)
  • brand (string)
  • caption (string)
  • description (string)
  • keywords (json array of strings)
  • images (json array)
    • url (string)
    • title (string)
    • identifier (string)
    • altText (string)
    • dominantColor (string)
    • width (int32)
    • height (int32)
    • aspectRatio (float32)
    • tags (json array of strings)
  • template_id string
  • price (float32) price from default pricebook
  • currency (string)
  • country_of_origin (string)
  • tax_class_id (string)
  • preorder_start (string RFC3339 truncated to seconds)
  • online_from (string RFC3339 truncated to seconds)
  • online_to (string RFC3339 truncated to seconds)
  • variation_color_value (string)
  • variation_size_value (string)
  • variation_size_gender (string)
  • variation_size_type (string)
  • variation_size_system (string)
  • variation_size_sort_position (int32)
  • variation_additional_1_name (string)
  • variation_additional_1_value (string)
  • variation_additional_2_name (string)
  • variation_additional_2_value (string)
  • product_hts_number (string)
  • schedule_b (string)
  • shipping_dimension_height (float32)
  • shipping_dimension_length (float32)
  • shipping_dimension_unit (string)
  • shipping_dimension_width (float32)
  • shipping_weight_value (float32)
  • shipping_weight_unit (string)
  • serialized_inventory (bool)
  • variable_pricing (bool)
  • inventory_tracked (bool)
  • material (string)
  • updated_at (int64 Unix Timestamp Milliseconds) - some products may have this value empty, value is then considered to be Thu Jan 01 1970 00:00:00 GMT+0000 Files are refreshed automatically. They are scheduled daily. Usually at 8:00 UTC. They are usually finished before 9:00 UTC. API can be used to retrieve max 1 day old snapshot of product data. Response header Last-Modified can be used to determine when file was updated last time (example value Mon, 18 Dec 2023 08:00:21 GMT). Response header ETag can be used to determine whether version you already downloaded before match current one. (example value "2ad5ba4e24fe1c0d225e9a94049f142d") Please use it with combination with If-None-Match request header to download file only when something changed. user wants to export, belongs to. export. Example en-us.csv will return HTTP 302 redirect to resource, otherwise it will return json response with link to a file.

Parameters:

  • catalog (String)

    Required parameter: The catalog the product, the

  • locale (String) (defaults to: 'en-us')

    Optional parameter: The locale the user wants to

  • accept (AcceptEnum) (defaults to: AcceptEnum::ENUM_TEXTCSV)

    Optional parameter: Example:text/csv

  • redirect (TrueClass | FalseClass) (defaults to: true)

    Optional parameter: if true api

Returns:



103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
# File 'lib/new_store_api/controllers/product_export_controller.rb', line 103

def list_products(catalog,
                  locale: 'en-us',
                  accept: AcceptEnum::ENUM_TEXTCSV,
                  redirect: true)
  @api_call
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/catalog/catalogs/{catalog}/offlineproducts',
                                 Server::API)
               .template_param(new_parameter(catalog, key: 'catalog')
                                .should_encode(true))
               .query_param(new_parameter(locale, key: 'locale'))
               .header_param(new_parameter(accept, key: 'Accept'))
               .query_param(new_parameter(redirect, key: 'redirect'))
               .auth(Single.new('oauth')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(DownloadResponse.method(:from_hash)))
    .execute
end