📋Getting Started Guide

For a initial interation with the SDK, follow this guide.

1. Installing

Add the SDK dependency on your pom.xml or build.gradle, check the latest version at Maven Central Repository.

Maven

<dependency>
    <groupId>io.github.open-ifood</groupId>
    <artifactId>sdk</artifactId>
    <version>1.0.0</version>
</dependency>

Gradle

implementation 'io.github.open-ifood:sdk:1.0.0'

2. Initialize the authentication

Firstly, for use private modules (address, order and merchants) you will need authenticate with a valid account.

Use the IFoodService class for create a new entry class instance and request auth code.

IFoodService
        .initialize()
        .authenticate(
                EmailAuthenticationRequest.builder()
                        .tenantId("IFO")
                        .type("EMAIL")
                        .email("email@domain.com")
                        .build()
)

3. Confirm auth code

Then, with the code at last step, you will receive an 6-digit authorization code in your e-mail, after receiving confirm this by running the following code snippet.

UserSession session = session.confirm("515151")

4. Access to private modules

So authenticated =). If any issues occurred during authentication process, through received UserSession you will be able to use private modules.

// list user addresses
session.address()
    .list()
 
// list merchants by filter
session.merchant()
    .list(
        MerchantFilter.builder()
            .coordinate(
                    Coordinate.builder()
                            .longitude("-22.5155151")
                            .latitude("-51.12313123")
                            .build()
            )
            .sort("user_rating:desc")
            .size(20)
            .build()
    );

Above you can see two code samples using private modules, check the Documentation to learn more and get detailed module information.

Last updated