Class: BeyondApi::ProductAttributeDefinitions

Inherits:
Base
  • Object
show all
Includes:
Utils
Defined in:
lib/beyond_api/resources/product_attribute_definitions.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 will list the available product attribute definitions.

$ curl 'https://api-shop.beyondshop.cloud/api/product-attribute-definitions' -i -X GET \
    -H 'Authorization: Bearer <Access token>'

Examples:

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

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)

Scopes:

  • prad:r



26
27
28
29
30
# File 'lib/beyond_api/resources/product_attribute_definitions.rb', line 26

def all(params = {})
  path = "/product-attribute-definitions"

  handle_all_request(path, :product_attribute_definitions, params)
end

#create(body) ⇒ OpenStruct

A POST request is used to create a product attribute definition.

$ curl 'https://api-shop.beyondshop.cloud/api/product-attribute-definitions' -i -X POST \
    -H 'Content-Type: application/json' \
    -H 'Authorization: Bearer <Access token>' \
    -d '{
  "key" : "filling_capacity",
  "type" : "NUMBER",
  "displayName" : "Filling Capacity",
  "format" : "#,###.## ml"
}'

Examples:

body = {
	"key": "filling_capacity",
	"type": "NUMBER",
	"displayName": "Filling Capacity",
	"format": "#,###.## ml"
}
@product_attribute_definition = session.product_attribute_definitions.create(body)

Parameters:

  • product_attribute_name (String)

    the product attribute key

Returns:

  • (OpenStruct)

Scopes:

  • prad:c



60
61
62
63
64
65
66
67
68
# File 'lib/beyond_api/resources/product_attribute_definitions.rb', line 60

def create(body)
  path = "/product-attribute-definitions"

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

  handle_response(response, status)
end

#delete(product_attribute_name) ⇒ true

A DELETE request is used to delete a product attribute definition.

$ curl 'https://api-shop.beyondshop.cloud/api/product-attribute-definitions/color' -i -X DELETE \
    -H 'Authorization: Bearer <Access token>'

Examples:

session.product_attribute_definitions.delete("color")

Parameters:

  • product_attribute_name (String)

    the product attribute key

Returns:

  • (true)

Scopes:

  • prad:d



85
86
87
88
89
90
91
92
# File 'lib/beyond_api/resources/product_attribute_definitions.rb', line 85

def delete(product_attribute_name)
  path = "/product-attribute-definitions/#{product_attribute_name}"

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

  handle_response(response, status, respond_with_true: true)
end

#find(product_attribute_name) ⇒ OpenStruct

A GET request is used to retrieve a single product attribute definition by name.

$ curl 'https://api-shop.beyondshop.cloud/api/product-attribute-definitions/filling_capacity' -i -X GET \
    -H 'Authorization: Bearer <Access token>'

Examples:

@product_attribute_definition = session.product_attribute_definitions.find("filling_capacity")

Parameters:

  • product_attribute_name (String)

    the product attribute key

Returns:

  • (OpenStruct)

Scopes:

  • prad:r



109
110
111
112
113
114
115
116
# File 'lib/beyond_api/resources/product_attribute_definitions.rb', line 109

def find(product_attribute_name)
  path = "/product-attribute-definitions/#{product_attribute_name}"

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

  handle_response(response, status)
end