Giter Site home page Giter Site logo

infosimples-data's Introduction

Infosimples::Data

Ruby API for Infosimples::Data (https://infosimples.com/).

Installation

Add this line to your application's Gemfile:

gem 'infosimples-data'

And then execute:

$ bundle

Or install it yourself as:

$ gem install infosimples-data

Usage

  1. Create a client
require 'infosimples/data'
client = Infosimples::Data::Client.new('my_token')
  1. Automate a service
response = client.automate('correios/cep', cep: '01311915')
response['code']                  # 200
response['code_message']          # "A consulta foi realizada com sucesso e retornou um resultado."
response['data']                  # Information about the postal code
response['receipt']['sites_urls'] # Links for the original HTMLs.

client.download_sites_urls(response) # Array with HTML bodies for `sites_urls`.

Check the full response in our documentation: https://data.infosimples.com/docs

  1. Billing
billing = client.billing          # Array of Hashes with:
billing.first['name']             # - Name of the Token
billing.first['quantity']         # - Number of automation requests the token has made
billing.first['credits']          # - How many credits the token has used
  1. Pricing
pricing = client.pricing          # Array of Hashes with:
pricing.first['service']          # - Name of the service that can be automated
pricing.first['credits']          # - How many credits this service uses
  1. Response codes
# Check a response code:
response['code'] == Infosimples::Data::CODE[:single_result]

# List of codes
{
  # success
  single_result:          200,
  multiple_results:       201,

  # error
  unexpected_error:       600,
  unauthorized:           601,
  invalid_service:        602,
  forbidden:              603,
  invalid_request:        604,
  timeout:                605,
  empty_parameters:       606,
  invalid_parameters:     607,
  refused_parameters:     608,
  attempts_exceeded:      609,
  failed_captcha:         610,
  incomplete_data:        611,
  inexistent:             612,
  blocked_request:        613,
  try_again:              614,
  source_unavailable:     615,
  source_error:           616,
  service_overloaded:     617,
  rate_limit_exceeded:    618,
  converted_parameters:   619,
  permanent_error:        620,
  receipt_error:          621,
}

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/infosimples/infosimples-data.

License

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

infosimples-data's People

Contributors

barbolo avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

Forkers

devton

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.