Class: NewStoreApi::ProfilesController

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

Overview

ProfilesController

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_profiles(next_page_token: nil, page_size: 100) ⇒ Profiles

List all clienteling profiles. encodes the information required to retrieve the next page of profiles. returned in a page.

Parameters:

  • next_page_token (String) (defaults to: nil)

    Optional parameter: Pagination token that

  • page_size (Integer) (defaults to: 100)

    Optional parameter: Number of profiles to be

Returns:

  • (Profiles)

    Response from the API call.



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/new_store_api/controllers/profiles_controller.rb', line 15

def list_profiles(next_page_token: nil,
                  page_size: 100)
  @api_call
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/clienteling/profiles',
                                 Server::API)
               .query_param(new_parameter(next_page_token, key: 'next_page_token'))
               .query_param(new_parameter(page_size, key: 'page_size'))
               .header_param(new_parameter('application/json', key: 'accept'))
               .auth(Single.new('oauth')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(Profiles.method(:from_hash)))
    .execute
end

#show_profile(customer_id) ⇒ Profile

Get a single clienteling profile. customer.

Parameters:

  • customer_id (String)

    Required parameter: The identifier of the

Returns:

  • (Profile)

    Response from the API call.



35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/new_store_api/controllers/profiles_controller.rb', line 35

def show_profile(customer_id)
  @api_call
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/clienteling/profiles/{customer_id}',
                                 Server::API)
               .template_param(new_parameter(customer_id, key: 'customer_id')
                                .should_encode(true))
               .header_param(new_parameter('application/json', key: 'accept'))
               .auth(Single.new('oauth')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(Profile.method(:from_hash)))
    .execute
end