Skip to content

Commit

Permalink
Refactor Operator Struct (#5)
Browse files Browse the repository at this point in the history
* Add Go-Reference badge

* Refactor Operator Struct

Refactor Operator Struct To Reflect Recent Changes To The Reloadly API
Add More Tests To Improve Coverage
  • Loading branch information
Ghvstcode committed May 19, 2021
1 parent 1163d67 commit 8fea241
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 36 deletions.
8 changes: 2 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,9 @@

# Reloadly SDK for Golang

[![CircleCI][circle-ci-badge]][circle-ci-url]
[![MIT][mit-badge]][mit-url]
[![codecov][codecov-badge]][codecov-url]
[![Go Reference][golang-reference-badge]][golang-reference-url]
[![CircleCI][circle-ci-badge]][circle-ci-url] [![MIT][mit-badge]][mit-url] [![codecov][codecov-badge]][codecov-url] [![Go Reference][golang-reference-badge]][golang-reference-url]
The **Reloadly SDK for Golang** enables Go developers to easily work with [Reloadly Services][reloadly-main-site] and build scalable solutions. You can get started in minutes if you have Go 1.15+ installed on your machine.

The **Reloadly SDK for Golang** enables Go developers to easily work with [Reloadly Services][reloadly-main-site] and
build scalable solutions. You can get started in minutes if you have Go 1.15+ installed on your machine.

* [SDK Homepage][sdk-website] (Coming soon)
* [Sample Code][sample-code]
Expand Down
2 changes: 1 addition & 1 deletion airtime/countries_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func TestClient_GetCountries(t *testing.T) {
body, err := client.GetCountries()

if err == nil {
t.Errorf("Expected error to be %q but got nil", err)
t.Errorf("Expected error but got nil")
}

if body != nil {
Expand Down
79 changes: 52 additions & 27 deletions airtime/operators.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,34 +56,59 @@ type Operator struct {

//Operators struct represents list of Operators returned by Relaodly
type Operators struct {
Content []Operator `json:"content"`
Pageable struct {
Sort struct {
Sorted bool `json:"sorted"`
Unsorted bool `json:"unsorted"`
Empty bool `json:"empty"`
} `json:"sort"`
PageNumber int `json:"pageNumber"`
PageSize int `json:"pageSize"`
Offset int `json:"offset"`
Unpaged bool `json:"unpaged"`
Paged bool `json:"paged"`
} `json:"pageable"`
TotalElements int `json:"totalElements"`
TotalPages int `json:"totalPages"`
Last bool `json:"last"`
Sort struct {
Sorted bool `json:"sorted"`
Unsorted bool `json:"unsorted"`
Empty bool `json:"empty"`
} `json:"sort"`
First bool `json:"first"`
NumberOfElements int `json:"numberOfElements"`
Size int `json:"size"`
Number int `json:"number"`
Empty bool `json:"empty"`
ID int `json:"id"`
OperatorID int `json:"operatorId"`
Name string `json:"name"`
Bundle bool `json:"bundle"`
Data bool `json:"data"`
Pin bool `json:"pin"`
SupportsLocalAmounts bool `json:"supportsLocalAmounts"`
SupportsGeographicalRechargePlans bool `json:"supportsGeographicalRechargePlans"`
DenominationType string `json:"denominationType"`
SenderCurrencyCode string `json:"senderCurrencyCode"`
SenderCurrencySymbol string `json:"senderCurrencySymbol"`
DestinationCurrencyCode string `json:"destinationCurrencyCode"`
DestinationCurrencySymbol string `json:"destinationCurrencySymbol"`
Commission float64 `json:"commission"`
InternationalDiscount float64 `json:"internationalDiscount"`
LocalDiscount float64 `json:"localDiscount"`
MostPopularAmount interface{} `json:"mostPopularAmount"`
MostPopularLocalAmount interface{} `json:"mostPopularLocalAmount"`
MinAmount interface{} `json:"minAmount"`
MaxAmount interface{} `json:"maxAmount"`
LocalMinAmount interface{} `json:"localMinAmount"`
LocalMaxAmount interface{} `json:"localMaxAmount"`
Country struct {
IsoName string `json:"isoName"`
Name string `json:"name"`
} `json:"country"`
Fx struct {
Rate int `json:"rate"`
CurrencyCode string `json:"currencyCode"`
} `json:"fx"`
LogoUrls []string `json:"logoUrls"`
FixedAmounts []interface{} `json:"fixedAmounts"`
FixedAmountsDescriptions struct {
} `json:"fixedAmountsDescriptions"`
LocalFixedAmounts []interface{} `json:"localFixedAmounts"`
LocalFixedAmountsDescriptions struct {
} `json:"localFixedAmountsDescriptions"`
SuggestedAmounts []interface{} `json:"suggestedAmounts"`
SuggestedAmountsMap struct {
} `json:"suggestedAmountsMap"`
GeographicalRechargePlans []struct {
LocationCode string `json:"locationCode"`
LocationName string `json:"locationName"`
FixedAmounts []float64 `json:"fixedAmounts"`
LocalAmounts []float64 `json:"localAmounts"`
FixedAmountsDescriptions struct {} `json:"fixedAmountsDescriptions"`
LocalFixedAmountsDescriptions struct {} `json:"localFixedAmountsDescriptions"`
} `json:"geographicalRechargePlans"`
Promotions []interface{} `json:"promotions"`
}



//OperatorFXRate represents FXRate returned by the Reloadly API
type OperatorFXRate struct {
ID int `json:"id"`
Expand Down Expand Up @@ -235,7 +260,7 @@ func (c *Client) GetOperatorsById(operatorID int, options ...OperatorOptions)(*O
method := "GET"
client := c.HttpClient
query := fmt.Sprintf("?suggestedAmounts=%t&suggestedAmountsMap=%t", o.SuggestedAmounts,o.SuggestedAmountsMap)
requestUrl := c.BaseURL + "/operators" + strconv.Itoa(operatorID) + query
requestUrl := c.BaseURL + "/operators/" + strconv.Itoa(operatorID) + query
req, _ := http.NewRequest(method, requestUrl, nil)

req.Header.Add("Authorization", c.AuthHeader)
Expand Down
2 changes: 0 additions & 2 deletions airtime/reloadly_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
package airtime


0 comments on commit 8fea241

Please sign in to comment.