Documentation
¶
Index ¶
- Constants
- type APIError
- type AuthError
- type BusinessError
- type Client
- func (c *Client) BaseURL() string
- func (c *Client) Do(ctx context.Context, req *Request, out any) error
- func (c *Client) DoBytes(ctx context.Context, req *Request) ([]byte, error)
- func (c *Client) DoDownload(ctx context.Context, req *Request) (*Download, error)
- func (c *Client) DoRaw(ctx context.Context, req *Request) (*http.Response, error)
- func (c *Client) HTTPClient() *http.Client
- type Config
- type Credentials
- type Download
- type Hook
- type Logger
- type LoginRequest
- type LoginResponse
- type Middleware
- type MultipartBody
- type MultipartFile
- type RateLimitError
- type Request
- type ResponseMeta
- type ServerError
- type StaticTokenSource
- type TokenSource
- type TransportError
- type ValidationError
Examples ¶
Constants ¶
View Source
const DefaultBaseURL = internalclient.DefaultBaseURL
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type APIError ¶
type APIError = internalclient.APIError
type AuthError ¶
type AuthError = internalclient.AuthError
type BusinessError ¶
type BusinessError = internalclient.BusinessError
type Client ¶
type Client struct {
Config Config
Auth *auth.Service
Orders *orders.Service
Couriers *courier.Service
PickupAddresses *pickupaddress.Service
Products *products.Service
Listings *listings.Service
Channels *channels.Service
Inventory *inventory.Service
Location *location.Service
International *international.Service
Hyperlocal *hyperlocal.Service
Account *account.Service
Returns *returns.Service
Shipments *shipment.Service
NDR *ndr.Service
// contains filtered or unexported fields
}
func NewClient ¶
Example ¶
package main
import (
"context"
"net/http"
"time"
shiprocket "github.com/Niyantra-Labs/shiprocket-gosdk"
"github.com/Niyantra-Labs/shiprocket-gosdk/account"
"github.com/Niyantra-Labs/shiprocket-gosdk/channels"
"github.com/Niyantra-Labs/shiprocket-gosdk/courier"
"github.com/Niyantra-Labs/shiprocket-gosdk/international"
"github.com/Niyantra-Labs/shiprocket-gosdk/inventory"
"github.com/Niyantra-Labs/shiprocket-gosdk/listings"
"github.com/Niyantra-Labs/shiprocket-gosdk/location"
"github.com/Niyantra-Labs/shiprocket-gosdk/ndr"
"github.com/Niyantra-Labs/shiprocket-gosdk/orders"
"github.com/Niyantra-Labs/shiprocket-gosdk/products"
"github.com/Niyantra-Labs/shiprocket-gosdk/returns"
"github.com/Niyantra-Labs/shiprocket-gosdk/shipment"
)
func main() {
client := shiprocket.NewClient(shiprocket.Config{
Token: "your-token",
HTTPClient: &http.Client{
Timeout: 30 * time.Second,
},
UserAgent: "example-app/1.0",
})
_, _ = client.Orders.CreateCustomOrder(context.Background(), &orders.CreateCustomOrderRequest{
OrderRequestFields: orders.OrderRequestFields{
ReferenceOrderID: "ref-1001",
OrderDate: "2026-07-23 10:00",
PickupLocation: "Primary Warehouse",
BillingCustomerName: "Jane",
BillingAddress: "Street 1",
BillingCity: "Delhi",
BillingPincode: "110001",
BillingState: "Delhi",
BillingCountry: "India",
BillingEmail: "jane@example.com",
BillingPhone: "9999999999",
OrderItems: []orders.OrderItem{
{Name: "Widget", Sku: "W-1", Units: 1, SellingPrice: "499"},
},
PaymentMethod: "Prepaid",
SubTotal: 499,
Length: 10,
Breadth: 10,
Height: 10,
Weight: 0.5,
},
})
label, _ := client.Shipments.GenerateLabel(context.Background(), &shipment.GenerateLabelRequest{
ShipmentID: []int64{16104408},
})
if label != nil {
_, _ = client.Shipments.DownloadArtifact(context.Background(), label.LabelURL)
}
_, _ = client.Returns.CreateReturnOrder(context.Background(), &returns.CreateReturnOrderRequest{
OrderID: "R-1001",
OrderDate: "2026-07-23",
PickupCustomerName: "Jane",
PickupAddress: "Customer Street 1",
PickupCity: "Delhi",
PickupState: "Delhi",
PickupCountry: "India",
PickupPincode: "110001",
PickupEmail: "jane@example.com",
PickupPhone: "9999999999",
ShippingCustomerName: "Warehouse",
ShippingAddress: "Return Hub",
ShippingCity: "Delhi",
ShippingCountry: "India",
ShippingPincode: "110002",
ShippingState: "Delhi",
ShippingPhone: "8888888888",
OrderItems: []returns.ReturnOrderItem{
{Name: "Widget", SKU: "W-1", Units: 1, SellingPrice: "499"},
},
PaymentMethod: "PREPAID",
SubTotal: 499,
Length: 10,
Breadth: 10,
Height: 10,
Weight: 0.5,
})
_, _ = client.NDR.Act(context.Background(), &ndr.ActionRequest{
AWB: "8373927474982",
Action: ndr.ActionReturn,
Comments: "Customer refused delivery",
})
_, _ = client.Products.Create(context.Background(), &products.CreateRequest{
Name: "Batman451",
CategoryCode: "default",
Type: "Single",
Qty: "10",
SKU: "b118771212",
})
_, _ = client.Listings.Link(context.Background(), &listings.LinkRequest{
ProductID: "17484610",
ListingID: "15897064",
ID: "manual-map-1",
})
_, _ = client.Channels.Create(context.Background(), &channels.CreateRequest{
Name: "MANUAL-25149",
BrandName: "SIORA-12",
})
_, _ = client.Inventory.Update(context.Background(), &inventory.UpdateRequest{
ProductID: "3448631",
Payload: &inventory.UpdatePayload{
Quantity: "51",
Action: "set",
},
})
_, _ = client.Location.GetPostcodeDetails(context.Background(), &location.PostcodeDetailsRequest{
Postcode: "110077",
})
_, _ = client.Account.GetStatement(context.Background(), &account.StatementParams{
Page: 1,
PerPage: 20,
})
_, _ = client.International.CheckServiceability(context.Background(), &international.ServiceabilityParams{
Weight: "10",
COD: 0,
DeliveryCountry: "US",
})
_, _ = client.Hyperlocal.CheckServiceability(context.Background(), &courier.ServiceabilityParams{
PickupPostcode: "110001",
DeliveryPostcode: "560034",
})
}
Output:
func (*Client) DoDownload ¶
func (*Client) HTTPClient ¶
type Config ¶
type Config struct {
BaseURL string
Token string
TokenSource TokenSource
Credentials *Credentials
HTTPClient *http.Client
Timeout time.Duration
UserAgent string
Logger Logger
Hooks []Hook
Middleware []Middleware
}
type Credentials ¶
type Download ¶
type Download = internalclient.Download
type Hook ¶
type Hook = internalclient.Hook
type Logger ¶
type Logger = internalclient.Logger
type LoginRequest ¶
type LoginRequest = auth.LoginRequest
type LoginResponse ¶
type LoginResponse = auth.LoginResponse
type Middleware ¶
type Middleware = internalclient.Middleware
type MultipartBody ¶
type MultipartBody = internalclient.MultipartBody
type MultipartFile ¶
type MultipartFile = internalclient.MultipartFile
type RateLimitError ¶
type RateLimitError = internalclient.RateLimitError
type Request ¶
type Request = internalclient.Request
type ResponseMeta ¶
type ResponseMeta = internalclient.ResponseMeta
type ServerError ¶
type ServerError = internalclient.ServerError
type StaticTokenSource ¶
type StaticTokenSource struct {
TokenValue string
}
type TokenSource ¶
type TokenSource = internalclient.TokenSource
type TransportError ¶
type TransportError = internalclient.TransportError
type ValidationError ¶
type ValidationError = internalclient.ValidationError
Directories
¶
| Path | Synopsis |
|---|---|
|
docs
|
|
|
examples/act-on-ndr
command
|
|
|
examples/assign-awb
command
|
|
|
examples/auth-login
command
|
|
|
examples/create-channel-order
command
|
|
|
examples/create-custom-order
command
|
|
|
examples/create-return-order
command
|
|
|
examples/generate-documents
command
|
|
|
examples/generate-pickup
command
|
|
|
examples/import-and-check-status
command
|
|
|
examples/track-shipment
command
|
|
|
internal
|
|
Click to show internal directories.
Click to hide internal directories.