mirror of
https://github.com/andwati/telecom-platform.git
synced 2026-11-26 13:58:49 +00:00
docs: Add Go SDK README with comprehensive API documentation and implement modular architecture with authentication provider
- Add README.md with installation instructions, architecture overview, and API examples for all SDK modules - Add AuthProvider class with API key and JWT token support (GenerateJWTToken, ValidateJWTToken, GetHeaders, ClearTokenCache methods) - Add HTTPClient base class with retry logic, error handling, and timeout management - Add GraphQLAPI, PaymentsAPI, RatingPlansAPI
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
package telecom
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// PaymentAPI handles payment-related API calls
|
||||
type PaymentAPI struct {
|
||||
client *HTTPClient
|
||||
}
|
||||
|
||||
// NewPaymentAPI creates a new PaymentAPI
|
||||
func NewPaymentAPI(client *HTTPClient) *PaymentAPI {
|
||||
return &PaymentAPI{client: client}
|
||||
}
|
||||
|
||||
// CreateTransaction creates a new payment transaction
|
||||
func (p *PaymentAPI) CreateTransaction(ctx context.Context, req *CreatePaymentRequest) (*PaymentTransaction, error) {
|
||||
var transaction PaymentTransaction
|
||||
err := p.client.Post(ctx, "/v1/payments/transactions", req, &transaction)
|
||||
return &transaction, err
|
||||
}
|
||||
|
||||
// GetTransaction retrieves a payment transaction by ID
|
||||
func (p *PaymentAPI) GetTransaction(ctx context.Context, transactionID string) (*PaymentTransaction, error) {
|
||||
var transaction PaymentTransaction
|
||||
err := p.client.Get(ctx, fmt.Sprintf("/v1/payments/transactions/%s", transactionID), &transaction)
|
||||
return &transaction, err
|
||||
}
|
||||
|
||||
// ListTransactions retrieves a list of payment transactions
|
||||
func (p *PaymentAPI) ListTransactions(ctx context.Context, subscriberID int64, status string, page, pageSize int32) (*SubscriberList, error) {
|
||||
params := map[string]string{
|
||||
"page": fmt.Sprintf("%d", page),
|
||||
"page_size": fmt.Sprintf("%d", pageSize),
|
||||
}
|
||||
|
||||
if subscriberID > 0 {
|
||||
params["subscriber_id"] = fmt.Sprintf("%d", subscriberID)
|
||||
}
|
||||
if status != "" {
|
||||
params["status"] = status
|
||||
}
|
||||
|
||||
var list SubscriberList
|
||||
err := p.client.Get(ctx, "/v1/payments/transactions", &list, params)
|
||||
return &list, err
|
||||
}
|
||||
Reference in New Issue
Block a user