Class: NewStoreApi::CustomerProfileController
- Inherits:
-
BaseController
- Object
- BaseController
- NewStoreApi::CustomerProfileController
- Defined in:
- lib/new_store_api/controllers/customer_profile_controller.rb
Overview
CustomerProfileController
Constant Summary
Constants inherited from BaseController
Instance Attribute Summary
Attributes inherited from BaseController
Instance Method Summary collapse
-
#create_or_show_profile(body) ⇒ ProfileResponse
🚧 BETA: This endpoint is in beta and may change.
- #create_profile_deletion_request(profile_id, body) ⇒ void
Creates request for customer profile deletion.
- #create_retrieval_bulk_email_profiles(body) ⇒ RetrieveBulkEmailLookupResponse
Warning: This endpoint is currently only available for non-pii tenants. Retrieves a mapping of existing customer profiles given a list of profile emails.
- #list_profiles(q: nil, sort: nil, offset: 0, count: 10) ⇒ ListProfilesResponse
Returns a searchable list of consumer profiles.
- #show_profile(profile_id) ⇒ ProfileResponse
Returns a single customer profile for the given customer
profile_id.- #update_profile(profile_id, body) ⇒ ProfileResponse
Updates an existing customer profile for the given
profile_id.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_or_show_profile(body) ⇒ ProfileResponse
🚧 BETA: This endpoint is in beta and may change.Get-or-create by email. Creates a new customer profile, or, if a profile already exists for the given email, returns that existing profile unchanged. It does NOT update an existing profile — use the update endpoint (`PATCH /profiles/profile_id`) to change fields on an existing profile. KNOWN LIMITATION: on success this endpoint always responds `201 Created`, even when it returned a pre-existing profile instead of creating one. The status code therefore cannot be used to tell a create apart from a get; if you need to distinguish them, compare the returned profile's `created_at` and `updated_at`. Neither a `200` nor a `409` is returned by this endpoint. **Note:** The Consumer Profile V2 API allows for a single approach to create customer names. When creating a profile, the client must choose one of the following name approaches: - first_name and last_name - full_name Providing both approaches will result in a bad request error from the API.
See API Lifecycle Documentation for details.107 108 109 110 111 112 113 114 115 116 117 118 119 120 121
# File 'lib/new_store_api/controllers/customer_profile_controller.rb', line 107 def create_or_show_profile(body) @api_call .request(new_request_builder(HttpMethodEnum::POST, '/customer/profiles', 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(ProfileResponse.method(:from_hash))) .execute end
#create_profile_deletion_request(profile_id, body) ⇒ void
This method returns an undefined value.
Creates request for customer profile deletion.
178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193
# File 'lib/new_store_api/controllers/customer_profile_controller.rb', line 178 def create_profile_deletion_request(profile_id, body) @api_call .request(new_request_builder(HttpMethodEnum::POST, '/customer/profiles/{profile_id}', Server::API) .template_param(new_parameter(profile_id, key: 'profile_id') .should_encode(true)) .header_param(new_parameter('application/json', key: 'Content-Type')) .body_param(new_parameter(body)) .body_serializer(proc do |param| param.to_json unless param.nil? end) .auth(Single.new('oauth'))) .response(new_response_handler .is_response_void(true)) .execute end
#create_retrieval_bulk_email_profiles(body) ⇒ RetrieveBulkEmailLookupResponse
Warning: This endpoint is currently only available for non-pii tenants. Retrieves a mapping of existing customer profiles given a list of profile emails. Any emails provided that are not associated with a Customer Profile, will not be part of the mapping returned. Notes: For profiles created before Jan 6th 2022 there is no uniqueness guarantee for the email. This means that for some tenants the mapping returned from this endpoint may be a bigger set than the emails requested. type description here
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
# File 'lib/new_store_api/controllers/customer_profile_controller.rb', line 22 def create_retrieval_bulk_email_profiles(body) @api_call .request(new_request_builder(HttpMethodEnum::POST, '/customer/profiles/lookup-bulk-emails', 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(RetrieveBulkEmailLookupResponse.method(:from_hash))) .execute end
#list_profiles(q: nil, sort: nil, offset: 0, count: 10) ⇒ ListProfilesResponse
Returns a searchable list of consumer profiles. Note: This endpoint is designed for paginated front-end use with a search function. It is not suitable for exporting a comprehensive list of all customers due to the following limitations:
- Pagination Per Page Limit: Up to 500 profiles can be fetched per page.
- Total Profiles Limit: There is a maximum limit of 10,000 profiles.
- API Error Beyond Limit: When trying to paginate beyond 10,000 profiles,
the API will start returning errors.
The term is compared to the values in the
email,fullnameandphonenumberfields. A partial match is also considered a match. The term will also be compared to the values in theidanddisplay_idfields. Only an exact match is considered a match. customers response. offset. customer profiles.
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
# File 'lib/new_store_api/controllers/customer_profile_controller.rb', line 58 def list_profiles(q: nil, sort: nil, offset: 0, count: 10) @api_call .request(new_request_builder(HttpMethodEnum::GET, '/customer/profiles', Server::API) .query_param(new_parameter(q, key: 'q')) .query_param(new_parameter(sort, key: 'sort')) .query_param(new_parameter(offset, key: 'offset')) .query_param(new_parameter(count, key: 'count')) .header_param(new_parameter('application/json', key: 'accept')) .auth(Single.new('oauth'))) .response(new_response_handler .deserializer(APIHelper.method(:custom_type_deserializer)) .deserialize_into(ListProfilesResponse.method(:from_hash))) .execute end
#show_profile(profile_id) ⇒ ProfileResponse
Returns a single customer profile for the given customer
profile_id.126 127 128 129 130 131 132 133 134 135 136 137 138 139
# File 'lib/new_store_api/controllers/customer_profile_controller.rb', line 126 def show_profile(profile_id) @api_call .request(new_request_builder(HttpMethodEnum::GET, '/customer/profiles/{profile_id}', Server::API) .template_param(new_parameter(profile_id, key: 'profile_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(ProfileResponse.method(:from_hash))) .execute end
#update_profile(profile_id, body) ⇒ ProfileResponse
Updates an existing customer profile for the given
profile_id. Note: The Consumer Profile V2 API allows for a single approach to update customer names. When updating a profile, the client must choose one of the following name approaches:- first_name and last_name
- full_name
Providing both approaches will result in a bad request error from the API.
Note:
If
extended_attributesis provided, it will replace any existing attributes for the customer.
155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172
# File 'lib/new_store_api/controllers/customer_profile_controller.rb', line 155 def update_profile(profile_id, body) @api_call .request(new_request_builder(HttpMethodEnum::PATCH, '/customer/profiles/{profile_id}', Server::API) .template_param(new_parameter(profile_id, key: 'profile_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(ProfileResponse.method(:from_hash))) .execute end
- #create_profile_deletion_request(profile_id, body) ⇒ void