1.0.5-a • Published 1 year ago

glovo-wrapper v1.0.5-a

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

Version

glovo-wrapper

Unofficial glovo courier app API wrapper

Features

  • Authorization using Glovo Courier app credentials
  • Profile Informations
  • Challenges
  • Deliveries
  • CheckIn method
  • Raports
  • Raport Details
  • Booking & Unbooking slot system - NEW
  • Calendar & Slots Info

Installation

Using NPM

  npm install glovo-wrapper

Usage

Authorization

import { oauth, isHttpError } from 'glovo-wrapper';

oauth.authenticate({
    grantType: "password",
    password: "<PASSWORD TO ACCOUNT>",
    termsAndConditionsChecked: false,
    userType: "courier",
    username: "<EMAIL TO ACCOUNT>"
}).then(data => {
    if (data === undefined) {
        console.log("No data found!");
        return;
    }
    if (isHttpError(data)) {
        console.log(`Error: ${JSON.stringify(data.error)}`);
        return;
    }

    // Save `accessToken` and execute other requests from `courier` module
    console.log(`Logged In with token: ${data.accessToken}`);
}).catch(console.error);

Get courier eg. profile data after authorization

import { courier, isHttpError } from 'glovo-wrapper';

const accessToken = // Get access token from authenticate() function (`oauth` module);

courier.getProfile(accessToken).then(profile => {
    if (isHttpError(profile)) {
        throw new Error(profile.error);
    }

    console.log(`Excellence Score: ${profile.header.excellenceScore}`);
}).catch(console.error);

Logout

import { oauth } from 'glovo-wrapper';

const accessToken = // Get access token from authenticate() function (`oauth` module);

oauth.logout(accessToken).then(success => console.log(`Success: ${success}`));

API Reference

Authorization

  OAuth authorize(authData: IAuthData)
ParameterTypePossible ValuesDescription
grantTypestringPASSWORDRequired. Authorization method
passwordstringRequired. User password
termsAndConditionsCheckedbooleanTrue / FalseRequired. Are terms and conditions accepted
userTypestringcourierRequired. User account type
usernamestringRequired. User account email

Return type: IToken | IError | undefined

IToken Interface

  OAuth interface IToken
ParameterTypePossible ValuesDescription
accessTokenstringBearer TokenGenerated user access bearer token
expiresInnumberSecondsNumber of seconds to token expire
refreshTokenstringRefresh TokenRefresh token to renew accessToken after expire time
scopeobject or nullUnknownContains unknown data
twoFactorTokenbooleanTrue / FalseDeterminate if user has 2FA

IError Interface

  Http interface IError
ParameterTypePossible ValuesDescription
errorobjectError JSON structureContains error JSON structure, each error has probably own structure

Full documentation

1.0.5-a

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2-a

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago