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

#file_content_type, #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
28
29
# File 'lib/beyond_api/resources/products_view.rb', line 25

def all(params = {})
  path = "/product-view/products"

  handle_all_request(path, :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)


43
44
45
46
47
48
49
50
# File 'lib/beyond_api/resources/products_view.rb', line 43

def available_tags
  path = "/product-view/products/search/find-available-tags"

  response, status = BeyondApi::Request.get(@session,
                                            path)

  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)


67
68
69
70
71
72
73
74
# File 'lib/beyond_api/resources/products_view.rb', line 67

def find(product_id)
  path = "/product-view/products/#{product_id}"

  response, status = BeyondApi::Request.get(@session,
                                            path)

  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)


92
93
94
95
96
97
98
99
100
# File 'lib/beyond_api/resources/products_view.rb', line 92

def search_by_tag(tag, params = {})
  path = "/product-view/products/search/find-by-tags"

  response, status = BeyondApi::Request.get(@session,
                                            path,
                                            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)


118
119
120
121
122
123
124
125
126
# File 'lib/beyond_api/resources/products_view.rb', line 118

def search_by_term(term, params = {})
  path = "/product-view/products/search/find-by-term"

  response, status = BeyondApi::Request.get(@session,
                                            path,
                                            params.merge(query: term))

  handle_response(response, status)
end