https://github.com/codenoble/trogdir-api-client
API consuming models for the Trogdir directory project
https://github.com/codenoble/trogdir-api-client
Last synced: 8 months ago
JSON representation
API consuming models for the Trogdir directory project
- Host: GitHub
- URL: https://github.com/codenoble/trogdir-api-client
- Owner: codenoble
- License: mit
- Created: 2015-12-23T00:32:53.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2015-12-22T23:35:07.000Z (over 10 years ago)
- Last Synced: 2025-03-21T23:35:00.463Z (over 1 year ago)
- Language: Ruby
- Size: 29.3 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: MIT-LICENSE
Awesome Lists containing this project
README
Trogdir API Client [](https://travis-ci.org/biola/trogdir-api-client)
==================
Installing
----------
Add `gem 'trogdir_api_client'` to your `Gemfile` and run `bundle`
Configuration
-------------
```ruby
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
```ruby
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