Class: BeyondApi::ProductsView

Inherits:
Base
  • Object
show all
Includes:
Utils
Defined in:
lib/beyond_api/resources/products_view.rb

Instance Attribute Summary

Attributes inherited from Base

#session

Instance Method Summary collapse

Methods included from Utils

#handle_all_request, #handle_error, #handle_response, #sanitize_key, #sanitize_response, #to_object_struct

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from BeyondApi::Base

Instance Method Details

#all(params = {}) ⇒ OpenStruct

A GET request is used to list all products.

$ curl 'https://api-shop.beyondshop.cloud/api/product-view/products' -i -X GET \
    -H 'Content-Type: application/json' \
    -H 'Accept: application/hal+json'

Examples:

@products = session.products_view.all(page: 0, size: 100)

Parameters:

  • params (Hash) (defaults to: {})

    a customizable set of options

Options Hash (params):

  • :paginated (Boolean)
  • :size (Integer)

    the page size

  • :page (Integer)

    the page number

Returns:

  • (OpenStruct)

25
26
27
# File 'lib/beyond_api/resources/products_view.rb', line 25

def all(params = {})
  handle_all_request("/product-view/products", :products, params)
end

#available_tagsOpenStruct

A GET request is used to list all available tags.

$ curl 'https://api-shop.beyondshop.cloud/api/product-view/products/search/find-available-tags' -i -X GET \
    -H 'Content-Type: application/json' \
    -H 'Accept: application/hal+json'

Examples:

@tags = session.products_view.available_tags

Returns:

  • (OpenStruct)

41
42
43
44
45
# File 'lib/beyond_api/resources/products_view.rb', line 41

def available_tags
  response, status = BeyondApi::Request.get(@session, "/product-view/products/search/find-available-tags")

  handle_response(response, status)
end

#find(product_id) ⇒ OpenStruct

TODO: To be documented. NOTE: 10.4 10.5 and 10.6 are the same call with different response.

$ curl 'https://api-shop.beyondshop.cloud/api/product-view/products/f75f8fb2-5a48-4d94-aad6-3d3692c06472' -i -X GET \
    -H 'Content-Type: application/json' \
    -H 'Accept: application/hal+json'

Examples:

@product = session.products_view.find("f75f8fb2-5a48-4d94-aad6-3d3692c06472")

Parameters:

  • product_id (String)

    the product UUID

Returns:

  • (OpenStruct)

62
63
64
65
66
# File 'lib/beyond_api/resources/products_view.rb', line 62

def find(product_id)
  response, status = BeyondApi::Request.get(@session, "/product-view/products/#{product_id}")

  handle_response(response, status)
end

#search_by_tag(tag, params = {}) ⇒ OpenStruct

A GET request is used to search for products matching any tag of the list given by a client. The intention is to offer product search capabilities for a shop’s storefront.

$ curl 'https://api-shop.beyondshop.cloud/api/product-view/products/search/find-by-tags?tag=number0' -i -X GET \
    -H 'Content-Type: application/json' \
    -H 'Accept: application/hal+json'

Examples:

@products = session.products_view.search_by_tag("number0", {page: 0, size: 100})

Parameters:

  • tag (String)

    the tag to search

  • params (Hash) (defaults to: {})

    a customizable set of options

Options Hash (params):

  • :size (Integer)

    the page size

  • :page (Integer)

    the page number

Returns:

  • (OpenStruct)

84
85
86
87
88
# File 'lib/beyond_api/resources/products_view.rb', line 84

def search_by_tag(tag, params = {})
  response, status = BeyondApi::Request.get(@session, "/product-view/products/search/find-by-tags", params.merge(tag: tag))

  handle_response(response, status)
end

#search_by_term(term, params = {}) ⇒ OpenStruct

A GET request is used to search for products matching any tag of the list given by a client. The intention is to offer product search capabilities for a shop’s storefront.

$ curl 'https://api-shop.beyondshop.cloud/api/product-view/products/search/find-by-term?query=search+snippet' -i -X GET \
    -H 'Content-Type: application/json' \
    -H 'Accept: application/hal+json'

Examples:

@products = session.products_view.search_by_term("search snippet", {page: 0, size: 100})

Parameters:

  • term (String)

    the term to search

  • params (Hash) (defaults to: {})

    a customizable set of options

Options Hash (params):

  • :size (Integer)

    the page size

  • :page (Integer)

    the page number

Returns:

  • (OpenStruct)

106
107
108
109
110
# File 'lib/beyond_api/resources/products_view.rb', line 106

def search_by_term(term, params = {})
  response, status = BeyondApi::Request.get(@session, "/product-view/products/search/find-by-term", params.merge(query: term))

  handle_response(response, status)
end