This commit is contained in:
@@ -0,0 +1,26 @@
|
|||||||
|
name: CI
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [master, main]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Set up Go
|
||||||
|
uses: actions/setup-go@v5
|
||||||
|
with:
|
||||||
|
go-version: '1.21'
|
||||||
|
|
||||||
|
- name: Build
|
||||||
|
run: go build ./...
|
||||||
|
|
||||||
|
- name: Vet
|
||||||
|
run: go vet ./...
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
.idea/
|
||||||
@@ -15,6 +15,12 @@ go get hub.rudder.build/rudder/rudder-go-sdk@latest
|
|||||||
|
|
||||||
Требуется Go 1.21+. Токен не нужен — репозиторий публичный.
|
Требуется Go 1.21+. Токен не нужен — репозиторий публичный.
|
||||||
|
|
||||||
|
## Версионирование
|
||||||
|
|
||||||
|
Потребители фиксируют версию по git-тегу
|
||||||
|
(`go get hub.rudder.build/rudder/rudder-go-sdk@vX.Y.Z`). Первый тег `v0.1.0`
|
||||||
|
будет создан при релизе; до него версионирования нет.
|
||||||
|
|
||||||
## Доступ
|
## Доступ
|
||||||
|
|
||||||
`APIKey` — это per-project Admin Key: поле «Admin Key» в настройках проекта
|
`APIKey` — это per-project Admin Key: поле «Admin Key» в настройках проекта
|
||||||
@@ -40,7 +46,6 @@ wallet, err := client.Wallet.Adjust(ctx, playerID, rudder.AdjustWalletParameters
|
|||||||
Reason: "compensation",
|
Reason: "compensation",
|
||||||
})
|
})
|
||||||
metrics, err := client.Metrics.Get(ctx)
|
metrics, err := client.Metrics.Get(ctx)
|
||||||
page, err := client.Ugc.List(ctx, rudder.ListUgcParameters{Status: "pending"})
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## Ошибки
|
## Ошибки
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ type Client struct {
|
|||||||
Metrics *MetricsService
|
Metrics *MetricsService
|
||||||
Leaderboards *LeaderboardsService
|
Leaderboards *LeaderboardsService
|
||||||
Wallet *WalletService
|
Wallet *WalletService
|
||||||
Ugc *UgcService
|
|
||||||
Inventory *InventoryService
|
Inventory *InventoryService
|
||||||
Storage *StorageService
|
Storage *StorageService
|
||||||
|
|
||||||
@@ -52,7 +51,6 @@ func New(config Config) (*Client, error) {
|
|||||||
Metrics: &MetricsService{transport: transport},
|
Metrics: &MetricsService{transport: transport},
|
||||||
Leaderboards: &LeaderboardsService{transport: transport},
|
Leaderboards: &LeaderboardsService{transport: transport},
|
||||||
Wallet: &WalletService{transport: transport},
|
Wallet: &WalletService{transport: transport},
|
||||||
Ugc: &UgcService{transport: transport},
|
|
||||||
Inventory: &InventoryService{transport: transport},
|
Inventory: &InventoryService{transport: transport},
|
||||||
Storage: &StorageService{transport: transport},
|
Storage: &StorageService{transport: transport},
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +0,0 @@
|
|||||||
// Code generated by apigen. DO NOT EDIT.
|
|
||||||
|
|
||||||
package models
|
|
||||||
|
|
||||||
type ListUgcResponse struct {
|
|
||||||
Items []UgcSubmission `json:"items,omitempty"`
|
|
||||||
NextCursor string `json:"nextCursor,omitempty"`
|
|
||||||
}
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
// Code generated by apigen. DO NOT EDIT.
|
|
||||||
|
|
||||||
package models
|
|
||||||
|
|
||||||
type ReviewUgcRequest struct {
|
|
||||||
ID string `json:"id,omitempty"`
|
|
||||||
ReviewedBy string `json:"reviewedBy,omitempty"`
|
|
||||||
Status string `json:"status,omitempty"`
|
|
||||||
}
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
// Code generated by apigen. DO NOT EDIT.
|
|
||||||
|
|
||||||
package models
|
|
||||||
|
|
||||||
type SubmittedBy struct {
|
|
||||||
UserID string `json:"userId,omitempty"`
|
|
||||||
Username string `json:"username,omitempty"`
|
|
||||||
}
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
// Code generated by apigen. DO NOT EDIT.
|
|
||||||
|
|
||||||
package models
|
|
||||||
|
|
||||||
import "encoding/json"
|
|
||||||
|
|
||||||
type UgcSubmission struct {
|
|
||||||
Description string `json:"description,omitempty"`
|
|
||||||
FileSize int64 `json:"fileSize,omitempty"`
|
|
||||||
FileURL string `json:"fileUrl,omitempty"`
|
|
||||||
ID string `json:"id,omitempty"`
|
|
||||||
Metadata json.RawMessage `json:"metadata,omitempty"`
|
|
||||||
Name string `json:"name,omitempty"`
|
|
||||||
ReviewedAt string `json:"reviewedAt,omitempty"`
|
|
||||||
ReviewedBy string `json:"reviewedBy,omitempty"`
|
|
||||||
Status string `json:"status,omitempty"`
|
|
||||||
SubmittedAt string `json:"submittedAt,omitempty"`
|
|
||||||
SubmittedBy SubmittedBy `json:"submittedBy,omitempty"`
|
|
||||||
}
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
// Code generated by apigen. DO NOT EDIT.
|
|
||||||
|
|
||||||
package models
|
|
||||||
|
|
||||||
import "encoding/json"
|
|
||||||
|
|
||||||
type UpdateUgcMetadataRequest struct {
|
|
||||||
ID string `json:"id,omitempty"`
|
|
||||||
Metadata json.RawMessage `json:"metadata,omitempty"`
|
|
||||||
}
|
|
||||||
@@ -1,72 +0,0 @@
|
|||||||
package rudder
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"encoding/json"
|
|
||||||
"net/http"
|
|
||||||
"net/url"
|
|
||||||
"strconv"
|
|
||||||
|
|
||||||
"hub.rudder.build/rudder/rudder-go-sdk/models"
|
|
||||||
)
|
|
||||||
|
|
||||||
type UgcService struct {
|
|
||||||
transport *transport
|
|
||||||
}
|
|
||||||
|
|
||||||
type ListUgcParameters struct {
|
|
||||||
Status string
|
|
||||||
Limit int
|
|
||||||
Cursor string
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *UgcService) List(ctx context.Context, parameters ListUgcParameters) (*models.ListUgcResponse, error) {
|
|
||||||
query := url.Values{}
|
|
||||||
if parameters.Status != "" {
|
|
||||||
query.Set("status", parameters.Status)
|
|
||||||
}
|
|
||||||
if parameters.Limit > 0 {
|
|
||||||
query.Set("limit", strconv.Itoa(parameters.Limit))
|
|
||||||
}
|
|
||||||
if parameters.Cursor != "" {
|
|
||||||
query.Set("cursor", parameters.Cursor)
|
|
||||||
}
|
|
||||||
|
|
||||||
var response models.ListUgcResponse
|
|
||||||
if err := s.transport.do(ctx, http.MethodGet, "/ugc", query, nil, &response); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return &response, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *UgcService) UpdateMetadata(ctx context.Context, id string, metadata json.RawMessage) (*models.UgcSubmission, error) {
|
|
||||||
body := models.UpdateUgcMetadataRequest{
|
|
||||||
ID: id,
|
|
||||||
Metadata: metadata,
|
|
||||||
}
|
|
||||||
|
|
||||||
var response models.UgcSubmission
|
|
||||||
if err := s.transport.do(ctx, http.MethodPatch, "/ugc/"+url.PathEscape(id)+"/metadata", nil, body, &response); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return &response, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
type ReviewUgcParameters struct {
|
|
||||||
Status string
|
|
||||||
ReviewedBy string
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *UgcService) Review(ctx context.Context, id string, parameters ReviewUgcParameters) (*models.UgcSubmission, error) {
|
|
||||||
body := models.ReviewUgcRequest{
|
|
||||||
ID: id,
|
|
||||||
Status: parameters.Status,
|
|
||||||
ReviewedBy: parameters.ReviewedBy,
|
|
||||||
}
|
|
||||||
|
|
||||||
var response models.UgcSubmission
|
|
||||||
if err := s.transport.do(ctx, http.MethodPost, "/ugc/"+url.PathEscape(id)+"/review", nil, body, &response); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return &response, nil
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user