Class: BeyondApi::CustomerGroups

Inherits:
Base
  • Object
show all
Includes:
Utils
Defined in:
lib/beyond_api/resources/customer_groups.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

#add_customer(customer_id, customer_group_ids) ⇒ OpenStruct

A POST request is used to add a customer to a provided list of groups.

$ curl 'https://api-shop.beyondshop.cloud/api/customers/fb5f14ac-f274-4673-ad40-6712dfeea1ba/customer-groups' -i -X POST \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer <Access token>'
  -d '["5d94fa06-f58c-4379-9714-5dc57877c186"]'

Examples:

@customer_groups = session.add_customer("fb5f14ac-f274-4673-ad40-6712dfeea1ba", ["5d94fa06-f58c-4379-9714-5dc57877c186"])

Returns:

  • (OpenStruct)

Scopes:

  • cugr:r



42
43
44
45
46
47
48
# File 'lib/beyond_api/resources/customer_groups.rb', line 42

def add_customer(customer_id, customer_group_ids)
  response, status = BeyondApi::Request.post(@session,
                                             "/customers/#{customer_id}/customer-groups",
                                             customer_group_ids)

  handle_response(response, status)
end

#all(params = {}) ⇒ OpenStruct

A GET request is used to list all customer groups of a shop in a paged way. Each item in the response represents a summary of the customer group data.

$ curl 'https://api-shop.beyondshop.cloud/api/customer-groups' -i -X POST \
  -H 'Authorization: Bearer <Access token>'

Examples:

@customer_groups = session.customer_groups.all

Returns:

  • (OpenStruct)

Scopes:

  • cugr:r



21
22
23
24
25
# File 'lib/beyond_api/resources/customer_groups.rb', line 21

def all(params = {})
  response, status = BeyondApi::Request.get(@session, "/customer-groups", params)

  handle_response(response, status)
end