Giter Club home page Giter Club logo

api_notify's Introduction

Code Climate

API notify

Installation

gem 'api_notify', :git => "https://github.com/ekaukis/api_notify.git"

bundle

Instruction

  • Add config file

     # config/initializers/api_notify.rb
    
     ApiNotify.configure do |config|
       config.active = false
       config.config_file = "#{Rails.root.to_s}/config/api_notify.yml"
     end
    
  • Add enpoints

     envoronment:
       one: #endpoint name
         domain: example.com
         port: 443
         base_path: /api/v1
         api_key: your_secret_api_key
       other: #endpoint name
         domain: example.com
         port: 443
         base_path: /api/v1
         api_key: your_secret_api_key
    
  • Add api_notify to models

     api_notify [
       :attribute_name,
       'association.attribute_name'
     ], # fields being checkd for changes
     {
       id: :id
     }, # Identificators
     {
       one: {
         skip_synchronize: :one_dont_do_synchronize,
       },
       other: {
         skip_synchronize: :other_dont_do_synchronize,
       }
     }, # endpoint config
     route_name: "the_route"
    
  • Define custom synchronization methods for each endpoint - skip_synchronize and is_synchronized

  • If nescessary add callbacks for succes or failing

    • #{endpoint}api_notify#{method}_success
    • #{endpoint}api_notify#{method}_failed

    ** methods are - post, delete, get and put

API notify tables

Api notify gem uses Two tables, one for storing tasks and second for loging changes. Both tables have polymorphic assosiation with api_notified models.

api_notify_tasks

  • fields_updated - text (serialized hash)
  • api_notifiable - polymorphic fields combination ( points to api_notify model )
  • endpoint - string
  • done - boolean (true if synchronization succeded)
  • response - text (json or message from endpoint)

api_notify_log

Only one record for one api_notified instance

  • api_notify_logable - polymorphic fields combination ( points to api_notify model )
  • endpoint - on which endpoint it is synchronized

Dependencies

  • Rails 4.0
  • Sidekiq
  • Redis

TODO

  • Make generators for configs and db migrations

api_notify's People

Contributors

ekaukis avatar

Watchers

 avatar  avatar

Forkers

zznull

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.