Class: NewStoreApi::UsersController
- Inherits:
-
BaseController
- Object
- BaseController
- NewStoreApi::UsersController
- Defined in:
- lib/new_store_api/controllers/users_controller.rb
Overview
UsersController
Constant Summary
Constants inherited from BaseController
Instance Attribute Summary
Attributes inherited from BaseController
Instance Method Summary collapse
-
#create_user(body) ⇒ User
Creates a new user account.
-
#destroy_user(id) ⇒ void
Deletes the user account with the specified ID.
-
#list_users(q: nil, associate_id: nil, offset: 0, count: 25, role: nil) ⇒ GetUsersResponse
Retrieves all available user accounts for the retailer.
-
#replace_user(id, body) ⇒ User
Updates the user account with the specified ID.
-
#show_config ⇒ GetConfigResponse
🚧 BETA: This endpoint is in beta and may change.
- #show_user(id) ⇒ User
Retrieves the user account with the specified ID.
- #show_user_access_details(id) ⇒ SupportAccessDetails
🚧 BETA: This endpoint is in beta and may change.- #show_user_info(application: nil) ⇒ GetUserinfoResponse
Retrieves information and permissions of the user identified by the bearer token.
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
rolesproperty. To retrieve the role IDs, use the List roles method. If theexternal_directoryproperty is set tofalse, 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. here105 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_directoryproperty is set tofalse, the user account will be deleted in Auth0 as well. If theexternal_directoryproperty is set totrue, the user account will not be deleted from the respective enterprise directory.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.
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_directoryproperty is changed tofalse, 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 theexternal_directoryproperty is changed totrue, the user account will be deleted from Auth0. The user then can login with the enterprise directory credentials. description here178 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_config ⇒ GetConfigResponse
🚧 BETA: This endpoint is in beta and may change.Retrieves the retailer's identity configuration, such as identity providers.
See API Lifecycle Documentation for details.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.
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.Retrieves the support access details for the user with the specified ID.
See API Lifecycle Documentation for details.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.
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 show_user_info(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
- #show_user(id) ⇒ User