Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement webhook client (repository layer) #5

Open
aldy505 opened this issue Jan 1, 2023 · 0 comments
Open

Implement webhook client (repository layer) #5

aldy505 opened this issue Jan 1, 2023 · 0 comments

Comments

@aldy505
Copy link
Member

aldy505 commented Jan 1, 2023

It should:

  • Create a constructor that set the target URL
  • Do an exponential backoff for failed request (response status code of 5xx or context deadline exceeded)
  • Parse the StatusUpdate struct into JSON string. You can put additional JSON annotation there.

type WebhookClient interface {
// SendStatusUpdate should send a POST request to the destination target URL (configured somewhere else)
// with the JSON request body of:
//
// {
// "reference_number": "string",
// "air_waybill": "string",
// "status_code": 3,
// "status_description": "IN_TRANSIT",
// "timestamp": "time.RFC3339",
// "note": "string"
// }
//
// It should do a retry with exponential backoff if the client returns 500 status code,
// or a timeout error happened.
//
// If the response status code is 400, it should throw an error and don't continue.
SendStatusUpdate(context.Context, StatusUpdate) error
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant