update readme

This commit is contained in:
diPhantxm
2023-07-27 00:44:36 +03:00
parent 9a41bb1196
commit eb0ce6feb6
2 changed files with 40 additions and 1 deletions

View File

@@ -11,6 +11,7 @@ Read full [documentation](https://docs.ozon.ru/api/seller/en/#tag/Introduction)
You can check [list of supported endpoints](ENDPOINTS.md)
## How to start
### API
Get Client-Id and Api-Key in your seller profile [here](https://seller.ozon.ru/app/settings/api-keys?locale=en)
Just add dependency to your project and you're ready to go.
@@ -49,6 +50,44 @@ func main() {
}
```
### Notifications
Ozon can send push-notifications to your REST server. There is an implementation of REST server that handles notifications in this library.
[Official documentation](https://docs.ozon.ru/api/seller/en/#tag/push_intro)
How to use:
```Golang
package main
import (
"fmt"
"log"
"github.com/diphantxm/ozon-api-client/ozon"
)
func main() {
// Create server
port := 5000
server := ozon.NewNotificationServer(port)
// Register handlers passing message type and handler itself
server.Register(ozon.ChatClosedType, func(req interface{}) error {
notification := req.(*ozon.ChatClosed)
// Do something with the notification here...
log.Printf("chat %s has been closed\n", notification.ChatId)
return nil
})
// Run server
if err := server.Run(); err != nil {
log.Printf("error while running notification server: %s", err)
}
}
```
## Contribution
If you need some endpoints ASAP, create an issue and list all the endpoints. I will add them to library soon.

View File

@@ -67,7 +67,7 @@ func (ns *NotificationServer) handler(rw http.ResponseWriter, httpReq *http.Requ
//ns.error(rw, http.StatusInternalServerError, err)
return
}
h, _ := ns.handlers[mt.MessageType]
h := ns.handlers[mt.MessageType]
if err := h(req); err != nil {
ns.result(rw, false)
//ns.error(rw, http.StatusInternalServerError, err)