for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
package smobilpay
import (
"context"
"encoding/json"
"fmt"
"net/http"
)
// topupService is the API client for the `/` endpoint
type topupService service
// GetPackages returns a list of all available topup packages.
//
// https://apidocs.smobilpay.com/s3papi/API-Reference.2066448558.html
func (service *topupService) GetPackages(ctx context.Context, serviceID string, options ...RequestOption) ([]*Topup, *Response, error) {
request, err := service.client.newRequest(ctx, options, http.MethodGet, fmt.Sprintf("/topup?serviceid=%s", serviceID), nil)
if err != nil {
return nil, nil, err
}
response, err := service.client.do(request)
return nil, response, err
var packages []*Topup
if err = json.Unmarshal(*response.Body, &packages); err != nil {
return packages, response, nil