Skip to content

Commit 8fea241

Browse files
authored
Refactor Operator Struct (#5)
* Add Go-Reference badge * Refactor Operator Struct Refactor Operator Struct To Reflect Recent Changes To The Reloadly API Add More Tests To Improve Coverage
1 parent 1163d67 commit 8fea241

File tree

4 files changed

+55
-36
lines changed

4 files changed

+55
-36
lines changed

README.md

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,9 @@
22

33
# Reloadly SDK for Golang
44

5-
[![CircleCI][circle-ci-badge]][circle-ci-url]
6-
[![MIT][mit-badge]][mit-url]
7-
[![codecov][codecov-badge]][codecov-url]
8-
[![Go Reference][golang-reference-badge]][golang-reference-url]
5+
[![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]
6+
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.
97

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

139
* [SDK Homepage][sdk-website] (Coming soon)
1410
* [Sample Code][sample-code]

airtime/countries_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ func TestClient_GetCountries(t *testing.T) {
1919
body, err := client.GetCountries()
2020

2121
if err == nil {
22-
t.Errorf("Expected error to be %q but got nil", err)
22+
t.Errorf("Expected error but got nil")
2323
}
2424

2525
if body != nil {

airtime/operators.go

Lines changed: 52 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -56,34 +56,59 @@ type Operator struct {
5656

5757
//Operators struct represents list of Operators returned by Relaodly
5858
type Operators struct {
59-
Content []Operator `json:"content"`
60-
Pageable struct {
61-
Sort struct {
62-
Sorted bool `json:"sorted"`
63-
Unsorted bool `json:"unsorted"`
64-
Empty bool `json:"empty"`
65-
} `json:"sort"`
66-
PageNumber int `json:"pageNumber"`
67-
PageSize int `json:"pageSize"`
68-
Offset int `json:"offset"`
69-
Unpaged bool `json:"unpaged"`
70-
Paged bool `json:"paged"`
71-
} `json:"pageable"`
72-
TotalElements int `json:"totalElements"`
73-
TotalPages int `json:"totalPages"`
74-
Last bool `json:"last"`
75-
Sort struct {
76-
Sorted bool `json:"sorted"`
77-
Unsorted bool `json:"unsorted"`
78-
Empty bool `json:"empty"`
79-
} `json:"sort"`
80-
First bool `json:"first"`
81-
NumberOfElements int `json:"numberOfElements"`
82-
Size int `json:"size"`
83-
Number int `json:"number"`
84-
Empty bool `json:"empty"`
59+
ID int `json:"id"`
60+
OperatorID int `json:"operatorId"`
61+
Name string `json:"name"`
62+
Bundle bool `json:"bundle"`
63+
Data bool `json:"data"`
64+
Pin bool `json:"pin"`
65+
SupportsLocalAmounts bool `json:"supportsLocalAmounts"`
66+
SupportsGeographicalRechargePlans bool `json:"supportsGeographicalRechargePlans"`
67+
DenominationType string `json:"denominationType"`
68+
SenderCurrencyCode string `json:"senderCurrencyCode"`
69+
SenderCurrencySymbol string `json:"senderCurrencySymbol"`
70+
DestinationCurrencyCode string `json:"destinationCurrencyCode"`
71+
DestinationCurrencySymbol string `json:"destinationCurrencySymbol"`
72+
Commission float64 `json:"commission"`
73+
InternationalDiscount float64 `json:"internationalDiscount"`
74+
LocalDiscount float64 `json:"localDiscount"`
75+
MostPopularAmount interface{} `json:"mostPopularAmount"`
76+
MostPopularLocalAmount interface{} `json:"mostPopularLocalAmount"`
77+
MinAmount interface{} `json:"minAmount"`
78+
MaxAmount interface{} `json:"maxAmount"`
79+
LocalMinAmount interface{} `json:"localMinAmount"`
80+
LocalMaxAmount interface{} `json:"localMaxAmount"`
81+
Country struct {
82+
IsoName string `json:"isoName"`
83+
Name string `json:"name"`
84+
} `json:"country"`
85+
Fx struct {
86+
Rate int `json:"rate"`
87+
CurrencyCode string `json:"currencyCode"`
88+
} `json:"fx"`
89+
LogoUrls []string `json:"logoUrls"`
90+
FixedAmounts []interface{} `json:"fixedAmounts"`
91+
FixedAmountsDescriptions struct {
92+
} `json:"fixedAmountsDescriptions"`
93+
LocalFixedAmounts []interface{} `json:"localFixedAmounts"`
94+
LocalFixedAmountsDescriptions struct {
95+
} `json:"localFixedAmountsDescriptions"`
96+
SuggestedAmounts []interface{} `json:"suggestedAmounts"`
97+
SuggestedAmountsMap struct {
98+
} `json:"suggestedAmountsMap"`
99+
GeographicalRechargePlans []struct {
100+
LocationCode string `json:"locationCode"`
101+
LocationName string `json:"locationName"`
102+
FixedAmounts []float64 `json:"fixedAmounts"`
103+
LocalAmounts []float64 `json:"localAmounts"`
104+
FixedAmountsDescriptions struct {} `json:"fixedAmountsDescriptions"`
105+
LocalFixedAmountsDescriptions struct {} `json:"localFixedAmountsDescriptions"`
106+
} `json:"geographicalRechargePlans"`
107+
Promotions []interface{} `json:"promotions"`
85108
}
86109

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

241266
req.Header.Add("Authorization", c.AuthHeader)

airtime/reloadly_test.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1 @@
11
package airtime
2-
3-

0 commit comments

Comments
 (0)