Skip to content

Growish/gw-api-v2-client

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

79 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gw-api-v2-client

Installation:

using NPM:

npm install https://github.com/Growish/gw-api-v2-client.git

using YARN:

yarn add https://github.com/Growish/gw-api-v2-client.git

Configuration:

GW2 class constructor need a configuration wich is provided by an object.
Example of the object needed:

options: {
      baseUrl: 'https://apidev.growish.com/v2/client/girocredito/',
      unauthorizedErr: () => {
        window.location.href = '/';
      },
      handleSucces: (data) => {
        return data;
      },
      defaultErr: (err) => {
        alert(err.response.data.message);
      },
      requestErr: (errors, setErr) => {
        setErr(errors.response.data.data);
      },
      onLoginSuccess: () => {
        window.location.href = '/';
      },
      onLoginError: (error) => {
        console.log(error);
      },
      onRegisterSuccess: () => {},
      onRegisterError: (error) => {
        console.log(error);
      },
      onLogoutSuccess: () => {},
      onLogoutError: (error) => {
        console.log(error);
      },
      badRequestErr: () => {},
      forbiddenErr: () => {},
    }

Class initialization:

example of GW2 class initialization:

new GW2(options);

Where options is the configuration object.

GW2 CLIENT API USAGE:

request method:

    client.request({
        action:String,// the API method in CAPS example: "GETWALLETS"
        params:Object,// object containing query string params
        body:Object,// object containing the payload request body
        setErrors:Function // function that saves the state of the errors in the UI component
        urlParams:Object //  url paramateres such as {ID} or path/{ID}/path
    })

EXAMPLE:

    client.request({
        action:"CREATEWALLET",
        //for this action, PARAMS is not mandatory
        body:{currency: "EUR",goalAmount: 25000},
        setErrors:setErrors // this is a frontend function reference.
        //for this action, urlParams is not mandatory
    })

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •