argonauts

package module
v0.0.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 29, 2024 License: MIT Imports: 9 Imported by: 0

README

DANA Ventures Logo

Argonauts Client for Go

Go library for accessing Open APIs provided by Argonauts: a package delivery system created by DANA Ventures.

Please check the example directory to get some examples on how to use this library.

Command to run an example:

go run example/*.go -f GetRatesV3

Add this library to your project dependencies with command below:

go get bitbucket.org/cp18/argonauts-client-go

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	PathGetRatesV3               = mappingPath{http.MethodGet, "/v3/getrates"}
	PathCreateOrderV3            = mappingPath{http.MethodPost, "/v3/order"}
	PathActivateOrderV3          = mappingPath{http.MethodPost, "/v3/order/{publicId}/activate"}
	PathGetOrderListV3           = mappingPath{http.MethodGet, "/v3/order"}
	PathGetOrderDetailsV3        = mappingPath{http.MethodGet, "/v3/order/{publicId}"}
	PathCancelOrderV3            = mappingPath{http.MethodPost, "/v3/order/{publicId}/void"}
	PathPreOrderV4               = mappingPath{http.MethodPost, "/v4/order"}
	PathRequestPickupV4          = mappingPath{http.MethodPost, "/v4/order/{publicId}/activate"}
	PathCreateOrEditDraftOrderV4 = mappingPath{http.MethodPost, "/v4/order/draft"}
	PathGetRatesV4               = mappingPath{http.MethodGet, "/v4/getrates"}
)

Functions

This section is empty.

Types

type ActivateOrderV3Request

type ActivateOrderV3Request struct {
}

type ActivateOrderV3Response

type ActivateOrderV3Response struct {
}

type BaseResponse

type BaseResponse struct {
	Status string `json:"status"`
	Error  struct {
		Code        string `json:"code"`
		Description string `json:"description"`
	}
}

func (BaseResponse) IsSuccess

func (r BaseResponse) IsSuccess() bool

type CancelOrderV3Request

type CancelOrderV3Request struct {
}

type CancelOrderV3Response

type CancelOrderV3Response struct {
}

type Client

type Client interface {
	WithEnv(env Env) Client
	WithApiKey(apiKey string) Client
	WithSecretKey(secretKey string) Client
	WithLogger(logger Logger) Client
	WithDebug(debug bool) Client
	WithTimeout(timeout time.Duration) Client

	// GetRatesV3 returns the list of logistic services and the rates available in Argonauts for the specified parameters.
	GetRatesV3(ctx context.Context, req GetRatesV3Request) (GetRatesV3Response, error)

	CreateOrderV3(ctx context.Context, req CreateOrderV3Request) (CreateOrderV3Response, error)
	ActivateOrderV3(ctx context.Context, req ActivateOrderV3Request) (ActivateOrderV3Response, error)
	GetOrderListV3(ctx context.Context, req GetOrderListV3Request) (GetOrderListV3Response, error)

	// GetOrderDetailsV3 returns the details of specified order public ID.
	GetOrderDetailsV3(ctx context.Context, req GetOrderDetailsV3Request) (GetOrderDetailsV3Response, error)

	CancelOrderV3(ctx context.Context, req CancelOrderV3Request) (CancelOrderV3Response, error)

	// PreOrderV4 creates a pre-order request to Argonauts for the chosen service ID and returns the AWB
	// if the logistic service support pre-order request.
	PreOrderV4(ctx context.Context, req PreOrderV4Request) (PreOrderV4Response, error)

	// RequestPickupV4 sends a request for pickup to Argonauts for the delivery order.
	// A pre-order request (PreOrderV4) must have been made prior to calling this method.
	RequestPickupV4(ctx context.Context, req RequestPickupV4Request) (RequestPickupV4Response, error)

	// CerateOrEditDraftOrderV4 creates a draft order in Argonauts when the OrderID is not set in the request body
	// and edits the draft order when the OrderID is set.
	CreateOrEditDraftOrderV4(ctx context.Context, req CreateOrEditDraftOrderV4Request) (CreateOrEditDraftOrderV4Response, error)

	// GetRatesV4 returns the list of logistic services and the rates available in Argonauts for the specified parameters.
	// with additional parameters
	GetRatesV4(ctx context.Context, req GetRatesV4Request) (GetRatesV4Response, error)
}

func NewClient

func NewClient(env Env) Client

type Coordinate

type Coordinate struct {
	Latitude  float64 `json:"latitude"`
	Longitude float64 `json:"longitude"`
}

type CreateOrEditDraftOrderV4Request

type CreateOrEditDraftOrderV4Request struct {
	OrderID             *string                     `json:"order_id"`
	ServiceID           string                      `json:"service_id"`
	IsInsured           bool                        `json:"is_insured"`
	ClientTransactionID string                      `json:"client_transaction_id"`
	Sender              ShippingOrderAddressDetails `json:"sender"`
	Recipient           ShippingOrderAddressDetails `json:"recipient"`
	Package             ShippingOrderPackageDetails `json:"package"`
	Source              string                      `json:"source"`
}

type CreateOrEditDraftOrderV4Response

type CreateOrEditDraftOrderV4Response struct {
	BaseResponse
	Payload struct {
		ID                  string                      `json:"id"`
		PublicID            string                      `json:"public_id"`
		ClientID            string                      `json:"client_id"`
		ServiceID           string                      `json:"service_id"`
		IsInsured           bool                        `json:"is_insured"`
		Source              string                      `json:"source"`
		ClientTransactionID string                      `json:"client_transaction_id"`
		ClientPublishRate   float64                     `json:"client_publish_rate"`
		ClientMargin        float64                     `json:"client_margin"`
		FinalPublishRate    float64                     `json:"final_publish_rate"`
		Package             ShippingOrderPackageDetails `json:"package"`
		Sender              ShippingOrderAddressDetails `json:"sender"`
		Recipient           ShippingOrderAddressDetails `json:"recipient"`
	}
}

type CreateOrderV3Request

type CreateOrderV3Request struct {
}

type CreateOrderV3Response

type CreateOrderV3Response struct {
}

type DefaultLog

type DefaultLog struct {
}

func (*DefaultLog) Print

func (l *DefaultLog) Print(v ...interface{})

type Dimension

type Dimension struct {
	Length float32 `json:"length"`
	Width  float32 `json:"width"`
	Height float32 `json:"height"`
}

type Env

type Env int
const (
	EnvStaging Env = iota + 1
	EnvProduction
)

type GetOrderDetailsV3Request

type GetOrderDetailsV3Request struct {
	PublicID string
}

type GetOrderDetailsV3Response

type GetOrderDetailsV3Response struct {
	BaseResponse
	Payload struct {
		PublicID               string                       `json:"public_id"`
		PaymentMethod          string                       `json:"payment_method"`
		CommissionRate         float32                      `json:"commission_rate"`
		IsInsured              bool                         `json:"is_insured"`
		AmountDeliveryRate     float32                      `json:"amount_delivery_rate"`
		AdditionalFee          float32                      `json:"additional_fee"`
		AmountWHTRate          float32                      `json:"amount_wht_rate"`
		AmountVATRate          float32                      `json:"amount_vat_rate"`
		AmountTransactionFee   float32                      `json:"amount_transaction_fee"`
		AmountInsurancePremium float32                      `json:"amount_insurance_premium"`
		AdditionalInsuranceFee float32                      `json:"additional_insurance_fee"`
		AmountTotal            float32                      `json:"amount_total"`
		PartnerDeliveryID      string                       `json:"partner_delivery_id"`
		AggregatorOrderID      string                       `json:"aggregator_order_id"`
		ClientTransactionID    string                       `json:"client_transaction_id"`
		PackageDetails         ShippingOrderPackageDetails2 `json:"package_details"`
		SenderDetails          ShippingOrderAddressDetails2 `json:"sender_details"`
		RecipientDetails       ShippingOrderAddressDetails2 `json:"recipient_details"`
		CarrierDetails         ShippingOrderCarrierDetails  `json:"carrier_details"`
		CreatedAt              time.Time                    `json:"created_at"`
		OrderHistories         []OrderHistory               `json:"order_histories"`
		PaymentHistories       []PaymentHistory             `json:"payment_histories"`
	}
}

type GetOrderListV3Request

type GetOrderListV3Request struct {
}

type GetOrderListV3Response

type GetOrderListV3Response struct {
}

type GetRatesV3Request

type GetRatesV3Request struct {
	Weight               float64 `json:"weight"`
	Dimension            string  `json:"dimension"`
	OriginLatitude       float64 `json:"origin_latitude"`
	OriginLongitude      float64 `json:"origin_longitude"`
	DestinationLatitude  float64 `json:"destination_latitude"`
	DestinationLongitude float64 `json:"destination_longitude"`
	ItemPrice            float64 `json:"item_price"`
	IsInsured            bool    `json:"is_insured"`
}

type GetRatesV3Response

type GetRatesV3Response struct {
	BaseResponse
	Payload []struct {
		ServiceID              string  `json:"id"`
		ServiceName            string  `json:"service_name"`
		ServiceType            string  `json:"service_type"`
		ServiceLogo            string  `json:"logo"`
		LogisticPartnerName    string  `json:"logistic_name"`
		LogisticPartnerID      string  `json:"logistic_partner_id"`
		LogisticPartnerLogo    string  `json:"logistic_partner_logo"`
		ETA                    string  `json:"eta"`
		ETADuration            string  `json:"eta_duration"`
		ETAUnit                string  `json:"eta_unit"`
		StartTime              string  `json:"start_time"`
		EndTime                string  `json:"end_time"`
		Rate                   float64 `json:"rate"`
		BaseRate               float64 `json:"base_rate"`
		AdditionalFee          float64 `json:"additional_fee"`
		Discount               float64 `json:"discount"`
		DiscountPercentage     float64 `json:"discount_percentage"`
		InsuranceFee           float64 `json:"insurance_fee"`
		AdditionalInsuranceFee float64 `json:"additional_insurance_fee"`
	} `json:"payload"`
}

type GetRatesV4Request

type GetRatesV4Request struct {
	Origin      LocationDetail `json:"origin"`
	Destination LocationDetail `json:"destination"`
	Package     PackageDetail  `json:"package"`
	IsInsured   bool           `json:"is_insured"`
}

type GetRatesV4Response

type GetRatesV4Response struct {
	BaseResponse
	Payload []struct {
		ID                string            `json:"id"`
		Name              string            `json:"name"`
		Type              string            `json:"type"`
		LogisticId        string            `json:"logistic_id"`
		LogisticName      string            `json:"logistic_name"`
		Eta               string            `json:"eta"`
		EtaDuration       string            `json:"eta_duration"`
		EtaUnit           string            `json:"eta_unit"`
		StartTime         string            `json:"start_time"`
		EndTime           string            `json:"end_time"`
		ClientPublishRate float64           `json:"client_publish_rate"`
		ClientMargin      float64           `json:"client_margin"`
		FinalPublishRate  float64           `json:"final_publish_rate"`
		Tnc               map[string]string `json:"tnc"`
		TypeDescription   []TypeDescription `json:"type_description"`
	}
}

type LocationDetail

type LocationDetail struct {
	Lat           float64 `json:"lat" `
	Long          float64 `json:"long"`
	SubdistrictId int     `json:"subdistrict_id"`
	PostalCode    int     `json:"postal_code"`
}

type Logger

type Logger interface {
	Print(v ...interface{})
}

type OrderHistory

type OrderHistory struct {
	State     string    `json:"state"`
	Status    string    `json:"status"`
	Remarks   string    `json:"remarks"`
	CreatedAt time.Time `json:"created_at"`
}

type PackageDetail

type PackageDetail struct {
	Weight    float32 `json:"weight"`
	Length    float32 `json:"length"`
	Height    float32 `json:"height"`
	Width     float32 `json:"width"`
	ItemPrice float32 `json:"item_price"`
	Type      string  `json:"type"`
}

type PaymentHistory

type PaymentHistory struct {
	State     string    `json:"state"`
	Status    string    `json:"status"`
	Remarks   string    `json:"remarks"`
	CreatedAt time.Time `json:"created_at"`
}

type PreOrderV4Request

type PreOrderV4Request struct {
	ServiceID           string                      `json:"service_id"`
	IsInsured           bool                        `json:"is_insured"`
	ClientTransactionID string                      `json:"client_transaction_id"`
	Sender              ShippingOrderAddressDetails `json:"sender"`
	Recipient           ShippingOrderAddressDetails `json:"recipient"`
	Package             ShippingOrderPackageDetails `json:"package"`
	Source              string                      `json:"source"`
}

type PreOrderV4Response

type PreOrderV4Response struct {
	BaseResponse
	Payload struct {
		PublicID            string                      `json:"public_id"`
		ServiceID           string                      `json:"service_id"`
		IsInsured           bool                        `json:"is_insured"`
		ClientTransactionID string                      `json:"client_transaction_id"`
		Package             ShippingOrderPackageDetails `json:"package"`
		Sender              ShippingOrderAddressDetails `json:"sender"`
		Recipient           ShippingOrderAddressDetails `json:"recipient"`
		Awb                 string                      `json:"awb"`
		CreatedAt           string                      `json:"created_at"`
	} `json:"payload"`
}

type RequestPickupV4Request

type RequestPickupV4Request struct {

	// Public ID of the order.
	PublicID string `json:"public_id"`

	// The preferred time for pickup, can be empty. Must be using the time layout of "2006-01-02T15:04:05-07:00".
	PickupTime *string `json:"pickup_time"`
}

type RequestPickupV4Response

type RequestPickupV4Response struct {
	BaseResponse
	Payload struct {
		OrderID           string `json:"order_id"`
		AWB               string `json:"awb"`
		AggregatorOrderID string `json:"aggregator_order_id"`
		PickupTime        string `json:"pickup_time"`
		LabelURL          string `json:"label_url"`
	}
}

type ShippingOrderAddressDetails

type ShippingOrderAddressDetails struct {
	Latitude           *float64 `json:"latitude"`
	Longitude          *float64 `json:"longitude"`
	FullName           string   `json:"fullname"`
	PhoneNumber        string   `json:"phone_number"`
	AddressBuilding    string   `json:"address_building"`
	AddressStreet      string   `json:"address_street"`
	AddressRemarks     string   `json:"address_remarks"`
	AddressCity        string   `json:"address_city"`
	AddressProvince    string   `json:"address_province"`
	AddressPostcode    string   `json:"address_postcode"`
	AddressDistrict    string   `json:"address_district"`
	AddressSubdistrict string   `json:"address_subdistrict"`
	SubdistrictID      int      `json:"subdistrict_id"`
}

type ShippingOrderAddressDetails2

type ShippingOrderAddressDetails2 struct {
	Coordinate      Coordinate `json:"coordinate"`
	Fullname        string     `json:"fullname"`
	PhoneNumber     string     `json:"phone_number"`
	AddressBuilding string     `json:"address_building"`
	AddressStreet   string     `json:"address_street"`
	AddressRemarks  string     `json:"address_remarks"`
	AddressCity     string     `json:"address_city"`
	AddressProvince string     `json:"address_province"`
	AddressPostcode string     `json:"address_postcode"`
	AddressGeohash  string     `json:"address_geohash"`
}

type ShippingOrderCarrierDetails

type ShippingOrderCarrierDetails struct {
	PartnerName         string `json:"partner_name"`
	DriverName          string `json:"driver_name"`
	DriverContactNumber string `json:"driver_contact_number"`
	VehicleNumber       string `json:"vehicle_number"`
	CourierName         string `json:"courier_name"`
	ServiceType         string `json:"service_type"`
	TrackURL            string `json:"track_url"`
	LabelURL            string `json:"label_url"`
	ProofOfDeliveryURL  string `json:"proof_of_delivery_url"`
	PickupTime          string `json:"pickup_time"`
}

type ShippingOrderPackageDetails

type ShippingOrderPackageDetails struct {
	Length          float64 `json:"length"`
	Width           float64 `json:"width"`
	Height          float64 `json:"height"`
	Weight          float64 `json:"weight"`
	PackageType     string  `json:"package_type"`
	Remarks         string  `json:"remarks"`
	PackageTypeInfo string  `json:"package_type_info"`
	ItemPrice       float64 `json:"item_price"`
}

type ShippingOrderPackageDetails2

type ShippingOrderPackageDetails2 struct {
	Dimension   Dimension `json:"dimension"`
	Weight      float32   `json:"weight"`
	PackageType string    `json:"package_type"`
	Remarks     string    `json:"remarks"`
	ItemPrice   float32   `json:"item_price"`
}

type TypeDescription

type TypeDescription struct {
	Type        string `json:"type,omitempty"`
	Description struct {
		EN string `json:"en,omitempty"`
		ID string `json:"id,omitempty"`
	} `json:"description,omitempty"`
}

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL