Skip to content

Service for creating, updating and deleting Customer Objects with all their SubEntities like Map, Router and Coordinates

Notifications You must be signed in to change notification settings

BinaryRepublic/triangl-customer-service

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CircleCI

Triangl-Customer-Service

Url: https://api.triangl.io/customer-service/

Full API Documentation: https://api.triangl.io/customer-service/swagger-ui.html

Place in the Infrastructure: https://github.com/codeuniversity/triangl-infrastructure

Routes

  • Get all Customers with GET /customers/all
  • Get a Customer by ID with GET /customers/{id}
  • Create a Customer with POST /customers
  • Update a Customer with PATCH /customers/{id}
  • Delete a Customer with DELETE /customers/{id}

What does it do

This Service is an Endpoint to Get, Create, Update or Delete a Customer. It is connected to a Google Cloud Datastore database and notifies the Pipeline over Google Pub/Sub about every change happening in the Datastore. The Pipeline can then apply the changes to the Serving SQL Database.

UpdateCustomer function

The Update Customer function works in the following way:

It expects a Customer object where only the values are set that needs to be updated. Every value that shouldn't be updadet is set null in the Customer instance. The UpdateCustomer function then fetches the current Customer object from the datastore and calls the Customer.Merge(customer: Customer): Customer function on it. This function iterates over every class property of the ValuesToUpdate Customer Object and checks if it not null, because not null means it should be updated and then updates it on the customer object from the db. But this means it currently can't detect correctly if the maps is updated because [map Object] != [map Object] always returns true.

Buggy/Todo

Can't check if Map is updated

Currently the UpdateCustomer function does not check if the received map is different from the old. Therefore the function will return updated:true even if the send map is identical to the old.

Tools used

Environment Variables

The following Environment variables are need for this service:

GOOGLE_APPLICATION_CREDENTIALS:{pathToGoogleKeyFile.json}

Run

  • With Gradle

    GOOGLE_APPLICATION_CREDENTIALS=/path/to/google/key/file.json ./gradlew bootRun

About

Service for creating, updating and deleting Customer Objects with all their SubEntities like Map, Router and Coordinates

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  

Languages