Project

apisync

0.0
No commit activity in last 3 years
No release in over 3 years
Official client to apisync.io
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.15
>= 0
~> 10.0
~> 3.0

Runtime

~> 0.13
 Project Readme

apisync-ruby

This gem gives you the tools to interact with apisync.io.

Installation

Add this line to your application's Gemfile:

gem 'apisync'

Usage

On Rails? Please use apisync-rails instead. It has automatic integration with ActiveRecord.

Vanilla Ruby

To create an inventory item:

client = Apisync.new(api_key: token)
client.inventory_items.save({
  attributes: {
    ad_template_type: "vehicle",
    available:        true,
    brand:            "brand",
    condition:        "new",
    content_language: "pt-br",
    reference_id:     "1"

    # more attributes
  }
})

For details on the attributes, see the API Reference documentation.

You can also define the API key globally:

Apisync.api_key = "my-key"

# Instantiate the client now without passing a token
client = Apisync.new

Verbose

If you want to output to $stdout, set verbose: true:

# Define in the instance
client = Apisync.new(api_key: 'api-key', verbose: true)

# or define it globally
Apisync.verbose = true

That is useful on Rails console in development mode, so you know what requests are being made

Logger

You can inject a logger as well:

Apisync.logger = Logger.new($stdout)

# or
Apisync.logger = Rails.logger

Responses

All HTTP calls return an HTTPart::Response instance:

response = client.inventory_items.save(attributes)
response.success? # => true

In case too many requests are made simultaneously, the server will return 429 and this lib will raise the Apisync::TooManyRequests exception.

Development

To run tests:

bundle exec rspec spec

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/apisync/apisync-ruby.

License

The gem is available as open source under the terms of the MIT License.