Class: Vra

Vra(options)

Vuex Rest API class. Generates Vuex stores based on the supplied config. The stores have actions for fetching and returning the API data,.

Constructor

new Vra(options)

Instantiate the class.
Parameters:
Name Type Description
options VraOptions
Source:

Members

actions

Get the actions for this module.
Source:

modules

Get child modules for this store.
Source:

store

Get the entire store for this module, for Vuex.
Source:

Methods

(static) createModules(modules) → {object}

Sugar for creating lots of modules.
Parameters:
Name Type Description
modules object Object of module configs.
Source:
Returns:
- Namespaced Vuex modules.
Type
object

(static) requestAdapter(requestParams) → {Promise.<object>}

Allows you to change the request function to something else (e.g. To add authorization headers) or to use a different HTTP library entirely. The function context (`this`) is set to the same of the Vuex action.
Parameters:
Name Type Description
requestParams object Request params for `axios.request`.
Source:
Returns:
- The result of the request.
Type
Promise.<object>

child(name, child)

Add a child module to this model.
Parameters:
Name Type Description
name string Name of the child model.
child object | Vra Vra constructor options or Vra instance.
Source:

createCall(name, options)

Create an action for an endpoint.
Parameters:
Name Type Description
name string Name of the action.
options object
Properties
Name Type Description
method string HTTP method for the call.
parser function Function used to parse the data from the API response.
identified boolean Whether this endpoint needs an identifier field or not, e.g. `id`.
path string Path for this callback, appended to baseUrl.
binary boolean Whether this is a binary model or not.
responseType string Override responseType, by default this is `undefined` for normal models, and `arraybuffer` for binary models.
Source:

createModel(fieldsOrData, options) → {object}

Instantiate a model class using the helpers if they exist.
Parameters:
Name Type Description
fieldsOrData object
options object
Properties
Name Type Description
binary boolean Whether this is a binary model or not.
Source:
Returns:
Model.
Type
object

getCall(name) → {object|null}

Get a calls options.
Parameters:
Name Type Description
name string Name of the action.
Source:
Returns:
Type
object | null

getParser(options) → {function}

Get the default parser.
Parameters:
Name Type Description
options object
Properties
Name Type Description
identified boolean Whether this is a parser for an identified API call or not.
binary boolean Whether this is a parser for a binary API call or not.
Source:
Returns:
Type
function

getUrl(fields, path) → {string}

Get the URL using the baseUrl and the supplied fields.
Parameters:
Name Type Description
fields object
path string
Source:
Returns:
Endpoint.
Type
string

modifyCall(name, options)

Modify an action for an endpoint.
Parameters:
Name Type Description
name string Name of the action.
options object
Source: