mirror of
https://github.com/cubixle/go-ebay.git
synced 2026-04-24 21:24:42 +01:00
first commit
This commit is contained in:
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
vendor
|
||||
7
commands/commands.go
Normal file
7
commands/commands.go
Normal file
@@ -0,0 +1,7 @@
|
||||
package commands
|
||||
|
||||
type Command interface {
|
||||
CallName() string
|
||||
GetRequestBody() []byte
|
||||
SetToken(token string)
|
||||
}
|
||||
69
commands/common.go
Normal file
69
commands/common.go
Normal file
@@ -0,0 +1,69 @@
|
||||
package commands
|
||||
|
||||
import "time"
|
||||
|
||||
type RequesterCredentials struct {
|
||||
EBayAuthToken string `xml:"eBayAuthToken"`
|
||||
}
|
||||
|
||||
type Response interface {
|
||||
ResponseErrors() ebayErrors
|
||||
GetResponse()
|
||||
}
|
||||
|
||||
type ebayErrors []ebayResponseError
|
||||
|
||||
type ebayResponseError struct {
|
||||
ShortMessage string
|
||||
LongMessage string
|
||||
ErrorCode int
|
||||
SeverityCode string
|
||||
ErrorClassification string
|
||||
}
|
||||
|
||||
type ShippingServiceOption struct {
|
||||
ShippingService string
|
||||
ShippingServiceCost float64
|
||||
ShippingServiceAdditionalCost float64
|
||||
FreeShipping bool
|
||||
}
|
||||
|
||||
type ReturnPolicy struct {
|
||||
ReturnsAccepted, ReturnsAcceptedOption, ReturnsWithinOption, RefundOption string
|
||||
}
|
||||
|
||||
type Storefront struct {
|
||||
StoreCategoryID string
|
||||
}
|
||||
|
||||
type ProductListingDetails struct {
|
||||
UPC string
|
||||
BrandMPN BrandMPN
|
||||
}
|
||||
|
||||
type PrimaryCategory struct {
|
||||
CategoryID string
|
||||
}
|
||||
|
||||
type ItemSpecifics struct {
|
||||
NameValueList []NameValueList
|
||||
}
|
||||
|
||||
type NameValueList struct {
|
||||
Name string
|
||||
Value []string
|
||||
}
|
||||
|
||||
type BrandMPN struct {
|
||||
Brand, MPN string
|
||||
}
|
||||
|
||||
type BestOfferDetails struct {
|
||||
BestOfferEnabled bool
|
||||
}
|
||||
|
||||
type ebayResponse struct {
|
||||
Timestamp time.Time
|
||||
Ack string
|
||||
Errors []ebayResponseError
|
||||
}
|
||||
9
commands/common_request_types.go
Normal file
9
commands/common_request_types.go
Normal file
@@ -0,0 +1,9 @@
|
||||
package commands
|
||||
|
||||
type PaginationRequest struct {
|
||||
EntriesPerPage string `xml:",omitempty"`
|
||||
OrdersPerPage string `xml:",omitempty"`
|
||||
PageNumber string `xml:",omitempty"`
|
||||
TotalNumberOfEntries int `xml:",omitempty"`
|
||||
TotalNumberOfPages int `xml:",omitempty"`
|
||||
}
|
||||
57
commands/get_item.go
Normal file
57
commands/get_item.go
Normal file
@@ -0,0 +1,57 @@
|
||||
package commands
|
||||
|
||||
import (
|
||||
"encoding/xml"
|
||||
|
||||
"github.com/cubixle/go-ebay/config"
|
||||
)
|
||||
|
||||
func NewGetItemRequest(cfg *config.Config, itemID string) *GetItemRequest {
|
||||
return &GetItemRequest{
|
||||
ItemID: itemID,
|
||||
RequesterCredentials: RequesterCredentials{
|
||||
EBayAuthToken: cfg.AuthToken,
|
||||
},
|
||||
Xmlns: "urn:ebay:apis:eBLBaseComponents",
|
||||
DetailLevel: "ItemReturnDescription",
|
||||
}
|
||||
}
|
||||
|
||||
type GetItemRequest struct {
|
||||
ItemID string
|
||||
Xmlns string `xml:"xmlns,attr"`
|
||||
RequesterCredentials RequesterCredentials `xml:"RequesterCredentials"`
|
||||
DetailLevel string
|
||||
}
|
||||
|
||||
func (c GetItemRequest) CallName() string {
|
||||
return "GetItem"
|
||||
}
|
||||
|
||||
// GetRequestBody returns bytes
|
||||
func (c GetItemRequest) GetRequestBody() []byte {
|
||||
body, _ := xml.Marshal(c)
|
||||
return body
|
||||
}
|
||||
|
||||
func (c GetItemRequest) SetToken(token string) {
|
||||
c.RequesterCredentials.EBayAuthToken = token
|
||||
}
|
||||
|
||||
type GetItemResponse struct {
|
||||
ebayResponse
|
||||
Item ItemResponse `xml:"Item"`
|
||||
}
|
||||
|
||||
type ItemResponse struct {
|
||||
Title string `xml:"Title"`
|
||||
Description string `xml:"Description"`
|
||||
ItemID string `xml:"ItemID"`
|
||||
ViewItemURLForNaturalSearch string `xml:"ViewItemURLForNaturalSearch"`
|
||||
PictureDetails PictureDetails `xml:"PictureDetails"`
|
||||
Quantity string `xml:"Quantity"`
|
||||
SellingStatus SellingStatus `xml:"SellingStatus"`
|
||||
}
|
||||
|
||||
type PictureDetails struct {
|
||||
}
|
||||
164
commands/get_my_ebay_selling.go
Normal file
164
commands/get_my_ebay_selling.go
Normal file
@@ -0,0 +1,164 @@
|
||||
package commands
|
||||
|
||||
import (
|
||||
"encoding/xml"
|
||||
|
||||
"github.com/cubixle/go-ebay/config"
|
||||
)
|
||||
|
||||
func NewGetMyEbaySelling(cfg *config.Config, version string, pageNumber string, perPage string) *GetMyeBaySellingRequest {
|
||||
return &GetMyeBaySellingRequest{
|
||||
ActiveList: ActiveList{
|
||||
Include: true,
|
||||
Pagination: PaginationRequest{
|
||||
PageNumber: pageNumber,
|
||||
EntriesPerPage: perPage,
|
||||
},
|
||||
Sort: "CurrentPriceDescending",
|
||||
},
|
||||
RequesterCredentials: RequesterCredentials{
|
||||
EBayAuthToken: cfg.AuthToken,
|
||||
},
|
||||
Xmlns: "urn:ebay:apis:eBLBaseComponents",
|
||||
}
|
||||
}
|
||||
|
||||
type GetMyeBaySellingRequest struct {
|
||||
ActiveList ActiveList `xml:"ActiveList"`
|
||||
Xmlns string `xml:"xmlns,attr"`
|
||||
RequesterCredentials RequesterCredentials `xml:"RequesterCredentials"`
|
||||
}
|
||||
type ActiveList struct {
|
||||
Include bool
|
||||
Pagination PaginationRequest
|
||||
Sort string
|
||||
}
|
||||
|
||||
func (c GetMyeBaySellingRequest) CallName() string {
|
||||
return "GetMyeBaySelling"
|
||||
}
|
||||
|
||||
// GetRequestBody returns bytes
|
||||
func (c GetMyeBaySellingRequest) GetRequestBody() []byte {
|
||||
body, _ := xml.Marshal(c)
|
||||
return body
|
||||
}
|
||||
|
||||
func (c GetMyeBaySellingRequest) SetToken(token string) {
|
||||
c.RequesterCredentials.EBayAuthToken = token
|
||||
}
|
||||
|
||||
type MyeBaySellingResponse struct {
|
||||
Ack string
|
||||
Build string
|
||||
CorrelationID string
|
||||
HardExpirationWarning string
|
||||
Timestamp string
|
||||
Version string
|
||||
Summary SummaryStruct
|
||||
SellingSummary SummaryStruct
|
||||
ActiveList ItemArrayStruct `xml:"ActiveList>ItemArray"`
|
||||
DeletedFromSoldList []OrderTransactionArray `xml:"DeletedFromSoldList>OrderTransactionArray"`
|
||||
DeletedFromUnsoldList []ItemArrayStruct `xml:"DeletedFromUnsoldList>ItemArray"`
|
||||
ScheduledList []ItemArrayStruct `xml:"ScheduledList>ItemArray"`
|
||||
SoldList []OrderTransactionArray `xml:"SoldList>OrderTransactionArray"`
|
||||
UnsoldList []ItemArrayStruct `xml:"UnsoldList>ItemArray"`
|
||||
ActiveListPagination PaginationStruct `xml:"ActiveList>PaginationResult"`
|
||||
DeletedFromSoldListPagination PaginationStruct `xml:"DeletedFromSoldList>PaginationResult"`
|
||||
DeletedFromUnsoldListPagination PaginationStruct `xml:"DeletedFromUnsoldList>PaginationResult"`
|
||||
ScheduledListPagination PaginationStruct `xml:"ScheduledList>PaginationResult"`
|
||||
SoldListPagination PaginationStruct `xml:"SoldList>PaginationResult"`
|
||||
UnsoldListPagination PaginationStruct `xml:"UnsoldList>PaginationResult"`
|
||||
Errors []ErrorMessage
|
||||
}
|
||||
type PaginationStruct struct {
|
||||
TotalNumberOfEntries string
|
||||
TotalNumberOfPages string
|
||||
}
|
||||
type SummaryStruct struct {
|
||||
ActiveAuctionCount string
|
||||
AmountLimitRemaining string
|
||||
AuctionBidCount string
|
||||
AuctionSellingCount string
|
||||
ClassifiedAdCount string
|
||||
ClassifiedAdOfferCount string
|
||||
QuantityLimitRemaining string
|
||||
SoldDurationInDays string
|
||||
TotalAuctionSellingValue string
|
||||
TotalLeadCount string
|
||||
TotalListingsWithLeads string
|
||||
TotalSoldCount string
|
||||
TotalSoldValue string
|
||||
}
|
||||
type BuyerStruct struct {
|
||||
Email string
|
||||
StaticAlias string
|
||||
UserID string
|
||||
ShippingAddress struct {
|
||||
PostalCode string
|
||||
}
|
||||
}
|
||||
type TransactionStruct struct {
|
||||
ConvertedTransactionPrice string
|
||||
CreatedDate string
|
||||
IsMultiLegShipping string
|
||||
LineItemID string
|
||||
PaidTime string
|
||||
PaisaPayID string
|
||||
Platform string
|
||||
QuantityPurchased string
|
||||
SellerPaidStatus string
|
||||
ShippedTime string
|
||||
ID string `xml:"TransactionID"`
|
||||
Price string
|
||||
Buyer BuyerStruct `xml:"Buyer>BuyerInfo"`
|
||||
OrderLineItemID string
|
||||
|
||||
FeedbackLeft string `xml:"FeedbackLeft>CommentType"`
|
||||
|
||||
FeedbackReceived string `xml:"FeedbackReceived>CommentType"`
|
||||
|
||||
Item ItemResultStruct `xml:"Item"`
|
||||
|
||||
Status struct {
|
||||
PaymentHold string
|
||||
}
|
||||
}
|
||||
type ItemResultStruct struct {
|
||||
BestOfferDetails struct {
|
||||
BestOfferCount string
|
||||
}
|
||||
BuyItNowPrice string
|
||||
ClassifiedAdPayPerLeadFee string
|
||||
eBayNotes string
|
||||
HideFromSearch string
|
||||
ItemID string
|
||||
ListingDuration string
|
||||
ListingType string
|
||||
PrivateNotes string
|
||||
Quantity string
|
||||
QuantityAvailable string
|
||||
QuestionCount string
|
||||
ReasonHideFromSearch string
|
||||
ReservePrice string
|
||||
SKU string
|
||||
StartPrice string
|
||||
TimeLeft string
|
||||
Title string
|
||||
WatchCount string
|
||||
}
|
||||
|
||||
type OrderStruct struct {
|
||||
ID string `xml:"OrderID"`
|
||||
Subtotal string
|
||||
Transactions []TransactionStruct `xml:"TransactionArray>Transaction"`
|
||||
}
|
||||
type OrderTransactionArray struct {
|
||||
Order OrderStruct `xml:"OrderTransaction>Order"`
|
||||
Transactions []TransactionStruct `xml:"Transaction"`
|
||||
Pagination PaginationStruct `xml:"PaginationResult"`
|
||||
}
|
||||
|
||||
type ItemArrayStruct struct {
|
||||
Items []ItemResultStruct `xml:"Item"`
|
||||
}
|
||||
432
commands/get_orders.go
Normal file
432
commands/get_orders.go
Normal file
@@ -0,0 +1,432 @@
|
||||
package commands
|
||||
|
||||
import (
|
||||
"encoding/xml"
|
||||
|
||||
"github.com/cubixle/go-ebay/config"
|
||||
)
|
||||
|
||||
// NewGetOrdersRequest returns struct
|
||||
func NewGetOrdersRequest(cfg *config.Config, CreateTimeFrom string,
|
||||
CreateTimeTo string,
|
||||
OrderRole string,
|
||||
SortingOrder string,
|
||||
Version string) *GetOrdersRequest {
|
||||
|
||||
return &GetOrdersRequest{
|
||||
CreateTimeFrom: CreateTimeFrom,
|
||||
CreateTimeTo: CreateTimeTo,
|
||||
OrderRole: OrderRole,
|
||||
SortingOrder: SortingOrder,
|
||||
RequesterCredentials: RequesterCredentials{
|
||||
EBayAuthToken: cfg.AuthToken,
|
||||
},
|
||||
Xmlns: "urn:ebay:apis:eBLBaseComponents",
|
||||
Version: Version,
|
||||
}
|
||||
}
|
||||
|
||||
type GetOrdersRequest struct {
|
||||
CreateTimeFrom string
|
||||
CreateTimeTo string
|
||||
OrderRole string
|
||||
SortingOrder string
|
||||
Xmlns string `xml:"xmlns,attr"`
|
||||
Version string
|
||||
RequesterCredentials RequesterCredentials `xml:"RequesterCredentials"`
|
||||
}
|
||||
|
||||
func (c GetOrdersRequest) CallName() string {
|
||||
return "GetOrders"
|
||||
}
|
||||
|
||||
// GetRequestBody returns bytes
|
||||
func (c GetOrdersRequest) GetRequestBody() []byte {
|
||||
body, _ := xml.Marshal(c)
|
||||
return body
|
||||
}
|
||||
|
||||
func (c GetOrdersRequest) SetToken(token string) {
|
||||
c.RequesterCredentials.EBayAuthToken = token
|
||||
}
|
||||
|
||||
type ErrorMessage struct {
|
||||
XmlName xml.Name `xml:"errorMessage"`
|
||||
Error Error `xml:"error"`
|
||||
}
|
||||
|
||||
type Errors struct {
|
||||
XmlName xml.Name `xml:"Errors"`
|
||||
ShortMessage string `xml:"ShortMessage"`
|
||||
LongMessage string `xml:"LongMessage"`
|
||||
ErrorCode string `xml:"ErrorCode"`
|
||||
}
|
||||
|
||||
type Error struct {
|
||||
ErrorId string `xml:"errorId"`
|
||||
Domain string `xml:"domain"`
|
||||
SeverityCode string `xml:"SeverityCode"`
|
||||
Severity string `xml:"Severity"`
|
||||
Line string `xml:"Line"`
|
||||
Column string `xml:"Column"`
|
||||
Category string `xml:"Category"`
|
||||
Message string `xml:"ShortMessage"`
|
||||
SubDomain string `xml:"subdomain"`
|
||||
}
|
||||
|
||||
type EBay struct {
|
||||
ApplicationId string
|
||||
}
|
||||
|
||||
type Item struct {
|
||||
ItemITitleD string
|
||||
ItemID string
|
||||
ListingDetails
|
||||
SellingStatus
|
||||
}
|
||||
|
||||
type ListingDetails struct {
|
||||
EndTime string
|
||||
StartTime string
|
||||
}
|
||||
|
||||
/*<SellingStatus>
|
||||
<BidCount>0</BidCount>
|
||||
<BidIncrement currencyID="USD">0.25</BidIncrement>
|
||||
<ConvertedCurrentPrice currencyID="USD">1.0</ConvertedCurrentPrice>
|
||||
<CurrentPrice currencyID="USD">1.0</CurrentPrice>
|
||||
<LeadCount>0</LeadCount>
|
||||
<MinimumToBid currencyID="USD">1.0</MinimumToBid>
|
||||
<QuantitySold>0</QuantitySold>
|
||||
<ReserveMet>true</ReserveMet>
|
||||
<SecondChanceEligible>false</SecondChanceEligible>
|
||||
<ListingStatus>Active</ListingStatus>
|
||||
</SellingStatus>*/
|
||||
|
||||
type SellingStatus struct {
|
||||
CurrentPrice float64
|
||||
BidCount string
|
||||
QuantitySold string
|
||||
}
|
||||
|
||||
type GetOrdersRequestResponse struct {
|
||||
Xmlns string `xml:"xmlns,attr"`
|
||||
Timestamp string `xml:"Timestamp"`
|
||||
Ack string `xml:"Ack"`
|
||||
Build string `xml:"Build"`
|
||||
Errors Errors `xml:"Errors"`
|
||||
HasMoreOrders bool `xml:"HasMoreOrders"`
|
||||
|
||||
CorrelationID string `xml:"CorrelationID"`
|
||||
HardExpirationWarning string `xml:"HardExpirationWarning"`
|
||||
|
||||
Paginations PaginationRequest `xml:"PaginationResult"`
|
||||
OrderArray OrderArray
|
||||
|
||||
OrdersPerPage int `xml:"OrdersPerPage"`
|
||||
PageNumber int `xml:"PageNumber"`
|
||||
ReturnedOrderCountActual int `xml:"ReturnedOrderCountActual"`
|
||||
}
|
||||
|
||||
type Amount struct {
|
||||
}
|
||||
type BuyerPackageEnclosures struct {
|
||||
}
|
||||
type PaymentInstructionCode struct {
|
||||
}
|
||||
type TaxIdentifierAttributeCode struct {
|
||||
}
|
||||
type ValueTypeCode struct {
|
||||
}
|
||||
type OrderIDArray struct {
|
||||
OrderID string
|
||||
BuyerUserID string
|
||||
}
|
||||
|
||||
type OrderArray struct {
|
||||
XMLName xml.Name `xml:"OrderArray"`
|
||||
Orders []Order `xml:"Order"`
|
||||
}
|
||||
|
||||
type Order struct {
|
||||
XMLName xml.Name `xml:"Order"`
|
||||
OrderID string
|
||||
OrderStatus string
|
||||
BuyerCheckoutMessage string
|
||||
BuyerUserID string
|
||||
CheckoutStatus CheckoutStatus
|
||||
CreatedTime string
|
||||
ModifiedTime string
|
||||
CreatingUserRole string
|
||||
EIASToken string
|
||||
ExtendedOrderID string
|
||||
ExternalTransactions ExternalTransaction `xml:"ExternalTransaction"`
|
||||
IntegratedMerchantCreditCardEnabled string
|
||||
IsMultiLegShipping string
|
||||
LogisticsPlanType string
|
||||
MonetaryDetailss MonetaryDetails `xml:"MonetaryDetails"`
|
||||
MultiLegShippingDetailss MultiLegShippingDetails `xml:"MultiLegShippingDetails"`
|
||||
PaidTime string
|
||||
PaymentHoldDetailss PaymentHoldDetails `xml:"PaymentHoldDetails"`
|
||||
PaymentHoldStatus string
|
||||
PaymentMethods string
|
||||
PickupDetailss PickupDetails `xml:"PickupDetails"`
|
||||
PickupMethodSelected
|
||||
RefundArrays RefundArray `xml:"RefundArray"`
|
||||
SellerEIASToken string
|
||||
SellerEmail string
|
||||
SellerUserID string
|
||||
ShippedTime string
|
||||
ShippingDetails ShippingDetails `xml:"ShippingDetails"`
|
||||
ShippingAddress ShippingAddress `xml:"ShippingAddress"`
|
||||
Subtotal string
|
||||
Total float64
|
||||
TransactionsArray TransactionArray
|
||||
}
|
||||
type Transaction struct {
|
||||
XMLName xml.Name `xml:"Transaction"`
|
||||
//Buyer Buyer
|
||||
ShippingDetails ShippingDetails `xml:"ShippingDetails"`
|
||||
CreatedDate string
|
||||
Item Item
|
||||
QuantityPurchased string
|
||||
// Status Status
|
||||
TransactionID string
|
||||
TransactionPrice string
|
||||
//ShippingServiceSelected ShippingServiceSelected
|
||||
FinalValueFee string
|
||||
TransactionSiteID string
|
||||
Platform string
|
||||
//Taxes Taxes
|
||||
ActualShippingCost float32
|
||||
ActualHandlingCost float32
|
||||
OrderLineItemID string
|
||||
ExtendedOrderID string
|
||||
eBayPlusTransaction bool
|
||||
}
|
||||
type TransactionArray struct {
|
||||
XMLName xml.Name `xml:"TransactionArray"`
|
||||
Transactions []Transaction `xml:"Transaction"`
|
||||
}
|
||||
|
||||
type PickupMethodSelected struct {
|
||||
XMLName xml.Name `xml:"PickupMethodSelected"`
|
||||
MerchantPickupCode string
|
||||
PickupFulfillmentTime string
|
||||
PickupLocationUUID string
|
||||
PickupMethod string
|
||||
PickupStatus string
|
||||
PickupStoreID string
|
||||
}
|
||||
type ShippingDetails struct {
|
||||
XMLName xml.Name `xml:"ShippingDetails"`
|
||||
CalculatedShippingRate
|
||||
CODCost string
|
||||
InsuranceFee string
|
||||
InsuranceOption string
|
||||
InsuranceWanted string
|
||||
|
||||
InternationalShippingServiceOption
|
||||
//SellingManagerSalesRecordNumber
|
||||
ShipmentTrackingDetails
|
||||
ShippingServiceOptions ShippingServiceOptions `xml:"ShippingServiceOptions"`
|
||||
TaxTable
|
||||
}
|
||||
type ShippingAddress struct {
|
||||
XMLName xml.Name `xml:"ShippingAddress"`
|
||||
AddressAttribute string
|
||||
AddressID string
|
||||
AddressOwner string
|
||||
CityName string
|
||||
Country string
|
||||
CountryName string
|
||||
ExternalAddressID string
|
||||
Name string
|
||||
Phone string
|
||||
PostalCode string
|
||||
//ReferenceID string
|
||||
StateOrProvince string
|
||||
Street1 string
|
||||
Street2 string
|
||||
}
|
||||
type TaxJurisdiction struct {
|
||||
JurisdictionID string
|
||||
SalesTaxPercent string
|
||||
ShippingIncludedInTax string
|
||||
}
|
||||
type TaxTable struct {
|
||||
TaxJurisdiction
|
||||
}
|
||||
type ShippingPackageInfo struct {
|
||||
ActualDeliveryTime string
|
||||
ScheduledDeliveryTimeMax string
|
||||
ScheduledDeliveryTimeMin string
|
||||
ShippingTrackingEvent string
|
||||
StoreID string
|
||||
}
|
||||
type ShippingServiceOptions struct {
|
||||
ExpeditedService string
|
||||
ImportCharge string
|
||||
LogisticPlanType string
|
||||
ShippingInsuranceCost string
|
||||
ShippingService string `xml:"ShippingService"`
|
||||
ShippingServiceAdditionalCost string
|
||||
ShippingServiceCost string
|
||||
ShippingServicePriority int
|
||||
}
|
||||
type ShipmentTrackingDetails struct {
|
||||
ShipmentTrackingNumber string
|
||||
ShippingCarrierUsed string
|
||||
}
|
||||
type InternationalShippingServiceOption struct {
|
||||
// ImportCharge string
|
||||
// ShippingInsuranceCost string
|
||||
// ShippingService string
|
||||
// ShippingServiceAdditionalCost string
|
||||
// ShippingServiceCost string
|
||||
// ShippingServicePriority int
|
||||
// ShipToLocation string
|
||||
}
|
||||
|
||||
type CalculatedShippingRate struct {
|
||||
InternationalPackagingHandlingCosts string
|
||||
OriginatingPostalCode string
|
||||
PackageDepth string
|
||||
PackageLength string
|
||||
PackageWidth string
|
||||
PackagingHandlingCosts string
|
||||
ShippingIrregular string
|
||||
ShippingPackage string
|
||||
WeightMajor string
|
||||
WeightMinor string
|
||||
}
|
||||
|
||||
type PickupOptions struct {
|
||||
PickupMethod string
|
||||
PickupPriority string
|
||||
}
|
||||
|
||||
type RefundArray struct{}
|
||||
type PickupDetails struct {
|
||||
PickupOptions
|
||||
}
|
||||
|
||||
type RequiredSellerActionArray struct {
|
||||
RequiredSellerAction string
|
||||
}
|
||||
type PaymentHoldDetails struct {
|
||||
ExpectedReleaseDate string
|
||||
NumOfReqSellerActions string
|
||||
PaymentHoldReason string
|
||||
RequiredSellerActionArrays RequiredSellerActionArray
|
||||
}
|
||||
type ShipToAddress struct {
|
||||
XMLName xml.Name `xml:"ShipToAddress"`
|
||||
AddressAttribute string
|
||||
AddressID string
|
||||
AddressOwner string
|
||||
CityName string
|
||||
Country string
|
||||
CountryName string
|
||||
ExternalAddressID string
|
||||
Name string
|
||||
Phone string
|
||||
PostalCode string
|
||||
//ReferenceID string
|
||||
StateOrProvince string
|
||||
Street1 string
|
||||
Street2 string
|
||||
}
|
||||
type SellerShipmentToLogisticsProvider struct {
|
||||
ShippingServiceDetails
|
||||
ShipToAddress
|
||||
ShippingTimeMax int
|
||||
ShippingTimeMin int
|
||||
}
|
||||
type ShippingServiceDetails struct {
|
||||
ShippingService string
|
||||
TotalShippingCost string
|
||||
}
|
||||
type MultiLegShippingDetails struct {
|
||||
SellerShipmentToLogisticsProvider
|
||||
}
|
||||
type MonetaryDetails struct {
|
||||
Payments
|
||||
Refunds
|
||||
}
|
||||
|
||||
type Payments struct {
|
||||
Payment []Payment
|
||||
}
|
||||
|
||||
type Refunds struct {
|
||||
Refund
|
||||
}
|
||||
type Refund struct {
|
||||
FeeOrCreditAmount string
|
||||
//ReferenceID string
|
||||
RefundAmount string
|
||||
RefundStatus string
|
||||
RefundTime string
|
||||
RefundTo string
|
||||
RefundType string
|
||||
|
||||
//RefundAmount string
|
||||
RefundFromSeller string
|
||||
// RefundID string
|
||||
// RefundStatus string
|
||||
// RefundTime string
|
||||
TotalRefundToBuyer string
|
||||
}
|
||||
|
||||
type SalesTax struct {
|
||||
SalesTaxAmount string
|
||||
SalesTaxPercent string
|
||||
SalesTaxState string
|
||||
ShippingIncludedInTax string
|
||||
}
|
||||
|
||||
type Payment struct {
|
||||
FeeOrCreditAmount string
|
||||
Payee string
|
||||
Payer string
|
||||
PaymentAmount string
|
||||
PaymentReferenceID string
|
||||
PaymentStatus string
|
||||
PaymentTime string
|
||||
//ReferenceID string
|
||||
}
|
||||
|
||||
type ExternalTransaction struct {
|
||||
ExternalTransactionID string
|
||||
ExternalTransactionStatus string
|
||||
ExternalTransactionTime string
|
||||
FeeOrCreditAmount string
|
||||
PaymentOrRefundAmount string
|
||||
}
|
||||
type BuyerPackageEnclosure struct {
|
||||
BuyerPackageEnclosureType string
|
||||
}
|
||||
|
||||
type BuyerTaxIdentifier struct {
|
||||
Attribute string
|
||||
ID string
|
||||
Type string
|
||||
}
|
||||
|
||||
type CancelDetail struct {
|
||||
CancelCompleteDate string
|
||||
CancelIntiationDate string
|
||||
CancelIntiator string
|
||||
CancelReason string
|
||||
CancelReasonDetails string
|
||||
}
|
||||
|
||||
type CheckoutStatus struct {
|
||||
eBayPaymentStatus string
|
||||
IntegratedMerchantCreditCardEnabled string
|
||||
LastModifiedTime string
|
||||
PaymentInstrument string
|
||||
PaymentMethod string
|
||||
Status string
|
||||
}
|
||||
37
commands/revise_item.go
Normal file
37
commands/revise_item.go
Normal file
@@ -0,0 +1,37 @@
|
||||
package commands
|
||||
|
||||
import (
|
||||
"encoding/xml"
|
||||
|
||||
"github.com/cubixle/go-ebay/config"
|
||||
)
|
||||
|
||||
func NewReviseItemRequest(cfg *config.Config, item ItemResponse) *ReviseItemRequest {
|
||||
return &ReviseItemRequest{
|
||||
Item: item,
|
||||
RequesterCredentials: RequesterCredentials{
|
||||
EBayAuthToken: cfg.AuthToken,
|
||||
},
|
||||
Xmlns: "urn:ebay:apis:eBLBaseComponents",
|
||||
}
|
||||
}
|
||||
|
||||
type ReviseItemRequest struct {
|
||||
Item ItemResponse
|
||||
Xmlns string `xml:"xmlns,attr"`
|
||||
RequesterCredentials RequesterCredentials `xml:"RequesterCredentials"`
|
||||
}
|
||||
|
||||
func (c ReviseItemRequest) CallName() string {
|
||||
return "ReviseItem"
|
||||
}
|
||||
|
||||
// GetRequestBody returns bytes
|
||||
func (c ReviseItemRequest) GetRequestBody() []byte {
|
||||
body, _ := xml.Marshal(c)
|
||||
return body
|
||||
}
|
||||
|
||||
func (c ReviseItemRequest) SetToken(token string) {
|
||||
c.RequesterCredentials.EBayAuthToken = token
|
||||
}
|
||||
20
config/config.go
Normal file
20
config/config.go
Normal file
@@ -0,0 +1,20 @@
|
||||
package config
|
||||
|
||||
const sandboxURL = "https://api.sandbox.ebay.com"
|
||||
const productionURL = "https://api.ebay.com"
|
||||
|
||||
type Config struct {
|
||||
BaseUrl string
|
||||
|
||||
DevId, AppId, CertId string
|
||||
RuName, AuthToken string
|
||||
SiteId int
|
||||
}
|
||||
|
||||
func (e *Config) Sandbox() {
|
||||
e.BaseUrl = sandboxURL
|
||||
}
|
||||
|
||||
func (e *Config) Production() {
|
||||
e.BaseUrl = productionURL
|
||||
}
|
||||
56
ebay.go
Normal file
56
ebay.go
Normal file
@@ -0,0 +1,56 @@
|
||||
package ebay
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
func Execute(request *Request) ([]byte, error) {
|
||||
return execute(request)
|
||||
}
|
||||
|
||||
func execute(request *Request) ([]byte, error) {
|
||||
config := request.Config
|
||||
request.Command.SetToken(config.AuthToken)
|
||||
|
||||
xmlBody := []byte("<?xml version=\"1.0\" encoding=\"utf-8\"?>")
|
||||
xmlBody = append(xmlBody, request.Command.GetRequestBody()...)
|
||||
body := bytes.NewReader(xmlBody)
|
||||
|
||||
req, _ := http.NewRequest(
|
||||
"POST",
|
||||
fmt.Sprintf("%s/ws/api.dll", config.BaseUrl),
|
||||
body,
|
||||
)
|
||||
|
||||
req.Header.Add("X-EBAY-API-DEV-NAME", config.DevId)
|
||||
req.Header.Add("X-EBAY-API-APP-NAME", config.AppId)
|
||||
req.Header.Add("X-EBAY-API-CERT-NAME", config.CertId)
|
||||
req.Header.Add("X-EBAY-API-CALL-NAME", request.Command.CallName())
|
||||
req.Header.Add("X-EBAY-API-SITEID", strconv.Itoa(config.SiteId))
|
||||
req.Header.Add("X-EBAY-API-COMPATIBILITY-LEVEL", strconv.Itoa(837))
|
||||
req.Header.Add("Content-Type", "application/xml; charset=utf-8")
|
||||
|
||||
client := &http.Client{}
|
||||
resp, err := client.Do(req)
|
||||
|
||||
if urlErr, ok := err.(*url.Error); ok {
|
||||
log.Printf("Error while trying to send req: %v", urlErr)
|
||||
|
||||
return []byte{}, urlErr
|
||||
} else if resp.StatusCode != 200 {
|
||||
rspBody, _ := ioutil.ReadAll(resp.Body)
|
||||
log.Println(string(rspBody))
|
||||
|
||||
return []byte{}, fmt.Errorf("<%d> - %s", resp.StatusCode, rspBody)
|
||||
}
|
||||
|
||||
rspBody, _ := ioutil.ReadAll(resp.Body)
|
||||
|
||||
return rspBody, nil
|
||||
}
|
||||
13
request.go
Normal file
13
request.go
Normal file
@@ -0,0 +1,13 @@
|
||||
package ebay
|
||||
|
||||
import (
|
||||
"github.com/cubixle/go-ebay/commands"
|
||||
"github.com/cubixle/go-ebay/config"
|
||||
)
|
||||
|
||||
const xmlns = "urn:ebay:apis:eBLBaseComponents"
|
||||
|
||||
type Request struct {
|
||||
Config *config.Config
|
||||
Command commands.Command
|
||||
}
|
||||
Reference in New Issue
Block a user