Skip to content

API consuming models for the Trogdir directory project

License

Notifications You must be signed in to change notification settings

codenoble/trogdir-api-client

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

38 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Trogdir API Client Build Status

Installing

Add gem 'trogdir_api_client' to your Gemfile and run bundle

Configuration

TrogdirAPIClient.configure do |config|
  # Optional:
  # config.scheme = 'http'
  # config.host = 'localhost'
  # config.script_name = nil
  # config.version = 'v1'
  
  # Required:
  config.access_id = '**************'
  config.secret_key = '*****************************************'
end

Usage

Example Syncinator

require 'trogdir_api_client'
require 'multi_json'

trogdir = Trogdir::APIClient::ChangeSyncs.new
hashes = trogdir.start.perform.parse

hashes.each do |hash|
  sync_log_id = hash['sync_log_id']
  action = hash['action']
  person_id = hash['person_id']
  scope = hash['scope']
  original = hash['original']
  modified = hash['modified']

  action_taken = 'nothing'

  begin
    person = Person.find(person_id)

    case scope
    when 'person'
      case action
      when 'create'
        # do stuff
        action_taken = 'create'
      when 'update'
        # do stuff
        action_taken = 'update'
      when 'destroy'
        # do stuff
        action_taken = 'destroy'
      end
    when 'id'
      case action
      when 'create'
        # do stuff
        action_taken = 'create'
      when 'update'
        # do stuff
        action_taken = 'update'
      when 'destroy'
        # do stuff
        action_taken = 'destroy'
      end
    when 'email'
      # blah
    when 'photo'
      # blah
    when 'phone'
      # blah
    when 'address'
      # blah
    end

    trogdir.finish(sync_log_id: sync_log_id, action: action_taken).perform
  rescue StandardError => err
    trogdir.error(sync_log_id: sync_log_id, message: err.message).perform
  end
end

License

MIT

About

API consuming models for the Trogdir directory project

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages