Ruby SDK for Rails to support usage of Alibaba API.
Aop-Client is built to run along with Rails. It wraps usage for Alibaba Post Product API. Currently, it only supports these api.
Add this line to your application's Gemfile:
gem 'aop-client'
And then execute:
$ bundle
Or install it yourself as:
$ gem install aop-client
Run install generator to get start.
rails generate aop_client:install
The generator will create a YAML file at config/aop-client.yml
.
For better usage, please refer to spec/response.
# Initialize an API object
api = AopClient::Api.new
# Call Alibaba API
# Omit 'alibaba.icbu' from alibaba method name
# provide require information in a hash
aop.call('category.postcat.get', { cat_id: 0 })
# when success
api.error #=> nil
api.data #=> [{ cat_id: 1, child_ids: [2, 3], en_name: 'Agriculture', ... }]
# when error
api.data #=> []
api.error #=> { code: 15, msg: 'Remote service error', sub_code: 'isv.100000', sub_msg: 'category does not exist', ... }
After checking out the repo, run bin/setup
to install dependencies. Then, 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
to create a git tag for the version, push git commits and tags, and push the .gem
file to rubygems.org.
- Fork it ( https://github.com/[my-github-username]/aop-client/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request