Skip to content

Commit

Permalink
refactor: simplify API (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewdargan committed Dec 22, 2023
1 parent c9da1c1 commit a312bd9
Show file tree
Hide file tree
Showing 8 changed files with 500 additions and 7,024 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ params := map[string]string{
c := &http.Client{Timeout: time.Second * 5}
appID := "your_app_id"
client := ebay.NewFindingClient(c, appID)
resp, err := client.FindItemsByCategories(context.Background(), params)
resp, err := client.FindItemsByCategory(context.Background(), params)
if err != nil {
// handle error
}
Expand Down
2 changes: 1 addition & 1 deletion doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ To interact with the eBay Finding API, create a [FindingClient]:
c := &http.Client{Timeout: time.Second * 5}
appID := "your_app_id"
client := ebay.NewFindingClient(c, appID)
resp, err := client.FindItemsByCategories(context.Background(), params)
resp, err := client.FindItemsByCategory(context.Background(), params)
if err != nil {
// handle error
}
Expand Down
26 changes: 13 additions & 13 deletions example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ import (
"github.com/matthewdargan/ebay"
)

func ExampleFindingClient_FindItemsByCategories() {
func ExampleFindingClient_FindItemsAdvanced() {
params := map[string]string{
"categoryId": "9355",
"keywords": "iphone",
"itemFilter.name": "MaxPrice",
"itemFilter.value": "500.0",
"itemFilter.paramName": "Currency",
Expand All @@ -23,19 +24,19 @@ func ExampleFindingClient_FindItemsByCategories() {
c := &http.Client{Timeout: time.Second * 5}
appID := "your_app_id"
client := ebay.NewFindingClient(c, appID)
resp, err := client.FindItemsByCategories(context.Background(), params)
resp, err := client.FindItemsAdvanced(context.Background(), params)
if err != nil {
fmt.Println(err)
} else {
fmt.Println(resp)
}
// Output:
// ebay: failed to perform eBay Finding API request with status code 500
// ebay: failed to perform eBay Finding API request with status code: 500
}

func ExampleFindingClient_FindItemsByKeywords() {
func ExampleFindingClient_FindItemsByCategory() {
params := map[string]string{
"keywords": "iphone",
"categoryId": "9355",
"itemFilter.name": "MaxPrice",
"itemFilter.value": "500.0",
"itemFilter.paramName": "Currency",
Expand All @@ -44,19 +45,18 @@ func ExampleFindingClient_FindItemsByKeywords() {
c := &http.Client{Timeout: time.Second * 5}
appID := "your_app_id"
client := ebay.NewFindingClient(c, appID)
resp, err := client.FindItemsByKeywords(context.Background(), params)
resp, err := client.FindItemsByCategory(context.Background(), params)
if err != nil {
fmt.Println(err)
} else {
fmt.Println(resp)
}
// Output:
// ebay: failed to perform eBay Finding API request with status code 500
// ebay: failed to perform eBay Finding API request with status code: 500
}

func ExampleFindingClient_FindItemsAdvanced() {
func ExampleFindingClient_FindItemsByKeywords() {
params := map[string]string{
"categoryId": "9355",
"keywords": "iphone",
"itemFilter.name": "MaxPrice",
"itemFilter.value": "500.0",
Expand All @@ -66,14 +66,14 @@ func ExampleFindingClient_FindItemsAdvanced() {
c := &http.Client{Timeout: time.Second * 5}
appID := "your_app_id"
client := ebay.NewFindingClient(c, appID)
resp, err := client.FindItemsAdvanced(context.Background(), params)
resp, err := client.FindItemsByKeywords(context.Background(), params)
if err != nil {
fmt.Println(err)
} else {
fmt.Println(resp)
}
// Output:
// ebay: failed to perform eBay Finding API request with status code 500
// ebay: failed to perform eBay Finding API request with status code: 500
}

func ExampleFindingClient_FindItemsByProduct() {
Expand All @@ -95,7 +95,7 @@ func ExampleFindingClient_FindItemsByProduct() {
fmt.Println(resp)
}
// Output:
// ebay: failed to perform eBay Finding API request with status code 500
// ebay: failed to perform eBay Finding API request with status code: 500
}

func ExampleFindingClient_FindItemsInEBayStores() {
Expand All @@ -116,5 +116,5 @@ func ExampleFindingClient_FindItemsInEBayStores() {
fmt.Println(resp)
}
// Output:
// ebay: failed to perform eBay Finding API request with status code 500
// ebay: failed to perform eBay Finding API request with status code: 500
}
Loading

0 comments on commit a312bd9

Please sign in to comment.