hiscaler / woocommerce-go Goto Github PK
View Code? Open in Web Editor NEWWooCommerce Rest API SDK
License: BSD 3-Clause "New" or "Revised" License
WooCommerce Rest API SDK
License: BSD 3-Clause "New" or "Revised" License
Hi, i found an issue when querying multiple statuses from get Orders API
package main
import (
"fmt"
"os"
"github.com/hiscaler/woocommerce-go"
"github.com/hiscaler/woocommerce-go/config"
jsoniter "github.com/json-iterator/go"
)
func main() {
// Read you config
b, err := os.ReadFile("./config_test.json")
if err != nil {
panic(fmt.Sprintf("Read config error: %s", err.Error()))
}
var c config.Config
err = jsoniter.Unmarshal(b, &c)
if err != nil {
panic(fmt.Sprintf("Parse config file error: %s", err.Error()))
}
wooClient := woocommerce.NewClient(c)
params := woocommerce.OrdersQueryParams{
Status: []string{
"pending",
"completed",
},
}
wooClient.Services.Order.All(params)
}
GET /wp-json/wc/v3/orders?context=view&oauth_consumer_key=xxxxx&oauth_nonce=7cd699b2e9bf1decb2e6ab063316585210846068&oauth_signature=EmtXCNXZTYkLyGktZPCrrFA3Pg8P3Z7S4aMnWE%2BBJiY%3D&oauth_signature_method=HMAC-SHA256&oauth_timestamp=1661340496&order=asc&page=1&per_page=10&status=pending&status=completed HTTP/1.1
HOST : 35.240.240.242
HEADERS:
Accept: application/json
Content-Type: application/json
User-Agent: WooCommerce API Client-Golang/1.0.0
BODY :
***** NO CONTENT *****
------------------------------------------------------------------------------
~~~ RESPONSE ~~~
STATUS : 401 Unauthorized
PROTO : HTTP/1.1
RECEIVED AT : 2022-08-24T18:28:16.679604+07:00
TIME DURATION: 204.796333ms
HEADERS :
Access-Control-Allow-Headers: Authorization, Content-Type
Access-Control-Expose-Headers: X-WP-Total, X-WP-TotalPages
Content-Length: 137
Content-Type: application/json; charset=UTF-8
Date: Wed, 24 Aug 2022 11:28:16 GMT
Link: <http://35.240.240.242/wp-json/>; rel="https://api.w.org/"
Server: Apache/2.4.29 (Ubuntu)
Vary: Origin
X-Content-Type-Options: nosniff
X-Robots-Tag: noindex
BODY :
{
"code": "woocommerce_rest_authentication_error",
"message": "Invalid signature - provided signature does not match.",
"data": {
"status": 401
}
}
==============================================================================
[ WooCommerce ] 2022/08/24 18:28:16 /Users/loithai/go/pkg/mod/github.com/hiscaler/[email protected]/woo.go:190: OnAfterResponse error: 401: Invalid signature - provided signature does not match.`
https://github.com/hiscaler/woocommerce-go/blob/main/entity/product_attribute.go
its incorrect. pks check WC api doc http://woocommerce.github.io/woocommerce-rest-api-docs/#product-properties
correct:
package entity
// ProductAttribute product attribute properties
type ProductAttribute struct {
/*
ID intjson:"id"
Name stringjson:"name"
Slug stringjson:"slug"
Type stringjson:"type"
OrderBy stringjson:"order_by"
HasArchives booljson:"has_archives"
*/
ID intjson:"id"
// Attribute ID.
Name stringjson:"name"
// Attribute name.
Position intjson:"position"
// Attribute position.
Visible booljson:"visible"
// Define if the attribute is visible on the "Additional information" tab in the product's page. Default is false
Variation booljson:"variation"
// Define if the attribute can be used as variation. Default is false
Options []stringjson:"options"
// List of available term names of the attribute
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.