-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Change pkgs * Change examples * Change tests * Add cover to preference search
- Loading branch information
1 parent
c76f053
commit 1772617
Showing
25 changed files
with
167 additions
and
199 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -161,8 +161,8 @@ func TestSearch(t *testing.T) { | |
Filters: map[string]string{ | ||
"EMAIL": "[email protected]", | ||
}, | ||
Limit: "10", | ||
Offset: "10", | ||
Limit: 10, | ||
Offset: 10, | ||
}, | ||
}, | ||
want: &SearchResponse{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,33 @@ | ||
package customer | ||
|
||
import "strings" | ||
import ( | ||
"strconv" | ||
"strings" | ||
) | ||
|
||
// SearchRequest is the request to search services. | ||
// SearchRequest is the helper structure to build search request. | ||
// Filters field can receive a lot of parameters. For details, see: | ||
// https://www.mercadopago.com/developers/en/reference/customers/_customers_search/get. | ||
type SearchRequest struct { | ||
Filters map[string]string | ||
|
||
Limit string | ||
Offset string | ||
Limit int | ||
Offset int | ||
} | ||
|
||
// SetDefaults sets values for limit and offset when not sent. | ||
func (s *SearchRequest) SetDefaults() { | ||
if len(s.Filters) == 0 { | ||
s.Filters = make(map[string]string, 2) | ||
} else { | ||
for k, v := range s.Filters { | ||
delete(s.Filters, k) | ||
s.Filters[strings.ToLower(k)] = v | ||
} | ||
// GetParams creates map to build query parameters. Keys will be changed to lower case. | ||
func (sr *SearchRequest) GetParams() map[string]string { | ||
params := map[string]string{} | ||
for k, v := range sr.Filters { | ||
key := strings.ToLower(k) | ||
params[key] = v | ||
} | ||
|
||
if _, ok := s.Filters["limit"]; !ok { | ||
limit := "30" | ||
if s.Limit != "" { | ||
limit = s.Limit | ||
} | ||
s.Filters["limit"] = limit | ||
} | ||
if _, ok := s.Filters["offset"]; !ok { | ||
offset := "0" | ||
if s.Offset != "" { | ||
offset = s.Offset | ||
} | ||
s.Filters["offset"] = offset | ||
if sr.Limit == 0 { | ||
sr.Limit = 30 | ||
} | ||
params["limit"] = strconv.Itoa(sr.Limit) | ||
params["offset"] = strconv.Itoa(sr.Offset) | ||
|
||
return params | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,31 @@ | ||
package invoice | ||
|
||
import "strings" | ||
import ( | ||
"strconv" | ||
"strings" | ||
) | ||
|
||
// SearchRequest contains filters accepted in search. | ||
// SearchRequest is the helper structure to build search request. | ||
type SearchRequest struct { | ||
Filters map[string]string | ||
|
||
Limit string | ||
Offset string | ||
Limit int | ||
Offset int | ||
} | ||
|
||
// SetDefaults sets values for limit and offset when not sent. | ||
func (s *SearchRequest) SetDefaults() { | ||
if len(s.Filters) == 0 { | ||
s.Filters = make(map[string]string, 2) | ||
} else { | ||
for k, v := range s.Filters { | ||
delete(s.Filters, k) | ||
s.Filters[strings.ToLower(k)] = v | ||
} | ||
// GetParams creates map to build query parameters. Keys will be changed to lower case. | ||
func (sr *SearchRequest) GetParams() map[string]string { | ||
params := map[string]string{} | ||
for k, v := range sr.Filters { | ||
key := strings.ToLower(k) | ||
params[key] = v | ||
} | ||
|
||
if _, ok := s.Filters["limit"]; !ok { | ||
limit := "30" | ||
if s.Limit != "" { | ||
limit = s.Limit | ||
} | ||
s.Filters["limit"] = limit | ||
} | ||
if _, ok := s.Filters["offset"]; !ok { | ||
offset := "0" | ||
if s.Offset != "" { | ||
offset = s.Offset | ||
} | ||
s.Filters["offset"] = offset | ||
if sr.Limit == 0 { | ||
sr.Limit = 30 | ||
} | ||
params["limit"] = strconv.Itoa(sr.Limit) | ||
params["offset"] = strconv.Itoa(sr.Offset) | ||
|
||
return params | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,33 @@ | ||
package merchantorder | ||
|
||
import "strings" | ||
import ( | ||
"strconv" | ||
"strings" | ||
) | ||
|
||
// SearchRequest is the request to search services. | ||
// SearchRequest is the helper structure to build search request. | ||
// Filters field can receive a lot of paramaters. For details, see: | ||
// https://www.mercadopago.com/developers/en/reference/merchant_orders/_merchant_orders_search/get. | ||
type SearchRequest struct { | ||
Filters map[string]string | ||
|
||
Limit string | ||
Offset string | ||
Limit int | ||
Offset int | ||
} | ||
|
||
// SetDefaults sets values for limit and offset when not sent. | ||
func (s *SearchRequest) SetDefaults() { | ||
if len(s.Filters) == 0 { | ||
s.Filters = make(map[string]string, 2) | ||
} else { | ||
for k, v := range s.Filters { | ||
delete(s.Filters, k) | ||
s.Filters[strings.ToLower(k)] = v | ||
} | ||
// GetParams creates map to build query parameters. Keys will be changed to lower case. | ||
func (sr *SearchRequest) GetParams() map[string]string { | ||
params := map[string]string{} | ||
for k, v := range sr.Filters { | ||
key := strings.ToLower(k) | ||
params[key] = v | ||
} | ||
|
||
if _, ok := s.Filters["limit"]; !ok { | ||
limit := "30" | ||
if s.Limit != "" { | ||
limit = s.Limit | ||
} | ||
s.Filters["limit"] = limit | ||
} | ||
if _, ok := s.Filters["offset"]; !ok { | ||
offset := "0" | ||
if s.Offset != "" { | ||
offset = s.Offset | ||
} | ||
s.Filters["offset"] = offset | ||
if sr.Limit == 0 { | ||
sr.Limit = 30 | ||
} | ||
params["limit"] = strconv.Itoa(sr.Limit) | ||
params["offset"] = strconv.Itoa(sr.Offset) | ||
|
||
return params | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,33 @@ | ||
package payment | ||
|
||
import "strings" | ||
import ( | ||
"strconv" | ||
"strings" | ||
) | ||
|
||
// SearchRequest is the request to search services. | ||
// SearchRequest is the helper structure to build search request. | ||
// Filters field can receive a lot of paramaters. For details, see: | ||
// https://www.mercadopago.com.br/developers/pt/reference/payments/_payments_search/get. | ||
// https://www.mercadopago.com/developers/en/reference/payments/_payments_search/get. | ||
type SearchRequest struct { | ||
Filters map[string]string | ||
|
||
Limit string | ||
Offset string | ||
Limit int | ||
Offset int | ||
} | ||
|
||
// SetDefaults sets values for limit and offset when not sent. | ||
func (s *SearchRequest) SetDefaults() { | ||
if len(s.Filters) == 0 { | ||
s.Filters = make(map[string]string, 2) | ||
} else { | ||
for k, v := range s.Filters { | ||
delete(s.Filters, k) | ||
s.Filters[strings.ToLower(k)] = v | ||
} | ||
// GetParams creates map to build query parameters. Keys will be changed to lower case. | ||
func (sr *SearchRequest) GetParams() map[string]string { | ||
params := map[string]string{} | ||
for k, v := range sr.Filters { | ||
key := strings.ToLower(k) | ||
params[key] = v | ||
} | ||
|
||
if _, ok := s.Filters["limit"]; !ok { | ||
limit := "30" | ||
if s.Limit != "" { | ||
limit = s.Limit | ||
} | ||
s.Filters["limit"] = limit | ||
} | ||
if _, ok := s.Filters["offset"]; !ok { | ||
offset := "0" | ||
if s.Offset != "" { | ||
offset = s.Offset | ||
} | ||
s.Filters["offset"] = offset | ||
if sr.Limit == 0 { | ||
sr.Limit = 30 | ||
} | ||
params["limit"] = strconv.Itoa(sr.Limit) | ||
params["offset"] = strconv.Itoa(sr.Offset) | ||
|
||
return params | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.