This article is aimed to guide developers through the steps required to consume Store related endpoints offered by Trustvox REST API.
Request Header required fields
In order to make a proper request, the header should have the following fields.
Accept: application/vnd.trustvox.com; version=1
Content-Type: application/json
Authorization: Your valid Trustvox authorization token
Observation: each store has its own unique token.
Tags endpoints
Through a simple GET request it's possible to retrieve all registered tags from Stores, Orders, Clients and Products.
In order retrieve all store's tags, you should perform a request as given:
Endpoint: http://trustvox.com.br/api/stores/< STORE ID>/tags
HTTP Method: GET
Success Response Body:
id: Trustvox unique identifier for the tag
name: tag's name
links:
self: URL for manipulating store through Trustvox API
cURL Example
Suppose you store id is 1, performing the following cURL command
curl --include \ --request GET \ --header "Accept: application/vnd.trustvox-v2+json" \ --header "Authorization: token obscured" \ 'http://staging.trustvox.com.br/api/stores/1/tags'
Gives the following response body:
{ "links": [ { "rel": "self", "href": "http://staging.trustvox.com.br/api/stores/1/tags" } ], "items": [ { "id": 1, "name": "Sample/Tag" } ] }
Customising Tag requests
In order to retrieve Tags of Clients, Orders or Products, a url parameter called ` belonging_to` is needed.
Clients: http://trustvox.com.br/api/stores/< STORE ID>/tags?belonging_to=clients
Orders: http://trustvox.com.br/api/stores/< STORE ID>/tags?belonging_to=orders
Products: http://trustvox.com.br/api/stores/< STORE ID>/tags?belonging_to=products
Store Reviews endpoints
It's also possible to retrieve store reviews made by clients. To do so, the following request should be issued:
Endpoint: http://trustvox.com.br/api/stores/< STORE_ID>/store_reviews
HTTP Method: GET
Success Response Body:
text: opinion text
id: Trustvox unique identifier for the store review
created_at: date of creation
client:
tags: list of client tags
id: Trustvox unique identifier for the tag
first_name: client's name
email: client's email
Note about the endpoints of Orders, Products and Clients
It's valuable to point that the default endpoints of Orders, Products and Clients doesn't return any associated tags for the sake of shorter response time.
In order to explicitly request that tags should be embedded in the response, the parameter ` tags` should be used.
For instance, the request to orders endpoint would be as the following:
Endpoint: http://trustvox.com.br/api/stores/< STORE_ID>/orders?tags=true
Orders endpoints
GET orders
To import all orders from a store, the following request should be performed:
Endpoint: http://trustvox.com.br/api/stores/< STORE_ID>/orders
HTTP Method: GET
Success Response Body:
id: Trustvox unique identifier for the tag
order_id: identifier from integration
client:
id: Trustvox unique identifier for the tag
first_name: client's name
email: client's email
items: list of sold products
id: product identifier from integration
name: product name
url: product url
price: sold price
GET informations of a specific order
To retrieve data about a specific order, you should perform a request with the order identifier from integration as given:
Endpoint: http://trustvox.com.br/api/stores/<STORE_ ID>/orders/<ORDER_ID>
HTTP Method: GET
GET individual product review URLs
To retrieve individual product review URLs, you must use a parameter called ` products_urls` and set it to true:
Endpoint: http://trustvox.com.br/api/stores/<STORE_ ID>/orders/<ORDER_ID>?products_urls=true
HTTP Method GET
Success Response Body:
id: product identifier from integration
name: product name
product_review_url: a custom URL for the specific product to be reviewed by clients
Products endpoints
GET products
To retrieve all products from a store, the following request should be performed:
Endpoint: http://trustvox.com.br/api/stores/ <STORE_ ID> /products
HTTP Method: GET
Success Response Body:
tags: list of product tags
id: product identifier from integration
name: product name
You can use a pagination parameter to specify how many products per page for the API to return. This can be accomplished by passing the `per_page` parameter.
GET products with opinions
In order to retrieve orders with their respective opinions, the parameter `opinions` should be passed by the GET request.
The resulting endpoint would be:
Endpoint: http://trustvox.com.br/api/stores/< STORE_ID>/products?opinions=true
You can also:
Endpoint: http://trustvox.com.br/api/stores/< STORE_ID>/products/<PRODUCT_ID>?opinions=true
GET products by a minimum rate
In order to get the products with a minimum rate value, the parameter `by_min_rate` should be used.
Example:
Endpoint: http://trustvox.com.br/api/stores/< STORE_ID>/products?by_min_rate=2
GET products such any opinion dates at least a specific date
In order to get the products that has at least one opinion dating a specific date, the parameter `commented_by` should be used.
Example:
Endpoint: http://trustvox.com.br/api/stores/< STORE_ID>/products?commented_by=2018-08-06
*The date should have the 'YYYY-MM-DD' format.
GET informations of a specific product
To retrieve data about a specific product, you should perform a request with the product identifier from integration as given:
Endpoint: http://trustvox.com.br/api/stores/<STORE_ ID>/product/<PRODUCT_ID>
HTTP Method: GET
Clients endpoints
GET clients
To retrieve all clients from a store, the following request should be performed:
Endpoint: http://trustvox.com.br/api/stores/<STORE_ ID> /clients
HTTP Method: GET
Success Response Body:
id: Trustvox unique identifier for the client
first_name: client name
email: client email