Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: simplify API #3

Merged
merged 1 commit into from
Dec 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading