Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get Transport Estimates For Other Pickup and Dropoff Locations #22

Open
ldw129 opened this issue Mar 19, 2023 · 4 comments
Open

Get Transport Estimates For Other Pickup and Dropoff Locations #22

ldw129 opened this issue Mar 19, 2023 · 4 comments

Comments

@ldw129
Copy link

ldw129 commented Mar 19, 2023

Hi there! Thank you for publishing this repo. I have tried to run the get-transport-estimate.js locally on my computer using a different set of latitude and longitude points for the pickup and dropoff locations, based outside of Indonesia in another country like Singapore. However, I encountered an error called .transport_pricing_service.estimate.error when requesting for transport estimates between the 2 points, using the get-transport-estimate.js file.

The latitude and longitude points that I used for the pickup and dropoff locations are:

  • Pickup point: 1.3376415,103.6947157
  • Dropoff point: 1.3475799,103.6786857

Additionally, I have already changed the country code to +65 (for Singapore) and the phone number to my phone number in the goid.js file, as shown below:

const testLoginRequest = async () => {
    const loginResponse = await tokenAPI.loginRequest({
        ...defaultHeaders,
        loginRequestBody:{
            client_id: 'gojek:consumer:app',
            client_secret: 'pGwQ7oi8bKqqwvid09UrjqpkMEHklb',
            country_code: '+65',
            login_type: 'otp_whatsapp',
            magic_link_ref: '',
            phone_number: '81464126'
        }
    });

    console.log({ loginResponse: loginResponse.data  });
};

And below is the error I faced when I ran get-transport-estimate.js, after running get-pickup-spots.js and get-dropoff-spots.js:

{
      code: '.transport_pricing_service.estimate.error',
      message: 'Don’t worry, we’re fixing this. We’ll be back for you soon!',
      message_title: 'Don’t worry, we’re fixing this. We’ll be back for you soon!',
      message_severity: 'severe'
}

May I seek your input on this error? Thank you very much! :)

@mychaelgo
Copy link
Owner

@ldw129 , please share the full code.. code above is for login request , not for transport estimate

@mychaelgo
Copy link
Owner

or maybe the service type is not exists in those area

@ldw129
Copy link
Author

ldw129 commented Mar 23, 2023

Hi @mychaelgo , thank you for your reply! For better clarity, below is the full edited code from:

  1. goid.js
const { TokenApi } = require('../../../sdk/goid-gojek-node/dist');

const tokenAPI = new TokenApi();

const defaultHeaders = {
    xAppid: 'com.gojek.app',
    xAppversion: '4.59.1',
    xDeviceos: 'Android,10',
    xPhonemake: 'Samsung',
    xPhonemodel: 'GT-S7500',
    xPlatform: 'Android',
    xPushtokentype: 'FCM',
    xUniqueid: '95f99ddd6a5d34a9',
    xUserType: 'customer'
};

const testLoginRequest = async () => {
    const loginResponse = await tokenAPI.loginRequest({
        ...defaultHeaders,
        loginRequestBody:{
            client_id: 'gojek:consumer:app',
            client_secret: 'pGwQ7oi8bKqqwvid09UrjqpkMEHklb',
            country_code: '+65',
            login_type: 'otp_whatsapp',
            magic_link_ref: '',
            phone_number: '81464126'
        }
    });

    console.log({ loginResponse: loginResponse.data  });
};

const testGenerateToken = async () => {
    const generateTokenResponse = await tokenAPI.generateToken({
        ...defaultHeaders,
        generateTokenRequest: {
            client_id: 'gojek:consumer:app',
            client_secret: 'pGwQ7oi8bKqqwvid09UrjqpkMEHklb',
            data: {
                otp: '2960',
                otp_token: 'd477d703-a5d3-43bb-92ce-7423929b0036'
            },
            grant_type: 'otp',
            scopes: []
        }
    });

    console.log({ generateTokenResponse: generateTokenResponse.data  });
};

// testLoginRequest();
testGenerateToken();
  1. get-transport-estimate.js
const { TransportApi, Configuration } = require('../../../sdk/api-gojek-node');

const configuration = new Configuration({
    accessToken: 'eyJhbGciOiJSUzI1NiIsImtpZCI6IiJ9.eyJhdWQiOlsiZ29qZWs6Y29uc3VtZXI6YXBwIl0sImRhdCI6eyJhY3RpdmUiOiJ0cnVlIiwiYmxhY2tsaXN0ZWQiOiJmYWxzZSIsImNvdW50cnlfY29kZSI6Iis2NSIsImNyZWF0ZWRfYXQiOiIyMDIwLTA3LTEyVDA0OjUxOjM3WiIsImVtYWlsIjoibGltZG9uZ3dhbjIwMTUyOEBnbWFpbC5jb20iLCJlbWFpbF92ZXJpZmllZCI6InRydWUiLCJnb3BheV9hY2NvdW50X2lkIjoiMDEtYzNmOTZkNTk5Zjc2NDEzZThkZDUyZTcxMjA0ZGNiNmMtMjQiLCJuYW1lIjoiTGltIERvbmcgV2FuIiwibnVtYmVyIjoiODE0NjQxMjYiLCJwaG9uZSI6Iis2NTgxNDY0MTI2Iiwic2lnbmVkX3VwX2NvdW50cnkiOiJJRCIsIndhbGxldF9pZCI6IjIwMTk0MDI5MTQzMDk1ODEyNyJ9LCJleHAiOjE2ODIwNzIzNjQsImlhdCI6MTY3OTIzMzUyMywiaXNzIjoiZ29pZCIsImp0aSI6ImI2OWJhZWVhLTg5MGItNGY1OS05YzZiLWI2YTUwZWU3YWMwYiIsInNjb3BlcyI6W10sInNpZCI6IjJhMjNlZjdiLTIyMGMtNGJkMy04ZGU2LWQwNzM2MmM3YTVjMyIsInN1YiI6ImQ0NTkyZDg4LTBkMDctNDhkYS1hNWUzLTc2NmEyZGNhNWYwZiIsInVpZCI6IjY4NTA1NjQ3NiIsInV0eXBlIjoiY3VzdG9tZXIifQ.OwQZeIjD_l11YuSEQ6Sdm6aqitdl6ny8tvCmilHacuhRsCMpWRvVq-1BWaWg2lyfT0WBtZfe43GuFQcyh-7V1Qmjr16DRhn6bMvqaRXY6gAPYe24C_vXoCIzT9Ieb8DiJkSv9sdxEE8pEHRPs9Mpk3uT6tK5UvetTxrvrFKseq0'
});

// const configuration = new Configuration({
//     accessToken: process.env.GOJEK_ACCESS_TOKEN
// });

const transportAPI = new TransportApi(configuration);

const defaultHeaders = {
    xAppid: 'com.gojek.app',
    xAppversion: '4.59.1',
    xDeviceos: 'Android,10',
    xPhonemake: 'Samsung',
    xPhonemodel: 'GT-S7500',
    xPlatform: 'Android',
    xPushtokentype: 'FCM',
    xUniqueid: '95f99ddd6a5d34a9',
    xUserType: 'customer',
    xSessionId: 'd31cc210-a067-4d0d-a52f-199880ea8907',
    gojekCountryCode: 'ID'
};

const getTransportEstimate = async () => {
    
    const getTransportEstimateResponse = await transportAPI.getTransportEstimate({
        ...defaultHeaders,
        sendPrioritisedOrder: true,
        userSelectedServiceType: 1,
        waypoints: '1.3376415,103.6947157|1.3336745,103.6758544'
    });

    console.log(JSON.stringify(getTransportEstimateResponse.data));
};

getTransportEstimate();

Just to clarify, I first ran goid.js to get the OTP from Gojek and generate the access token, then I ran get-transport-estimate.js using the access token generated. This was where the error, as mentioned in my first comment above, surfaced.

Thank you!

@haiqaldani
Copy link

i wanna ask i get 400 error, im using waypoint in singapore

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants