GithubHelp home page GithubHelp logo

feapaydin / parasut-v4 Goto Github PK

View Code? Open in Web Editor NEW

This project forked from dijitalgaraj/parasut-v4

0.0 0.0 0.0 32 KB

Parasut API v4 Integration for Ruby applications.

License: MIT License

Ruby 99.68% Shell 0.32%

parasut-v4's Introduction

parasut-v4

Parasut API V4 integration. You can sign up for an parasut account at https://www.parasut.com/

Dependencies

  • her
  • kaminari 0.17.0

Requirements

  • Ruby 2.0.0 or newer

Installation

Add this line to your application's Gemfile:

gem 'parasut-v4'

And then execute:

$ bundle

Or install it yourself as:

$ gem install parasut-v4

Usage

Create an initializer for Parasut options.

  require 'parasut'

  # config/initializers/parasut.rb
  Parasut.options do |option|
    option.api_base_url="https://url" # this is optional, default is "https://api.parasut.com/"
    option.client_id = 'client_id'
    option.client_secret = 'client_secret'
    option.username = 'username'
    option.password = 'password'
    option.company_id = 'company_id'
  end

Afterwards you can call a model:

account = Parasut::Account.find(1)
puts account.inspect

contacts = Parasut::Contact.all
puts contacts.inspect

account.destroy

To paginate collections:

contacts=Parasut::Contact.all
contacts.page(2).per(25)
# Pagination uses kaminari. (https://github.com/kaminari/kaminari)

HttpClient

Parasut-v4 provides an http client integration to execute tasks manually. You can make your calls simply providing endpoint, body and headers. It automatically handles authentication and handles your request.

This is an http client, hence it does not manipulate the response into objects.

Making get requests:

# Parasut::HttpClient.get(endpoint, query_parameters, headers, parse_json=true)
#   parse_json tries to parse the response body into hash 
contact=Parasut::HttpClient.get("contacts/123")
contact[:data][:attributes][:name]

Executing post calls:

# Parasut::HttpClient.post(endpoint, body, headers, parse_json=true)
contact=Parasut::HttpClient.post("contacts", {
  data:{
    type: :contacts,
    attributes:{
      name: "Test From Api",
      account_type: :customer
    }
  }
)

ENVs

  • PARASUT_API_BASE_URL
  • PARASUT_CLIENT_ID
  • PARASUT_CLIENT_SECRET
  • PARASUT_USERNAME
  • PARASUT_PASSWORD
  • PARASUT_COMPANY_ID

Development

After checking out the repo, run bin/setup to install dependencies. 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/dijitalgaraj/parasut-v4. 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.

Contributors

This gem uses @ahtung 's Parasut API v1 gem as its base. (https://github.com/ahtung/parasut)

API Version 4 compability implemented by @dijitalgaraj - @feapaydin

License

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

parasut-v4's People

Contributors

feapaydin avatar furkan-enes avatar

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.