Here you can find our library for idealo. We develop the API endpoints according to our demand and need. You are welcome to help us to further develop this library.
go get github.com/jjideenschmiede/goidealo
To allow technology partners to transfer their headers as well, we have added another parameter to the request. Now you can set new values flexibly.
Here you can find the description in the idealo documentation.
// Define request
r := goidealo.Request{
ClientId: "",
ClientPassword: "",
Header: map[string]string{},
}
// Add header
r.Header["Partner-Merchant-Solution"] = "J&J Afterialo"
r.Header["Partner-Merchant-Solution-Version"] = "1.0.0"
r.Header["Integration-Partner"] = "J&J Ideenschmiede GmbH"
r.Header["Interface-Version"] = "unbekannt"
To generate an access token for the pws api, you can use the following function. Important! The bearer token must be renewed after 3600 seconds.
Here you can find the description in the idealo documentation.
// Define request
r := goidealo.Request{
ClientId: "",
ClientPassword: "",
}
// Get access token
accessToken, err := goidealo.PwsAccessToken(r)
if err != nil {
fmt.Println(err)
} else {
fmt.Println(accessToken)
}
With this function you can read an offer based on the sku. The following attributes are needed for this:
Also the shop id, the Sku and the and the access token is needed in the request struct. This must be generated before via the function: goidealo.PwsAccessToken(r).
Here you can find the description in the idealo documentation.
// Define request
r := goidealo.Request{
AccessToken: "",
}
// Get offer by sku
offer, err := goidealo.Offer(325081, "21-Lloyd-27-600-12-Hagen-UK6.5-Gr.40", r)
if err != nil {
fmt.Println(err)
} else {
fmt.Println(offer)
}
If you want to create a new offer, then this goes as follows. Some attributes are needed for this. You can see them in the following example. Here you can find the description in the idealo documentation.
Important! You need to fill in the following data, as it will always be submitted in the requests: CheckoutLimitPerPeriod.
// Define request
r := goidealo.Request{
AccessToken: "",
}
// Set body
body := goidealo.OfferBody{
Sku: "21-Lloyd-27-600-12-Hagen-UK6.5-Gr.40",
Title: "Lloyd Men Hagen 27-600-12 Herren Schuhe Derby Schnürer Wildleder Dunkelbraun",
Price: "89.95",
Url: "http://www.shoes4friends.de",
PaymentCosts: &goidealo.OfferBodyPaymentCosts{
PAYPAL: "2.63",
},
DeliveryCosts: &goidealo.OfferBodyDeliveryCosts{
DHL: "0.69",
},
BasePrice: "",
PackagingUnit: 5,
VoucherCode: "",
BranchId: "lloyd",
Brand: "Lloyd",
Oens: nil,
CategoryPath: nil,
Description: "Lloyd Men Hagen 27-600-12 Herren Schuhe Derby Schnürer Wildleder Dunkelbraun",
ImageUrls: nil,
Eans: nil,
Hans: nil,
Pzns: nil,
Kbas: nil,
MerchantName: "",
MerchantId: "",
DeliveryComment: "",
Delivery: "1-3 Werktage",
MaxOrderProcessingTime: 1,
FreeReturnDays: 30,
Checkout: true,
CheckoutLimitPerPeriod: 13,
QuantityPerOrder: 2,
MinimumPrice: "",
FulfillmentType: "",
TwoManHandlingFee: "",
DisposalFee: "",
Eec: "",
EnergyLabels: nil,
Deposit: "",
Size: "",
Colour: "",
Gender: "",
Material: "",
Replica: false,
Used: false,
Download: false,
DynamicProductAttributes: nil,
}
// Add images
body.ImageUrls = append(body.ImageUrls, "https://www.marken-schuhmarkt.de/21-Lloyd-Herren-Schuhe-Derby-Halbschuhe-Wildleder-Hagen-27-600-12-braun-001.jpg")
// Add eans
body.Eans = append(body.Eans, "4032055134146")
// Update the timestamp
offer, err := goidealo.CreateOffer(325081, body, r)
if err != nil {
fmt.Println(err)
} else {
fmt.Println(offer)
}
If you want to revise an offer, you can do it as follows. Here you can find the description in the idealo documentation.
// Set body
body := goidealo.OfferBody{
Sku: "21-Lloyd-27-600-12-Hagen-UK6.5-Gr.40",
Title: "Lloyd Men Hagen 27-600-12 Herren Schuhe Derby Schnürer Wildleder Dunkelbraun",
Price: "189.95",
}
// Update an offer
offer, err := goidealo.UpdateOffer(325081, body, r)
if err != nil {
fmt.Println(err)
} else {
fmt.Println(offer)
}
If you want to remove a special offer, you can do this with the following function. For this some attributes like shop id, sku and the access token are needed. Here you can find the description in the idealo documentation.
// Define request
r := goidealo.Request{
AccessToken: "",
}
// Delete an offer
err := goidealo.DeleteOffer(325081, "21-Lloyd-27-600-12-Hagen-UK6.5-Gr.40", r)
if err != nil {
fmt.Println(err)
}
If you want to remove all existing offers, then you can do this with the following function, for this the shop id and the access token are needed. Here you can find the description in the idealo documentation.
// Define request
r := goidealo.Request{
AccessToken: "",
}
// Delete all existing offers
err := goidealo.DeleteAllOffers(325081, r)
if err != nil {
fmt.Println(err)
}
If you want to update the timestamp of all products, you can do it as follows. You only need the store id and the access token. Here you can find the description in the idealo documentation.
// Define request
r := goidealo.Request{
AccessToken: "",
}
// Update the timestamp
err := goidealo.UpdateOffersTimestamp(325081, r)
if err != nil {
fmt.Println(err)
}
To generate an access token for the moa api, you can use the following function. Important! The bearer token must be renewed after 3600 seconds. If the sandbox system is to be used, then this token is not required.
Here you can find the description in the idealo documentation.
// Define request
r := goidealo.Request{
ClientId: "",
ClientPassword: "",
Sandbox: false,
}
// Get access token
accessToken, err := goidealo.MoaAccessToken(r)
if err != nil {
fmt.Println(err)
} else {
fmt.Println(accessToken)
}
To be able to read all orders, you can use the following function and populate it with url parameters. We have already set the url parameter pageSize. With a value of 250 orders. Here you can find the description in the idealo documentation.
// Define request
r := goidealo.Request{
AccessToken: "",
Sandbox: false,
}
// Add url parameter
parameter := make(map[string]string)
parameter["status"] = "PROCESSING"
parameter["from"] = "2019-05-01T00:00:00Z"
parameter["pageNumber"] = "0"
// Read all orders
orders, err := goidealo.Orders(325081, parameter, r)
if err != nil {
fmt.Println(err)
} else {
fmt.Println(orders)
}
If you want to read out a specific order, this is done as follows. For this you need the id of the shop and the id of the order. Here you can find the description in the idealo documentation.
// Define request
r := goidealo.Request{
AccessToken: "",
Sandbox: false,
}
// Read an order
orders, err := goidealo.Order(325081, "00ALP766AM", r)
if err != nil {
fmt.Println(err)
} else {
fmt.Println(orders)
}
If you want to set the merchant order number, you can do this using the following function. For this you need the shop id and the idealo order id. In addition, the body in the given struct. Here you can find the description in the idealo documentation.
// Define request
r := goidealo.Request{
AccessToken: "",
Sandbox: false,
}
// Define body
body := goidealo.MerchantOrderNumberBody{
MerchantOrderNumber: "012345777777",
}
// Set a merchant order number
merchantOrderNumber, err := goidealo.MerchantOrderNumber(325081, "00REAVQH3Y", body, r)
if err != nil {
fmt.Println(err)
} else {
fmt.Println(merchantOrderNumber)
}
If you want to assign the fulfillment to an order, you can do this with the following function. Here you can find the description in the idealo documentation.
// Define request
r := goidealo.Request{
AccessToken: "",
Sandbox: false,
}
// Define body
body := goidealo.FulfillmentInformationBody{
Carrier: "DHL",
TrackingCode: []string{"example-tracking-number-1234"},
}
// Set a fulfillment information
fulfillmentInformation, err := goidealo.FulfillmentInformation(325081, "00REAVQH3Y", body, r)
if err != nil {
fmt.Println(err)
} else {
fmt.Println(fulfillmentInformation)
}
If an order is to be revoked, then you can do it through the following api endpoint. Here you can find the description in the idealo documentation.
// Define request
r := goidealo.Request{
AccessToken: "",
Sandbox: false,
}
// Define body
body := goidealo.RevokeOrderBody{
Sku: "21-Lloyd-27-600-12-Hagen-UK6.5-Gr.40",
RemainingQuantity: 0,
Reason: "MERCHANT_DECLINE",
Comment: "Sorry, buddy.",
}
// Revoke an order
revokeOrder, err := goidealo.RevokeOrder(325081, "00ALP766AM", body, r)
if err != nil {
fmt.Println(err)
} else {
fmt.Println(revokeOrder)
}
If you want to make a refund, then this goes through the following route. Here you can find the description in the idealo documentation.
// Define request
r := goidealo.Request{
AccessToken: "",
Sandbox: false,
}
// Define body
body := goidealo.RefundOrderBody{
RefundAmount: 1.99,
Currency: "EUR",
}
// Set a refund for an order
refundOrder, err := goidealo.RefundOrder(325081, "00ALP766AM", body, r)
if err != nil {
fmt.Println(err)
} else {
fmt.Println(refundOrder)
}
If you want to read out the refunds, this is done as follows. Here you can find the description in the idealo documentation.
// Define request
r := goidealo.Request{
AccessToken: "",
Sandbox: false,
}
// Get refunds
refundOrder, err := goidealo.Refunds(325081, "00ALP766AM", r)
if err != nil {
fmt.Println(err)
} else {
fmt.Println(refundOrder)
}