Class: NewStoreApi::UsersController

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

Overview

UsersController

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

#create_user(body) ⇒ User

Creates a new user account. To assign roles to a new user account, provide the IDs of the relevant roles in the roles property. To retrieve the role IDs, use the List roles method. If the external_directory property is set to false, the user account is created in Auth0 as well and an email with password setup instructions is sent. The user can then use these credentials to log into NewStore. Note: If the user has no roles assigned, they will be able to log in to NOM but will not be able to interact with NOM until you assign roles to the user to allow them to interact with the various apps. See the Create user role method. here

Parameters:

Returns:

  • (User)

    Response from the API call.



105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
# File 'lib/new_store_api/controllers/users_controller.rb', line 105

def create_user(body)
  @api_call
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/iam/users',
                                 Server::API)
               .header_param(new_parameter('application/json', key: 'Content-Type'))
               .body_param(new_parameter(body))
               .header_param(new_parameter('application/json', key: 'accept'))
               .body_serializer(proc do |param| param.to_json unless param.nil? end)
               .auth(Single.new('oauth')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(User.method(:from_hash)))
    .execute
end

#destroy_user(id) ⇒ void

This method returns an undefined value.

Deletes the user account with the specified ID. If the external_directory property is set to false, the user account will be deleted in Auth0 as well. If the external_directory property is set to true, the user account will not be deleted from the respective enterprise directory.

Parameters:

  • id (String)

    Required parameter: user id



129
130
131
132
133
134
135
136
137
138
139
140
# File 'lib/new_store_api/controllers/users_controller.rb', line 129

def destroy_user(id)
  @api_call
    .request(new_request_builder(HttpMethodEnum::DELETE,
                                 '/iam/users/{id}',
                                 Server::API)
               .template_param(new_parameter(id, key: 'id')
                                .should_encode(true))
               .auth(Single.new('oauth')))
    .response(new_response_handler
                .is_response_void(true))
    .execute
end

#list_users(q: nil, associate_id: nil, offset: 0, count: 25, role: nil) ⇒ GetUsersResponse

Retrieves all available user accounts for the retailer. Searches if the query parameter is used. first/last name or email address. the given associate_id. resulting user account list. accounts. by.

Parameters:

  • q (String) (defaults to: nil)

    Optional parameter: Query the resulting list by

  • associate_id (String) (defaults to: nil)

    Optional parameter: Filter to get user with

  • offset (Integer) (defaults to: 0)

    Optional parameter: The offset to be used for the

  • count (Integer) (defaults to: 25)

    Optional parameter: The number of requested user

  • role (String) (defaults to: nil)

    Optional parameter: The role of the users to filter

Returns:



65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/new_store_api/controllers/users_controller.rb', line 65

def list_users(q: nil,
               associate_id: nil,
               offset: 0,
               count: 25,
               role: nil)
  @api_call
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/iam/users',
                                 Server::API)
               .query_param(new_parameter(q, key: 'q'))
               .query_param(new_parameter(associate_id, key: 'associate_id'))
               .query_param(new_parameter(offset, key: 'offset'))
               .query_param(new_parameter(count, key: 'count'))
               .query_param(new_parameter(role, key: 'role'))
               .header_param(new_parameter('application/json', key: 'accept'))
               .auth(Single.new('oauth')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(GetUsersResponse.method(:from_hash)))
    .execute
end

#replace_user(id, body) ⇒ User

Updates the user account with the specified ID. If the external_directory property is changed to false, the user account will be created in Auth0 as well and an email with password setup instructions will be send. The user can then use these credentials to log into NewStore. Note: If the user has no roles assigned, they will be able to log in to NOM but will not be able to interact with NOM until you assign roles to the user to allow them to interact with the various apps. See the Create user role method.. If the external_directory property is changed to true, the user account will be deleted from Auth0. The user then can login with the enterprise directory credentials. description here

Parameters:

  • id (String)

    Required parameter: user id

  • body (PutUsersByIdRequest)

    Required parameter: TODO: type

Returns:

  • (User)

    Response from the API call.



178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
# File 'lib/new_store_api/controllers/users_controller.rb', line 178

def replace_user(id,
                 body)
  @api_call
    .request(new_request_builder(HttpMethodEnum::PUT,
                                 '/iam/users/{id}',
                                 Server::API)
               .template_param(new_parameter(id, key: 'id')
                                .should_encode(true))
               .header_param(new_parameter('application/json', key: 'Content-Type'))
               .body_param(new_parameter(body))
               .header_param(new_parameter('application/json', key: 'accept'))
               .body_serializer(proc do |param| param.to_json unless param.nil? end)
               .auth(Single.new('oauth')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(User.method(:from_hash)))
    .execute
end

#show_configGetConfigResponse

🚧 BETA: This endpoint is in beta and may change.
See API Lifecycle Documentation for details.
Retrieves the retailer's identity configuration, such as identity providers.

Returns:



21
22
23
24
25
26
27
28
29
30
31
# File 'lib/new_store_api/controllers/users_controller.rb', line 21

def show_config
  @api_call
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/iam/config',
                                 Server::API)
               .header_param(new_parameter('application/json', key: 'accept')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(GetConfigResponse.method(:from_hash)))
    .execute
end

#show_user(id) ⇒ User

Retrieves the user account with the specified ID.

Parameters:

  • id (String)

    Required parameter: user id

Returns:

  • (User)

    Response from the API call.



145
146
147
148
149
150
151
152
153
154
155
156
157
158
# File 'lib/new_store_api/controllers/users_controller.rb', line 145

def show_user(id)
  @api_call
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/iam/users/{id}',
                                 Server::API)
               .template_param(new_parameter(id, key: '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(User.method(:from_hash)))
    .execute
end

#show_user_access_details(id) ⇒ SupportAccessDetails

🚧 BETA: This endpoint is in beta and may change.
See API Lifecycle Documentation for details.
Retrieves the support access details for the user with the specified ID.

Parameters:

  • id (String)

    Required parameter: user id

Returns:



209
210
211
212
213
214
215
216
217
218
219
220
221
222
# File 'lib/new_store_api/controllers/users_controller.rb', line 209

def show_user_access_details(id)
  @api_call
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/iam/users/{id}/support-access-details',
                                 Server::API)
               .template_param(new_parameter(id, key: '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(SupportAccessDetails.method(:from_hash)))
    .execute
end

#show_user_info(application: nil) ⇒ GetUserinfoResponse

Retrieves information and permissions of the user identified by the bearer token. permission by application.

Parameters:

  • application (ApplicationEnum) (defaults to: nil)

    Optional parameter: Filter the users

Returns:



38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/new_store_api/controllers/users_controller.rb', line 38

def (application: nil)
  @api_call
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/iam/userinfo',
                                 Server::API)
               .query_param(new_parameter(application, key: 'application'))
               .header_param(new_parameter('application/json', key: 'accept'))
               .auth(Single.new('oauth')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(GetUserinfoResponse.method(:from_hash)))
    .execute
end