Managing Customers#

Every Customer who wants to use MOIA’s Ridepooling Service needs to be registered in the Ridepooling API. The Ridepooling Service uses the Customer data to address the Customer during different parts of the Trip or to contact them if something goes wrong.

Creating a Customer#

When creating a Customer the Customer object is returned including the generated Customer id. This Customer id is essential for all further interactions related to a Customer. This includes but is not limited to updating a Customer or ordering an Offer for a Trip.

Important

There is no restriction on the uniqueness of any Customer properties except the id. And since the id is generated by the Customer Service multiple requests with the same Customer data will result in the creation of multiple Customers with different ids.

The following example details a CreateCustomerRequest to create a new Customer.

grpcurl \
  -H "authorization: Bearer ${ACCESS_TOKEN}" \
  -import-path ./protos/ \
  -proto "moia/ridepooling/customer/v1beta1/customer.proto" \
  -d "{\"email_address\":\"test-customer@moia.io\",\"family_name\":\"Customer\",\"given_name\":\"Test\",\"language_code\":\"en\",\"phone_number\":\"+4997259173740\"}" \
  ridepooling-api.int.eu-central-1.moia-group.io:443 moia.ridepooling.customer.v1beta1.CustomerService/CreateCustomer

Listing all Customers#

To get all Customers, we can request them using the ListCustomers RPC.

This method returns a paginated list of Customers. When the next_page_token is set in the response, passing this token as page_token in the next request will return the next page of Customers.

Is the next_page_token not set in the response, we have reached the last page of Customers. The next_page_token should be considered as an opaque token and should not be interpreted in any way.

The following example details a ListCustomersRequest to get existing Customers through paginated requests.

grpcurl \
  -H "authorization: Bearer ${ACCESS_TOKEN}" \
  -import-path ./protos/ \
  -proto "moia/ridepooling/customer/v1beta1/customer.proto" \
  -d "{\"page_size\":5}" \
  ridepooling-api.int.eu-central-1.moia-group.io:443 moia.ridepooling.customer.v1beta1.CustomerService/ListCustomers

Deleting a Customer#

For deleting a Customer the DeleteCustomer RPC is used.

When a Customer is deleted while having an active Trip, the Customer will be able to finish the Trip. But the Customer will not be able to order any new Trips.

The following example details a DeleteCustomerRequest to delete an existing Customer.

# export CUSTOMER_ID="<replace with customer id>"

grpcurl \
  -H "authorization: Bearer ${ACCESS_TOKEN}" \
  -import-path ./protos/ \
  -proto "moia/ridepooling/customer/v1beta1/customer.proto" \
  -d "{\"id\":\"${CUSTOMER_ID}\"}" \
  ridepooling-api.int.eu-central-1.moia-group.io:443 moia.ridepooling.customer.v1beta1.CustomerService/DeleteCustomer

Managing Customer Flags#

The flags of a Customer can be managed through the AddCustomerFlag RPC and RemoveCustomerFlag RPC. A Customer’s currently set flags are returned by the ListCustomerFlags RPC.

For more information about Customer flags, please refer to the Customer flags fundamentals.

The following example details an AddCustomerFlagRequest to attach a flag to an existing Customer.

# export CUSTOMER_ID="<replace with customer id>"
# export CUSTOMER_FLAG="<replace with customer flag>"

grpcurl \
  -H "Authorization: Bearer ${ACCESS_TOKEN}" \
  -import-path ./protos/ \
  -proto "moia/ridepooling/customer/v1beta1/customer.proto" \
  -d "{\"customer_id\":\"${CUSTOMER_ID}\",\"flag\":\"${CUSTOMER_FLAG}\"}" \
  ridepooling-api.int.eu-central-1.moia-group.io:443 moia.ridepooling.customer.v1beta1.CustomerService/AddCustomerFlag

The following example details a RemoveCustomerFlagRequest to remove a flag from an existing Customer.

# export CUSTOMER_ID="<replace with customer id>"
# export CUSTOMER_FLAG="<replace with customer flag>"

grpcurl \
  -H "Authorization: Bearer ${ACCESS_TOKEN}" \
  -import-path ./protos/ \
  -proto "moia/ridepooling/customer/v1beta1/customer.proto" \
  -d "{\"customer_id\":\"${CUSTOMER_ID}\",\"flag\":\"${CUSTOMER_FLAG}\"}" \
  ridepooling-api.int.eu-central-1.moia-group.io:443 moia.ridepooling.customer.v1beta1.CustomerService/RemoveCustomerFlag

The following example details a ListCustomerFlagsRequest to read the flags of an existing Customer.

# export CUSTOMER_ID="<replace with customer id>"

grpcurl \
  -H "Authorization: Bearer ${ACCESS_TOKEN}" \
  -import-path ./protos/ \
  -proto "moia/ridepooling/customer/v1beta1/customer.proto" \
  -d "{\"customer_id\":\"${CUSTOMER_ID}\",\"page_size\":5}" \
  ridepooling-api.int.eu-central-1.moia-group.io:443 moia.ridepooling.customer.v1beta1.CustomerService/ListCustomerFlags