Skip to content

Commit

Permalink
remove "Output" postfixes from model names
Browse files Browse the repository at this point in the history
  • Loading branch information
d5 committed Sep 1, 2016
1 parent b6b7195 commit ac0ae94
Show file tree
Hide file tree
Showing 23 changed files with 113 additions and 113 deletions.
14 changes: 7 additions & 7 deletions client/address.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,32 +9,32 @@ import (
)

// CreateAddress creates a new address object.
func (c *Client) CreateAddress(input *models.AddressInput) (*models.AddressOutput, error) {
func (c *Client) CreateAddress(input *models.AddressInput) (*models.Address, error) {
if input == nil {
return nil, errors.New("nil input")
}

output := &models.AddressOutput{}
output := &models.Address{}
err := c.do(http.MethodPost, "/addresses/", input, output)
return output, err
}

// RetrieveAddress retrieves an existing address by object id.
func (c *Client) RetrieveAddress(objectID string) (*models.AddressOutput, error) {
func (c *Client) RetrieveAddress(objectID string) (*models.Address, error) {
if objectID == "" {
return nil, errors.New("Empty object ID")
}

output := &models.AddressOutput{}
output := &models.Address{}
err := c.do(http.MethodGet, "/addresses/"+objectID, nil, output)
return output, err
}

// ListAllAddresses lists all addresses.
func (c *Client) ListAllAddresses() ([]*models.AddressOutput, error) {
list := []*models.AddressOutput{}
func (c *Client) ListAllAddresses() ([]*models.Address, error) {
list := []*models.Address{}
err := c.doList(http.MethodGet, "/addresses/", nil, func(v json.RawMessage) error {
item := &models.AddressOutput{}
item := &models.Address{}
if err := json.Unmarshal(v, item); err != nil {
return err
}
Expand Down
16 changes: 8 additions & 8 deletions client/batch.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
// RetrieveBatch retrieves an existing batch. BatchShipments are displayed 100 at a time.
// You can iterate through each "page" by specifying non-zero value to page parameter.
// You can also filter based on BatchShipment status using objectResultsFilter parameter
func (c *Client) RetrieveBatch(objectID string, page uint, objectResultsFilter string) (*models.BatchOutput, error) {
func (c *Client) RetrieveBatch(objectID string, page uint, objectResultsFilter string) (*models.Batch, error) {
if objectID == "" {
return nil, errors.New("Empty object ID")
}
Expand All @@ -29,35 +29,35 @@ func (c *Client) RetrieveBatch(objectID string, page uint, objectResultsFilter s
url += "?" + strings.Join(qs, "&")
}

output := &models.BatchOutput{}
output := &models.Batch{}
err := c.do(http.MethodGet, url, nil, output)
return output, err
}

// AddBatchShipmentsToBatch adds batch shipment(s) to an existing Batch.
func (c *Client) AddBatchShipmentsToBatch(objectID string, batchShipments []*models.BatchShipmentInput) (*models.BatchOutput, error) {
func (c *Client) AddBatchShipmentsToBatch(objectID string, batchShipments []*models.BatchShipmentInput) (*models.Batch, error) {
if objectID == "" {
return nil, errors.New("Empty object ID")
}
if batchShipments == nil {
return nil, errors.New("nil batch shipments")
}

output := &models.BatchOutput{}
output := &models.Batch{}
err := c.do(http.MethodPost, "/batches/"+objectID+"/add_shipments", &batchShipments, output)
return output, err
}

// RemoveBatchShipmentsFromBatch removes batch shipment(s) from an existing Batch.
func (c *Client) RemoveBatchShipmentsFromBatch(objectID string, batchShipmentIDs []string) (*models.BatchOutput, error) {
func (c *Client) RemoveBatchShipmentsFromBatch(objectID string, batchShipmentIDs []string) (*models.Batch, error) {
if objectID == "" {
return nil, errors.New("Empty object ID")
}
if batchShipmentIDs == nil {
return nil, errors.New("nil batch shipment IDs")
}

output := &models.BatchOutput{}
output := &models.Batch{}
err := c.do(http.MethodPost, "/batches/"+objectID+"/remove_shipments", &batchShipmentIDs, output)
return output, err
}
Expand All @@ -66,12 +66,12 @@ func (c *Client) RemoveBatchShipmentsFromBatch(objectID string, batchShipmentIDs
// Once you send invoke this function, the batch ObjectStatus will be change to PURCHASING.
// When all the shipments are purchased, the ObjectStatus will change to PURCHASED
// and you will receive a batch_purchased webhook indicating that the batch has been purchased.
func (c *Client) PurchaseBatch(objectID string) (*models.BatchOutput, error) {
func (c *Client) PurchaseBatch(objectID string) (*models.Batch, error) {
if objectID == "" {
return nil, errors.New("Empty object ID")
}

output := &models.BatchOutput{}
output := &models.Batch{}
err := c.do(http.MethodPost, "/batches/"+objectID+"/purchase", nil, output)
return output, err
}
18 changes: 9 additions & 9 deletions client/carrier_account.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,32 +9,32 @@ import (
)

// CreateCarrierAccount creates a new carrier account object.
func (c *Client) CreateCarrierAccount(input *models.CarrierAccountInput) (*models.CarrierAccountOutput, error) {
func (c *Client) CreateCarrierAccount(input *models.CarrierAccountInput) (*models.CarrierAccount, error) {
if input == nil {
return nil, errors.New("nil input")
}

output := &models.CarrierAccountOutput{}
output := &models.CarrierAccount{}
err := c.do(http.MethodPost, "/carrier_accounts/", input, output)
return output, err
}

// RetrieveCarrierAccount retrieves an existing carrier account by object id.
func (c *Client) RetrieveCarrierAccount(objectID string) (*models.CarrierAccountOutput, error) {
func (c *Client) RetrieveCarrierAccount(objectID string) (*models.CarrierAccount, error) {
if objectID == "" {
return nil, errors.New("Empty object ID")
}

output := &models.CarrierAccountOutput{}
output := &models.CarrierAccount{}
err := c.do(http.MethodGet, "/carrier_accounts/"+objectID, nil, output)
return output, err
}

// ListAllCarrierAccounts lists all carrier accounts.
func (c *Client) ListAllCarrierAccounts() ([]*models.CarrierAccountOutput, error) {
list := []*models.CarrierAccountOutput{}
func (c *Client) ListAllCarrierAccounts() ([]*models.CarrierAccount, error) {
list := []*models.CarrierAccount{}
err := c.doList(http.MethodGet, "/carrier_accounts/", nil, func(v json.RawMessage) error {
item := &models.CarrierAccountOutput{}
item := &models.CarrierAccount{}
if err := json.Unmarshal(v, item); err != nil {
return err
}
Expand All @@ -47,15 +47,15 @@ func (c *Client) ListAllCarrierAccounts() ([]*models.CarrierAccountOutput, error

// UpdateCarrierAccount updates an existing carrier account.
// AccountID and Carrier cannot be updated because they form the unique identifier together.
func (c *Client) UpdateCarrierAccount(objectID string, input *models.CarrierAccountInput) (*models.CarrierAccountOutput, error) {
func (c *Client) UpdateCarrierAccount(objectID string, input *models.CarrierAccountInput) (*models.CarrierAccount, error) {
if objectID == "" {
return nil, errors.New("Empty object ID")
}
if input == nil {
return nil, errors.New("nil input")
}

output := &models.CarrierAccountOutput{}
output := &models.CarrierAccount{}
err := c.do(http.MethodPut, "/carrier_accounts/"+objectID, input, output)
return output, err
}
28 changes: 14 additions & 14 deletions client/customs.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,32 +9,32 @@ import (
)

// CreateCustomsItem creates a new customs item object.
func (c *Client) CreateCustomsItem(input *models.CustomsItemInput) (*models.CustomsItemOutput, error) {
func (c *Client) CreateCustomsItem(input *models.CustomsItemInput) (*models.CustomsItem, error) {
if input == nil {
return nil, errors.New("nil input")
}

output := &models.CustomsItemOutput{}
output := &models.CustomsItem{}
err := c.do(http.MethodPost, "/customs/items/", input, output)
return output, err
}

// RetrieveCustomsItem retrieves an existing customs item by object id.
func (c *Client) RetrieveCustomsItem(objectID string) (*models.CustomsItemOutput, error) {
func (c *Client) RetrieveCustomsItem(objectID string) (*models.CustomsItem, error) {
if objectID == "" {
return nil, errors.New("Empty object ID")
}

output := &models.CustomsItemOutput{}
output := &models.CustomsItem{}
err := c.do(http.MethodGet, "/customs/items/"+objectID, nil, output)
return output, err
}

// ListAllCustomsItems lists all customs item objects.
func (c *Client) ListAllCustomsItems() ([]*models.CustomsItemOutput, error) {
list := []*models.CustomsItemOutput{}
func (c *Client) ListAllCustomsItems() ([]*models.CustomsItem, error) {
list := []*models.CustomsItem{}
err := c.doList(http.MethodGet, "/customs/items/", nil, func(v json.RawMessage) error {
item := &models.CustomsItemOutput{}
item := &models.CustomsItem{}
if err := json.Unmarshal(v, item); err != nil {
return err
}
Expand All @@ -46,32 +46,32 @@ func (c *Client) ListAllCustomsItems() ([]*models.CustomsItemOutput, error) {
}

// CreateCustomsDeclaration creates a new customs declaration object.
func (c *Client) CreateCustomsDeclaration(input *models.CustomsDeclarationInput) (*models.CustomsDeclarationOutput, error) {
func (c *Client) CreateCustomsDeclaration(input *models.CustomsDeclarationInput) (*models.CustomsDeclaration, error) {
if input == nil {
return nil, errors.New("nil input")
}

output := &models.CustomsDeclarationOutput{}
output := &models.CustomsDeclaration{}
err := c.do(http.MethodPost, "/customs/declarations/", input, output)
return output, err
}

// RetrieveCustomsDeclaration retrieves an existing customs declaration by object id.
func (c *Client) RetrieveCustomsDeclaration(objectID string) (*models.CustomsDeclarationOutput, error) {
func (c *Client) RetrieveCustomsDeclaration(objectID string) (*models.CustomsDeclaration, error) {
if objectID == "" {
return nil, errors.New("Empty object ID")
}

output := &models.CustomsDeclarationOutput{}
output := &models.CustomsDeclaration{}
err := c.do(http.MethodGet, "/customs/declarations/"+objectID, nil, output)
return output, err
}

// ListAllCustomsDeclaration lists all customs declaration objects.
func (c *Client) ListAllCustomsDeclaration() ([]*models.CustomsDeclarationOutput, error) {
list := []*models.CustomsDeclarationOutput{}
func (c *Client) ListAllCustomsDeclaration() ([]*models.CustomsDeclaration, error) {
list := []*models.CustomsDeclaration{}
err := c.doList(http.MethodGet, "/customs/declarations/", nil, func(v json.RawMessage) error {
item := &models.CustomsDeclarationOutput{}
item := &models.CustomsDeclaration{}
if err := json.Unmarshal(v, item); err != nil {
return err
}
Expand Down
14 changes: 7 additions & 7 deletions client/manifest.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,32 +9,32 @@ import (
)

// CreateManifest creates a new manifest object.
func (c *Client) CreateManifest(input *models.ManifestInput) (*models.ManifestOutput, error) {
func (c *Client) CreateManifest(input *models.ManifestInput) (*models.Manifest, error) {
if input == nil {
return nil, errors.New("nil input")
}

output := &models.ManifestOutput{}
output := &models.Manifest{}
err := c.do(http.MethodPost, "/manifests/", input, output)
return output, err
}

// RetrieveManifest retrieves an existing manifest by object id.
func (c *Client) RetrieveManifest(objectID string) (*models.ManifestOutput, error) {
func (c *Client) RetrieveManifest(objectID string) (*models.Manifest, error) {
if objectID == "" {
return nil, errors.New("Empty object ID")
}

output := &models.ManifestOutput{}
output := &models.Manifest{}
err := c.do(http.MethodGet, "/manifests/"+objectID, nil, output)
return output, err
}

// ListAllManifests lists all manifest objects.
func (c *Client) ListAllManifests() ([]*models.ManifestOutput, error) {
list := []*models.ManifestOutput{}
func (c *Client) ListAllManifests() ([]*models.Manifest, error) {
list := []*models.Manifest{}
err := c.doList(http.MethodGet, "/manifests/", nil, func(v json.RawMessage) error {
item := &models.ManifestOutput{}
item := &models.Manifest{}
if err := json.Unmarshal(v, item); err != nil {
return err
}
Expand Down
14 changes: 7 additions & 7 deletions client/parcel.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,32 +9,32 @@ import (
)

// CreateParcel creates a new parcel object.
func (c *Client) CreateParcel(input *models.ParcelInput) (*models.ParcelOutput, error) {
func (c *Client) CreateParcel(input *models.ParcelInput) (*models.Parcel, error) {
if input == nil {
return nil, errors.New("nil input")
}

output := &models.ParcelOutput{}
output := &models.Parcel{}
err := c.do(http.MethodPost, "/parcels/", input, output)
return output, err
}

// RetrieveParcel retrieves an existing parcel by object id.
func (c *Client) RetrieveParcel(objectID string) (*models.ParcelOutput, error) {
func (c *Client) RetrieveParcel(objectID string) (*models.Parcel, error) {
if objectID == "" {
return nil, errors.New("Empty object ID")
}

output := &models.ParcelOutput{}
output := &models.Parcel{}
err := c.do(http.MethodGet, "/parcels/"+objectID, nil, output)
return output, err
}

// ListAllParcels lists all parcel objects.
func (c *Client) ListAllParcels() ([]*models.ParcelOutput, error) {
list := []*models.ParcelOutput{}
func (c *Client) ListAllParcels() ([]*models.Parcel, error) {
list := []*models.Parcel{}
err := c.doList(http.MethodGet, "/parcels/", nil, func(v json.RawMessage) error {
item := &models.ParcelOutput{}
item := &models.Parcel{}
if err := json.Unmarshal(v, item); err != nil {
return err
}
Expand Down
16 changes: 8 additions & 8 deletions client/rate.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@ import (
)

// GetShippingRates gets rates for a shipping object.
func (c *Client) GetShippingRates(shipmentObjectID, currencyCode string) ([]*models.RateOutput, error) {
func (c *Client) GetShippingRates(shipmentObjectID, currencyCode string) ([]*models.Rate, error) {
if shipmentObjectID == "" {
return nil, errors.New("Empty shipment object ID")
}
if currencyCode == "" {
return nil, errors.New("Empty currency code")
}

list := []*models.RateOutput{}
list := []*models.Rate{}
err := c.doList(http.MethodGet, "/shipments/"+shipmentObjectID+"/rates/"+currencyCode, nil, func(v json.RawMessage) error {
item := &models.RateOutput{}
item := &models.Rate{}
if err := json.Unmarshal(v, item); err != nil {
return err
}
Expand All @@ -31,21 +31,21 @@ func (c *Client) GetShippingRates(shipmentObjectID, currencyCode string) ([]*mod
}

// RetrieveRate retrieves an existing rate by object id.
func (c *Client) RetrieveRate(objectID string) (*models.RateOutput, error) {
func (c *Client) RetrieveRate(objectID string) (*models.Rate, error) {
if objectID == "" {
return nil, errors.New("Empty object ID")
}

output := &models.RateOutput{}
output := &models.Rate{}
err := c.do(http.MethodGet, "/rates/"+objectID, nil, output)
return output, err
}

// ListAllRates lists all the rate objects that have been previously obtained through GetShippingRates function.
func (c *Client) ListAllRates() ([]*models.RateOutput, error) {
list := []*models.RateOutput{}
func (c *Client) ListAllRates() ([]*models.Rate, error) {
list := []*models.Rate{}
err := c.doList(http.MethodGet, "/rates/", nil, func(v json.RawMessage) error {
item := &models.RateOutput{}
item := &models.Rate{}
if err := json.Unmarshal(v, item); err != nil {
return err
}
Expand Down
Loading

0 comments on commit ac0ae94

Please sign in to comment.