Skip to content

Commit

Permalink
Initital release
Browse files Browse the repository at this point in the history
  • Loading branch information
muhamad-lukman-grab committed Sep 27, 2024
0 parents commit d508934
Show file tree
Hide file tree
Showing 308 changed files with 69,656 additions and 0 deletions.
30 changes: 30 additions & 0 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven
#
# This file is auto-generated by OpenAPI Generator (https://openapi-generator.tech)

name: Java CI with Maven

on:
push:
branches: [ main, master ]
pull_request:
branches: [ main, master ]

jobs:
build:
name: Build GrabFood
runs-on: ubuntu-latest
strategy:
matrix:
java: [ 17, 21 ]
steps:
- uses: actions/checkout@v4
- name: Set up JDK
uses: actions/setup-java@v4
with:
java-version: ${{ matrix.java }}
distribution: 'temurin'
cache: maven
- name: Build with Maven
run: mvn -B package --no-transfer-progress --file pom.xml
23 changes: 23 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
*.class

# Mobile Tools for Java (J2ME)
.mtj.tmp/

# Package Files #
*.jar
*.war
*.ear

# exclude jar for gradle wrapper
!gradle/wrapper/*.jar

# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*

# build files
**/target
target
.gradle
build

.DS_Store
33 changes: 33 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Contributing to Our Project's SDK

We value your input and contributions! We use the [OpenAPI Generator tool](https://openapi-generator.tech) to generate our SDK based on an OpenAPI YAML specification.

If you find an issue with our SDK and want to contribute a fix, follow the guidelines mentioned below:

## Reporting an Issue

1. Notice an issue while using the SDK? Try to determine what's causing it. Was it a particular endpoint, operation, or datatype?

2. Check the YAML specification: Once you've identified the issue, refer to the corresponding definition in the OpenAPI YAML specification file that is included in the SDK. This could be a specific path, operation, parameter, or schema.

3. Describe the current behavior and desired correct behavior.

4. Describe the steps to reproduce this issue.

Please note that due to our open-source process, we don't have a direct way to accept code contributions for the SDK. The SDK is directly generated from our OpenAPI YAML specification file. Hence, you don't need to manually update the SDK. Instead, identify the modifications needed in the OpenAPI YAML specification.

## Submitting a Suggestion

If there's something in the SDK that isn't broken but could be better, you're welcome to share suggestions. Constructive feedback is always appreciated!

When submitting a suggestion:

1. Be clear and concise in your description of the suggestion.

2. Explain why it would be beneficial. Real-life examples, if applicable, can help to illustrate your point.

3. Be patient. Not all suggestions can be incorporated immediately, and it may be necessary for us to research your idea before we can implement it.

Remember, contributions come in many forms, not just in code! Identifying areas for improvement or bringing up issues helps us make the SDK better for everyone.

Thank you for your contributions!
7 changes: 7 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Copyright (c) 2024 Grabtaxi Holdings PTE LTE (GRAB)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
290 changes: 290 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,290 @@
# Java API client for GrabFood

- API version: 1.1.3

- Generator version: 7.8.0

For more information, please visit [https://developer.grab.com](https://developer.grab.com)

*Automatically generated by the [OpenAPI Generator](https://openapi-generator.tech)*

## Requirements

Building the API client library requires:

1. Java 1.8+
2. Maven/Gradle

## Installation

To install the API client library to your local Maven repository, simply execute:

```shell
mvn clean install
```

To deploy it to a remote Maven repository instead, configure the settings of the repository and execute:

```shell
mvn clean deploy
```

Refer to the [OSSRH Guide](http://central.sonatype.org/pages/ossrh-guide.html) for more information.

### Maven users

Add this dependency to your project's POM:

```xml
<dependency>
<groupId>com.grabfood</groupId>
<artifactId>grabfood-java-client</artifactId>
<version>1.0.0</version>
<scope>compile</scope>
</dependency>
```

### Gradle users

Add this dependency to your project's build file:

```groovy
repositories {
mavenCentral() // Needed if the 'grabfood-java-client' jar has been published to maven central.
mavenLocal() // Needed if the 'grabfood-java-client' jar has been published to the local maven repo.
}
dependencies {
implementation "com.grabfood:grabfood-java-client:1.0.0"
}
```

### Others

At first generate the JAR by executing:

```shell
mvn clean package
```

Then manually install the following JARs:

- `target/grabfood-java-client-1.0.0.jar`
- `target/lib/*.jar`

## Getting Started

Please follow the [installation](#installation) instruction and execute the following Java code:

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.

```java
import com.grabfood.client.ApiClient;
import com.grabfood.client.ApiException;
import com.grabfood.client.Configuration;
import com.grabfood.client.model.*;
import com.grabfood.client.api.*;

public class Example {
public static void main(String[] args) {
ApiClient client = Configuration.getDefaultApiClient();
client.setServerIndex(Configuration.StgEnv);

GetOauthGrabApi authInstance = new GetOauthGrabApi(client);
authInstance.setHostIndex(client.getServerIndex());

String contentType = "application/json";

GrabOauthRequest req = new GrabOauthRequest();
req.setClientId("client_id");
req.setClientSecret("client_secret");
req.setGrantType("client_credentials");
req.setScope("food.partner_api");

try {
GrabOauthResponse authResp = authInstance.postOauthGrab(contentType, req);
// Request a new token only when the previous one has expired.
// Can utilize the `expires_in` from authResp.getExpiresIn() to determine the validity of the token.
ACCESS_TOKEN = authResp.getAccessToken();
} catch (ApiException e) {
System.err.println("Exception when calling GetOauthGrabApi#postOauthGrab");
e.printStackTrace();
}

GetStoreHourApi apiInstance = new GetStoreHourApi(client);
String authorization = "Bearer " + ACCESS_TOKEN;
String merchantID = "1-CYNGRUNGSBCCC";
try {
StoreHourResponse result = apiInstance.getStoreHour(authorization, merchantID);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling GetStoreHourApi#getStoreHour");
e.printStackTrace();
}
}
}
```

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

Class | Method | HTTP request | Description
------------ | ------------- | ------------- | -------------
*AcceptRejectOrderApi* | [**acceptRejectApi**](docs/AcceptRejectOrderApi.md#acceptRejectApi) | **POST** /partner/v1/order/prepare | Manually accept/reject orders
*CancelOrderApi* | [**cancelOrders**](docs/CancelOrderApi.md#cancelOrders) | **PUT** /partner/v1/order/cancel | Cancel an order
*CheckCancelableApi* | [**checkOrderCancelable**](docs/CheckCancelableApi.md#checkOrderCancelable) | **GET** /partner/v1/order/cancelable | Check order cancelable
*CreateCampaignApi* | [**createCampaignApi**](docs/CreateCampaignApi.md#createCampaignApi) | **POST** /partner/v1/campaigns | Create campaign
*DeleteCampaignApi* | [**deleteCampaignApi**](docs/DeleteCampaignApi.md#deleteCampaignApi) | **DELETE** /partner/v1/campaigns/{campaign_id} | Delete campaigns
*DeliveryStateApi* | [**deliveryStateApi**](docs/DeliveryStateApi.md#deliveryStateApi) | **POST** /partner/v1/order/delivery | Update delivery state
*EditOrderApi* | [**editOrderApi**](docs/EditOrderApi.md#editOrderApi) | **PUT** /partner/v1/orders/{orderID} | Edit Order
*GetDineinVoucherApi* | [**getDineinVoucher**](docs/GetDineinVoucherApi.md#getDineinVoucher) | **GET** /partner/v1/dinein/voucher | Get Dine In Voucher
*GetOauthGrabApi* | [**postOauthGrab**](docs/GetOauthGrabApi.md#postOauthGrab) | **POST** /grabid/v1/oauth2/token | Get Oauth access token
*GetStoreHourApi* | [**getStoreHour**](docs/GetStoreHourApi.md#getStoreHour) | **GET** /partner/v2/merchants/{merchantID}/store/hours | Get Store Hours
*GetStoreStatusApi* | [**getStoreStatus**](docs/GetStoreStatusApi.md#getStoreStatus) | **GET** /partner/v1/merchants/{merchantID}/store/status | Get Store Status
*ListCampaignApi* | [**listCampaignApi**](docs/ListCampaignApi.md#listCampaignApi) | **GET** /partner/v1/campaigns | List campaigns
*ListOrderApi* | [**listOrders**](docs/ListOrderApi.md#listOrders) | **GET** /partner/v1/orders | List orders
*MarkOrderApi* | [**markOrderReady**](docs/MarkOrderApi.md#markOrderReady) | **POST** /partner/v1/orders/mark | Mark order as ready
*NotifyMembershipWebviewApi* | [**notifyMembershipWebview**](docs/NotifyMembershipWebviewApi.md#notifyMembershipWebview) | **POST** /partner/v1/membership/notify | Notify Membership
*PauseStoreApi* | [**pauseStoreApi**](docs/PauseStoreApi.md#pauseStoreApi) | **PUT** /partner/v1/merchant/pause | Pause store
*RedeemDineinVoucherApi* | [**redeemDineinVoucher**](docs/RedeemDineinVoucherApi.md#redeemDineinVoucher) | **POST** /partner/v1/dinein/voucher/redeem | Redeem Dine In Voucher
*TraceMenuSyncApi* | [**traceMenuSync**](docs/TraceMenuSyncApi.md#traceMenuSync) | **GET** /partner/v1/merchant/menu/trace | Trace menu sync
*UpdateCampaignApi* | [**updateCampaignApi**](docs/UpdateCampaignApi.md#updateCampaignApi) | **PUT** /partner/v1/campaigns/{campaign_id} | Update campaign
*UpdateMenuNotiApi* | [**updateMenuNotification**](docs/UpdateMenuNotiApi.md#updateMenuNotification) | **POST** /partner/v1/merchant/menu/notification | Notify Grab of updated menu
*UpdateMenuRecordApi* | [**batchUpdateMenuRecord**](docs/UpdateMenuRecordApi.md#batchUpdateMenuRecord) | **PUT** /partner/v1/batch/menu | Batch Update Menu
*UpdateMenuRecordApi* | [**updateMenu**](docs/UpdateMenuRecordApi.md#updateMenu) | **PUT** /partner/v1/menu | Update menu record
*UpdateOrderReadyTimeApi* | [**updateOrderTime**](docs/UpdateOrderReadyTimeApi.md#updateOrderTime) | **PUT** /partner/v1/order/readytime | Update new order ready time
*UpdateStoreDeliveryHourApi* | [**updateStoreDeliveryHour**](docs/UpdateStoreDeliveryHourApi.md#updateStoreDeliveryHour) | **PUT** /partner/v1/merchants/{merchantID}/store/opening-hours | Update Store Delivery Hours
*UpdateStoreDineInHourApi* | [**updateStoreDineInHour**](docs/UpdateStoreDineInHourApi.md#updateStoreDineInHour) | **PUT** /partner/v1/merchants/{merchantID}/store/dine-in-hours | Update Store Dine-in Hours
*UpdateStoreSpecialHourApi* | [**updateStoreSpecialHour**](docs/UpdateStoreSpecialHourApi.md#updateStoreSpecialHour) | **PUT** /partner/v2/merchants/{merchantID}/store/special-opening-hour | Update Store Special Hours


## Documentation for Models

- [AcceptOrderRequest](docs/AcceptOrderRequest.md)
- [Address](docs/Address.md)
- [AdvancedPricing](docs/AdvancedPricing.md)
- [BatchUpdateMenuItem](docs/BatchUpdateMenuItem.md)
- [BatchUpdateMenuResponse](docs/BatchUpdateMenuResponse.md)
- [BindMembershipNativeRequest](docs/BindMembershipNativeRequest.md)
- [BindMembershipNativeResponse](docs/BindMembershipNativeResponse.md)
- [Campaign](docs/Campaign.md)
- [CampaignConditions](docs/CampaignConditions.md)
- [CampaignDiscount](docs/CampaignDiscount.md)
- [CampaignQuotas](docs/CampaignQuotas.md)
- [CampaignScope](docs/CampaignScope.md)
- [CancelCode](docs/CancelCode.md)
- [CancelOrderLimitType](docs/CancelOrderLimitType.md)
- [CancelOrderRequest](docs/CancelOrderRequest.md)
- [CancelOrderResponse](docs/CancelOrderResponse.md)
- [CancelReason](docs/CancelReason.md)
- [CheckOrderCancelableResponse](docs/CheckOrderCancelableResponse.md)
- [Coordinates](docs/Coordinates.md)
- [CreateCampaignRequest](docs/CreateCampaignRequest.md)
- [CreateCampaignResponse](docs/CreateCampaignResponse.md)
- [Currency](docs/Currency.md)
- [DineIn](docs/DineIn.md)
- [EditOrderItem](docs/EditOrderItem.md)
- [EditOrderRequest](docs/EditOrderRequest.md)
- [Error](docs/Error.md)
- [GetDineInVoucherResponse](docs/GetDineInVoucherResponse.md)
- [GetMembershipNativeResponse](docs/GetMembershipNativeResponse.md)
- [GetMembershipNativeResponsePointInfo](docs/GetMembershipNativeResponsePointInfo.md)
- [GetMembershipRequest](docs/GetMembershipRequest.md)
- [GetMembershipWebviewResponse](docs/GetMembershipWebviewResponse.md)
- [GetMenuNewResponse](docs/GetMenuNewResponse.md)
- [GetMenuOldResponse](docs/GetMenuOldResponse.md)
- [GetRewardNativeRequest](docs/GetRewardNativeRequest.md)
- [GetRewardNativeResponse](docs/GetRewardNativeResponse.md)
- [GrabOauthRequest](docs/GrabOauthRequest.md)
- [GrabOauthResponse](docs/GrabOauthResponse.md)
- [ListCampaignResponse](docs/ListCampaignResponse.md)
- [ListOrdersResponse](docs/ListOrdersResponse.md)
- [MarkOrderRequest](docs/MarkOrderRequest.md)
- [MenuCategory](docs/MenuCategory.md)
- [MenuEntity](docs/MenuEntity.md)
- [MenuEntityError](docs/MenuEntityError.md)
- [MenuItem](docs/MenuItem.md)
- [MenuModifier](docs/MenuModifier.md)
- [MenuSection](docs/MenuSection.md)
- [MenuSectionCategory](docs/MenuSectionCategory.md)
- [MenuSectionCategoryItem](docs/MenuSectionCategoryItem.md)
- [MenuSyncFail](docs/MenuSyncFail.md)
- [MenuSyncFailCategory](docs/MenuSyncFailCategory.md)
- [MenuSyncFailItem](docs/MenuSyncFailItem.md)
- [MenuSyncFailModifier](docs/MenuSyncFailModifier.md)
- [MenuSyncFailModifierGroup](docs/MenuSyncFailModifierGroup.md)
- [MenuSyncFailServiceHours](docs/MenuSyncFailServiceHours.md)
- [MenuSyncResponse](docs/MenuSyncResponse.md)
- [MenuSyncWebhookRequest](docs/MenuSyncWebhookRequest.md)
- [ModifierGroup](docs/ModifierGroup.md)
- [NewOrderTimeRequest](docs/NewOrderTimeRequest.md)
- [NotifyMembershipWebviewRequest](docs/NotifyMembershipWebviewRequest.md)
- [OpenPeriod](docs/OpenPeriod.md)
- [Order](docs/Order.md)
- [OrderCampaign](docs/OrderCampaign.md)
- [OrderDeliveryRequest](docs/OrderDeliveryRequest.md)
- [OrderFeatureFlags](docs/OrderFeatureFlags.md)
- [OrderFreeItem](docs/OrderFreeItem.md)
- [OrderItem](docs/OrderItem.md)
- [OrderItemModifier](docs/OrderItemModifier.md)
- [OrderPrice](docs/OrderPrice.md)
- [OrderPromo](docs/OrderPromo.md)
- [OrderReadyEstimation](docs/OrderReadyEstimation.md)
- [OrderStateRequest](docs/OrderStateRequest.md)
- [OutOfStockInstruction](docs/OutOfStockInstruction.md)
- [PartnerOauthRequest](docs/PartnerOauthRequest.md)
- [PartnerOauthResponse](docs/PartnerOauthResponse.md)
- [PauseStoreRequest](docs/PauseStoreRequest.md)
- [Purchasability](docs/Purchasability.md)
- [Receiver](docs/Receiver.md)
- [RedeemDineInVoucherRequest](docs/RedeemDineInVoucherRequest.md)
- [RedeemDineInVoucherResponse](docs/RedeemDineInVoucherResponse.md)
- [RedeemResult](docs/RedeemResult.md)
- [RegisterMembershipNativeRequest](docs/RegisterMembershipNativeRequest.md)
- [RegisterMembershipNativeResponse](docs/RegisterMembershipNativeResponse.md)
- [RewardItem](docs/RewardItem.md)
- [SellingTime](docs/SellingTime.md)
- [ServiceHour](docs/ServiceHour.md)
- [ServiceHours](docs/ServiceHours.md)
- [SpecialOpeningHour](docs/SpecialOpeningHour.md)
- [SpecialOpeningHourMetadata](docs/SpecialOpeningHourMetadata.md)
- [SpecialOpeningHourOpeningHours](docs/SpecialOpeningHourOpeningHours.md)
- [StoreHour](docs/StoreHour.md)
- [StoreHourResponse](docs/StoreHourResponse.md)
- [StoreStatusResponse](docs/StoreStatusResponse.md)
- [SubmitOrderRequest](docs/SubmitOrderRequest.md)
- [UnbindMembershipNativeRequest](docs/UnbindMembershipNativeRequest.md)
- [UnlinkMembershipWebviewRequest](docs/UnlinkMembershipWebviewRequest.md)
- [UpdateAdvancedPricing](docs/UpdateAdvancedPricing.md)
- [UpdateCampaignRequest](docs/UpdateCampaignRequest.md)
- [UpdateDeliveryHourRequest](docs/UpdateDeliveryHourRequest.md)
- [UpdateDeliveryHourResponse](docs/UpdateDeliveryHourResponse.md)
- [UpdateDineInHourRequest](docs/UpdateDineInHourRequest.md)
- [UpdateDineInHourResponse](docs/UpdateDineInHourResponse.md)
- [UpdateMenuItem](docs/UpdateMenuItem.md)
- [UpdateMenuModifier](docs/UpdateMenuModifier.md)
- [UpdateMenuNotifRequest](docs/UpdateMenuNotifRequest.md)
- [UpdateMenuRequest](docs/UpdateMenuRequest.md)
- [UpdatePurchasability](docs/UpdatePurchasability.md)
- [UpdateSpecialHourRequest](docs/UpdateSpecialHourRequest.md)
- [UpdateSpecialHourResponse](docs/UpdateSpecialHourResponse.md)
- [Voucher](docs/Voucher.md)
- [VoucherDescriptionInfo](docs/VoucherDescriptionInfo.md)
- [WorkingHour](docs/WorkingHour.md)
- [WorkingHourDay](docs/WorkingHourDay.md)


## Recommendation

It's recommended to create an instance of `ApiClient` per thread in a multithreaded environment to avoid any potential issues.
Loading

0 comments on commit d508934

Please sign in to comment.