Download the PHP package pdeans/miva-api without Composer

On this page you can find all versions of the php package pdeans/miva-api. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package miva-api

Miva JSON Api PHP Library

PHP library for interacting with the Miva JSON API.

Table Of Contents

Installation

Install via Composer.

Configuring the Api Client

Utilizing the library to interact with the Api is accomplished via the Client class. The Client class accepts an array containing Api and HTTP client (cURL) configuration options in key/value format.

Client Configuration Options

Key Required Type Description
url Yes string The Api endpoint URL.
store_code Yes string The Miva store code.
access_token Yes string The Api access token.
private_key Yes string The Api private key. Hint: If omitting signature validation, pass in an '' empty string literal value.
hmac No string HMAC signature type. Defaults to sha256. Valid types are one of: sha256, sha1, '' (Enter a blank string literal if omitting signature validation).
timestamp No boolean Enable/disable Api request timestamp validation. Defaults to true (Enabled).
http_headers No array HTTP request headers. Note that the library will automatically send the Content-Type: application/json and X-Miva-API-Authorization headers with each Api request. For this reason, these headers should not be included in this list.
http_client No array Associative array of curl options.

Example:

Authentication

The Miva Api authorization header will be automatically generated based on the configuration settings passed into the Client object and sent along with each Api request. The configuration settings should match the Miva store settings for the given Api token.

JSON Request Format

The required Miva_Request_Timestamp and Store_Code properties are automatically generated based on the configuration settings passed into the Client object and added to the JSON body for every Api request. The Function property is also automatically added to the JSON body for every request. The JSON data generated for the Function property will vary based on the provided request function list.

Function Builder

The func method is used to generate Api request functions. The method accepts the request function name as its only argument.

The add method is used to "publish" the function and append it to the request function list.

Note: All function builder methods are chainable.

Function Request Parameters

This section showcases how to construct and add function parameters.

Common Filter List Parameters

Each common filter list parameter for the xxxList_Load_Query functions has a corresponding helper method to seamlessly set the parameter value. The example below shows each of the methods in action.

Function Request Filters

Most of the function search/display filters have an associated helper method that acts as a shorthand, or factory for creating the respective filter. The filter method must be used for any filter that does not have a linked helper method, as shown in the example above. This method can also be used to create each filter covered below. The method accepts two arguments, with the first argument always being the filter name. The second argument takes the filter value, which will vary per filter type.

The available search/display helper methods are covered below.

Search

The search method may be used to attach a search filter to a function's filter list. The most basic call to search requires three arguments. The first argument is the search field column. The second argument is the search operator, which can be any of the supported Api search operators. Finally, the third argument is the value to evaluate against the search column.

Below is an example to issue a search filter for a specific product code:

For convenience, if you want to verify that a column is equal ('EQ') to a given value, you may pass the value directly as the second argument to the search method. The following will achieve the same result as the first example above:

Of course, you may use a variety of other supported operators when writing a search filter:

The search method can be issued multiple times to perform an AND search:

Performing OR searches and parenthetical comparisons can be achieved by passing in an array to the search method as the first and only argument. The array should be modeled to match the desired search value output, with value nesting as needed:

On Demand Columns

Using the ondemandcolumns method, you can specify the explicit columns to return. The method takes one argument, the list of on demand columns to select:

For convenience, the odc method can be utilized as an alias to the ondemandcolumns method:

Show

The "show" filters can be created using the show method. This method takes one argument, the show filter value, which will vary per xxxList_Load_Query function. Note that this filter is currently available for the following functions only:

Example:

Function Request Input Parameters

Passphrase

The passphrase method is used to set the Passphrase parameter. The method takes a single argument, the decryption passphrase.

Additional Input Parameters

The params method is used to set all other input parameters. Some example use cases for this method are the request body parameters for the Xx_Create / Xx_Insert / Xx_Update / Xx_Delete functions, Module level functions, and essentially all other functions that require specific input parameters to perform actions. The function accepts a key/value array which maps to the input parameter key/values as its only argument.

Examples:

API Requests

This section covers configuring and issuing Api requests.

HTTP Headers

You may specify which HTTP headers are attached to all Api requests with the addHeader and addHeaders methods. Please note that the library automatically creates and attaches the Content-Type: application/json and X-Miva-API-Authorization headers to each Api request.

Sending Requests

The send method will issue an Api request, and return the results in the library's Response object. If you wish to bypass this object and return the raw JSON response from the Api, pass a true value as the first argument for the send method.

Example requests:

You may preview the current request body at any time before sending the request by using the getRequestBody method. This is helpful for debugging requests.

API Responses

By default, Api responses will return a pdeans\Miva\Api\Response class instance. The Response object includes a number of helper methods for interacting with the Api responses.

Checking For Request Errors

Checking for errors that may have occurred on the Api request can be accomplished with the getErrors method. This method will return a stdClass object containing the error code and error message thrown. The isSuccess method returns a boolean value which can be used as a flag to determine if a request error occurred:

Response Body

The raw JSON response body can be retrieved anytime using the getBody method:

To receive an iterable form of the Api response, issue the getResponse method. This will return an array of objects, with the array keys mapping to the function names supplied to the Api request function list. The items are sorted in identical order to the Api request function list. Each item or "function", contains its own array of the results of the function request. These array items correlate to each of the function's iterations that were sent in the request. The items are sorted in the same order that they were issued in the request. Use the getFunctions method to retrieve the list of available functions.

The getFunction method may be used to explicitly return the response results for a specific function name. This can also be accomplished with the getResponse method by passing the function name as the first argument.

The getData method returns the response data property for a specific function name. By default, the data property is returned for the first iteration index for the function name provided. However, an optional second argument can be provided to return the data property for a specific iteration index on the given function name.

Examples:

Helpers

This section covers library helper methods.

Troubleshooting Api Requests And Responses

To aid in troubleshooting Api requests and responses, PSR-7 Request and PSR-7 Response objects can be obtained using the getPreviousRequest and getPreviousResponse methods respectively after an Api request has been issued:

Furthermore, the getUrl, getHeaders, and getFunctionList methods may be used to inspect and troubleshoot requests before they are sent off to the Api:

Further Reading

Having a general understanding of the Miva JSON Api configuration and schema is highly recommended before using the library.


All versions of miva-api with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
ext-json Version *
pdeans/http Version ^2.0.3
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package pdeans/miva-api contains the following files

Loading the files please wait ....