Vtex
Vtex API client ruby implementation
Installation
Add this line to your application's Gemfile:
gem 'vtex'
And then execute:
$ bundle
Or install it yourself as:
$ gem install vtex
Usage
You'll need to gatter the following information from your VTex account
X-VTEX-API-AppKey
Email from a user with access to the API.
X-VTEX-API-AppToken
VTEXId password of the user with access to the API.
Account name
VTex account name.
Environment:
- Use
vtexcommercestable
for production - Use
vtexcommmercebeta
for tests
- Use
Note: It's recommended that you create an specific user to access the API (vtex-auth)
With all the information retrieve a client instance with it.
client = Vtex::Client.new({ account_name: "demo",
environment: "vtexcommercebeta",
app_key: "[email protected]",
app_token: "VTEXIdPassword" })
Design
VTex follows a design of resources as methods on the client. For example, for Products, you will call your client like this:
client = Vtex::Client.new({ ... })
client.products #=> ProductsResource
VTex will return PORO objects that contain the information provided by the API. For example:
client.products.by_id(id: 1)
# => Vtex::Product (Id:1, Name: "Guarda-Roupa Casal Lisboa 10 Portas 3 Gavetas - Araplac", ...)
Note: Right now, Key Values are being used as they come from the API
All Resources and actions.
All resources, methods and properties are direct matches from the VTex API
Products resource
Vtex API: Catalog System - Product
Usage:
client = Vtex::Client.new({ ... })
client.products #=> ProductsResource
Actions supported:
client.products.by_id(id: 'id')
Development
After checking out the repo, run bin/setup
to install dependencies. Then, run rake spec
to run the tests. You can also run bin/console
for an interactive prompt that will allow you to experiment.
To install this gem onto your local machine, run bundle exec rake install
. To release a new version, update the version number in version.rb
, and then run bundle exec rake release
, which will create a git tag for the version, push git commits and tags, and push the .gem
file to rubygems.org.
Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/mumoc/vtex. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.
License
The gem is available as open source under the terms of the MIT License.
Code of Conduct
Everyone interacting in the Vtex project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.