Categorygithub.com/grab/grabfood-api-sdk-go
repositorypackage
1.0.1
Repository: https://github.com/grab/grabfood-api-sdk-go.git
Documentation: pkg.go.dev

# README

Go API client for GrabFood

Overview

This API client was generated by the OpenAPI Generator project. By using the OpenAPI-spec from a remote server, you can easily generate an API client.

  • API version: 1.1.3
  • Package version: 1.0.1
  • Generator version: 7.8.0
  • Build package: org.openapitools.codegen.languages.GoClientCodegen

For more information, please visit https://developer.grab.com

Installation

go get github.com/grab/grabfood-api-sdk-go

Put the package under your project folder and add the following in import:

import grabfood "github.com/grab/grabfood-api-sdk-go"

Usage Example

In the example below, we start by acquiring an OAuth2 access token. In your applications, it's important to handle OAuth2 tokens efficiently. This means:

  • Store the received access token once it's obtained.
  • Use this stored access token for as long as it's valid.
  • Only request a new access token when the current one has expired.

By following these practices, you minimize the number of requests to the server, making your application more efficient and responsive.

You can usually determine the validity of a token by the expires_in attribute in the OAuth2 token response.

config := grabfood.NewConfiguration()
apiClient := grabfood.NewAPIClient(config)
ctx := context.WithValue(context.Background(), grabfood.ContextServerIndex, grabfood.StgEnv)

grabOauthRequest := *grabfood.NewGrabOauthRequest("client_id", "client_secret", "client_credentials", "food.partner_api")

authResp, _, _ := apiClient.GetOauthGrabAPI.GetOauthGrab(ctx).GrabOauthRequest(grabOauthRequest).Execute()

// Request a new token only when the previous one has expired.
// Can utilize the `expires_in` from *authResp.ExpiresIn to determine the validity of the token.
ACCESS_TOKEN := *authResp.AccessToken

authorization := "Bearer " + ACCESS_TOKEN
merchantID := "1-CYNGRUNGSBCCC"
resp, _, _ := apiClient.GetStoreHourAPI.GetStoreHour(ctx, merchantID).Authorization(authorization).Execute()

fmt.Printf("Response from `GetStoreHourAPI.GetStoreHour`: %+v\n", resp)

For handling webhook requests, we provide dedicated models for both requests and responses. Please refer to the list of available models provided below for more details.

Documentation for API Endpoints

The base URL for OAuth2 URIs is https://api.grab.com

For other GrabFood partner API endpoints, URIs are relative to https://partner-api.grab.com/grabfood

ClassMethodHTTP requestDescription
AcceptRejectOrderAPIAcceptRejectOrderPost /partner/v1/order/prepareManually accept/reject orders
CancelOrderAPICancelOrderPut /partner/v1/order/cancelCancel an order
CheckOrderCancelableAPICheckOrderCancelableGet /partner/v1/order/cancelableCheck order cancelable
CreateCampaignAPICreateCampaignPost /partner/v1/campaignsCreate campaign
CreateSelfServeJourneyAPICreateSelfServeJourneyPost /partner/v1/self-serve/activationCreate self serve journey
DeleteCampaignAPIDeleteCampaignDelete /partner/v1/campaigns/{campaign_id}Delete campaigns
EditOrderAPIEditOrderPut /partner/v1/orders/{orderID}Edit Order
GetDineinVoucherAPIGetDineinVoucherGet /partner/v1/dinein/voucherGet Dine In Voucher
GetOauthGrabAPIGetOauthGrabPost /grabid/v1/oauth2/tokenGet Oauth access token
GetStoreHourAPIGetStoreHourGet /partner/v2/merchants/{merchantID}/store/hoursGet Store Hours
GetStoreStatusAPIGetStoreStatusGet /partner/v1/merchants/{merchantID}/store/statusGet Store Status
ListCampaignAPIListCampaignGet /partner/v1/campaignsList campaigns
ListOrdersAPIListOrdersGet /partner/v1/ordersList orders
MarkOrderReadyAPIMarkOrderReadyPost /partner/v1/orders/markMark order as ready
NotifyMembershipWebviewAPINotifyMembershipWebviewPost /partner/v1/membership/notifyNotify Membership
PauseStoreAPIPauseStorePut /partner/v1/merchant/pausePause store
RedeemDineinVoucherAPIRedeemDineinVoucherPost /partner/v1/dinein/voucher/redeemRedeem Dine In Voucher
TraceMenuSyncAPITraceMenuSyncGet /partner/v1/merchant/menu/traceTrace menu sync
UpdateCampaignAPIUpdateCampaignPut /partner/v1/campaigns/{campaign_id}Update campaign
UpdateDeliveryStateAPIUpdateDeliveryStatePost /partner/v1/order/deliveryUpdate delivery state
UpdateMenuNotificationAPIUpdateMenuNotificationPost /partner/v1/merchant/menu/notificationNotify Grab of updated menu
UpdateMenuRecordAPIBatchUpdateMenuPut /partner/v1/batch/menuBatch Update Menu
UpdateMenuRecordAPIUpdateMenuPut /partner/v1/menuUpdate menu record
UpdateOrderReadyTimeAPIUpdateOrderReadyTimePut /partner/v1/order/readytimeUpdate new order ready time
UpdateStoreDeliveryHourAPIUpdateStoreDeliveryHourPut /partner/v1/merchants/{merchantID}/store/opening-hoursUpdate Store Delivery Hours
UpdateStoreDineInHourAPIUpdateStoreDineInHourPut /partner/v1/merchants/{merchantID}/store/dine-in-hoursUpdate Store Dine-in Hours
UpdateStoreSpecialHourAPIUpdateStoreSpecialHourPut /partner/v2/merchants/{merchantID}/store/special-opening-hourUpdate Store Special Hours

Documentation For Models

Documentation for Utility Methods

Due to the fact that model structure members are all pointers, this package contains a number of utility functions to easily obtain pointers to values of basic types. Each of these functions takes a value of the given basic type and returns a pointer to it:

  • PtrBool
  • PtrInt
  • PtrInt32
  • PtrInt64
  • PtrFloat
  • PtrFloat32
  • PtrFloat64
  • PtrString
  • PtrTime