trogdir_api_client 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +80 -1
- data/lib/trogdir/api_client/addresses.rb +2 -3
- data/lib/trogdir/api_client/change_syncs.rb +2 -3
- data/lib/trogdir/api_client/emails.rb +2 -3
- data/lib/trogdir/api_client/ids.rb +2 -4
- data/lib/trogdir/api_client/people.rb +2 -4
- data/lib/trogdir/api_client/phones.rb +2 -3
- data/lib/trogdir/api_client/photos.rb +2 -3
- data/lib/trogdir/api_client/settings.rb +11 -0
- data/lib/trogdir_api_client.rb +6 -1
- data/lib/trogdir_api_client/version.rb +2 -2
- data/lib/weary/adapters/net_http_advanced.rb +16 -0
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ea9c3e595f525942487a98181287f1c6ed41c6ad
|
4
|
+
data.tar.gz: f6e92275bd78dcaa4a273419af082f4d7a0feb77
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c3aece16e1db4297f4e434c2494995e3d9202e17a5ec619b64ab3704705bf092a2c3151929ba9c28d639dc30f224832a4ec17497f7c6087d3afaa8d0ac44f914
|
7
|
+
data.tar.gz: 61e17953d264e2f47149750274ef0dfec6ae15438977805805f124b1c6c4c54000567ab8634616ace80238ae2261c2be4f28107d0eeada4b3b22574d72b400d5
|
data/README.md
CHANGED
@@ -6,10 +6,89 @@ Installing
|
|
6
6
|
|
7
7
|
Add `gem 'trogdir_api_client'` to your `Gemfile` and run `bundle`
|
8
8
|
|
9
|
+
Configuration
|
10
|
+
-------------
|
11
|
+
|
12
|
+
```ruby
|
13
|
+
TrogdirAPIClient.configure do |config|
|
14
|
+
# Optional:
|
15
|
+
# config.scheme = 'http'
|
16
|
+
# config.host = 'localhost'
|
17
|
+
# config.script_name = nil
|
18
|
+
# config.version = 'v1'
|
19
|
+
|
20
|
+
# Required:
|
21
|
+
config.access_id = '**************'
|
22
|
+
config.secret_key = '*****************************************'
|
23
|
+
end
|
24
|
+
```
|
25
|
+
|
9
26
|
Usage
|
10
27
|
-----
|
11
28
|
|
12
|
-
|
29
|
+
### Example Syncinator
|
30
|
+
|
31
|
+
```ruby
|
32
|
+
require 'trogdir_api_client'
|
33
|
+
require 'multi_json'
|
34
|
+
|
35
|
+
trogdir = Trogdir::APIClient::ChangeSyncs.new
|
36
|
+
hashes = trogdir.start.perform.parse
|
37
|
+
|
38
|
+
hashes.each do |hash|
|
39
|
+
sync_log_id = hash['sync_log_id']
|
40
|
+
action = hash['action']
|
41
|
+
person_id = hash['person_id']
|
42
|
+
scope = hash['scope']
|
43
|
+
original = hash['original']
|
44
|
+
modified = hash['modified']
|
45
|
+
|
46
|
+
action_taken = 'nothing'
|
47
|
+
|
48
|
+
begin
|
49
|
+
person = Person.find(person_id)
|
50
|
+
|
51
|
+
case scope
|
52
|
+
when 'person'
|
53
|
+
case action
|
54
|
+
when 'create'
|
55
|
+
# do stuff
|
56
|
+
action_taken = 'create'
|
57
|
+
when 'update'
|
58
|
+
# do stuff
|
59
|
+
action_taken = 'update'
|
60
|
+
when 'destroy'
|
61
|
+
# do stuff
|
62
|
+
action_taken = 'destroy'
|
63
|
+
end
|
64
|
+
when 'id'
|
65
|
+
case action
|
66
|
+
when 'create'
|
67
|
+
# do stuff
|
68
|
+
action_taken = 'create'
|
69
|
+
when 'update'
|
70
|
+
# do stuff
|
71
|
+
action_taken = 'update'
|
72
|
+
when 'destroy'
|
73
|
+
# do stuff
|
74
|
+
action_taken = 'destroy'
|
75
|
+
end
|
76
|
+
when 'email'
|
77
|
+
# blah
|
78
|
+
when 'photo'
|
79
|
+
# blah
|
80
|
+
when 'phone'
|
81
|
+
# blah
|
82
|
+
when 'address'
|
83
|
+
# blah
|
84
|
+
end
|
85
|
+
|
86
|
+
trogdir.finish(sync_log_id: sync_log_id, action: action_taken).perform
|
87
|
+
rescue StandardError => err
|
88
|
+
trogdir.error(sync_log_id: sync_log_id, message: err.message).perform
|
89
|
+
end
|
90
|
+
end
|
91
|
+
```
|
13
92
|
|
14
93
|
License
|
15
94
|
-------
|
@@ -1,8 +1,7 @@
|
|
1
1
|
module Trogdir
|
2
2
|
module APIClient
|
3
3
|
class Addresses < Weary::Client
|
4
|
-
|
5
|
-
use Weary::Middleware::HMACAuth, [TrogdirAPIClient.config.credentials]
|
4
|
+
include Settings
|
6
5
|
|
7
6
|
get :index, '/people/{uuid}/addresses'
|
8
7
|
|
@@ -20,4 +19,4 @@ module Trogdir
|
|
20
19
|
delete :destroy, '/people/{uuid}/addresses/{address_id}'
|
21
20
|
end
|
22
21
|
end
|
23
|
-
end
|
22
|
+
end
|
@@ -1,8 +1,7 @@
|
|
1
1
|
module Trogdir
|
2
2
|
module APIClient
|
3
3
|
class ChangeSyncs < Weary::Client
|
4
|
-
|
5
|
-
use Weary::Middleware::HMACAuth, [TrogdirAPIClient.config.credentials]
|
4
|
+
include Settings
|
6
5
|
|
7
6
|
put :start, '/change_syncs/start'
|
8
7
|
|
@@ -16,4 +15,4 @@ module Trogdir
|
|
16
15
|
end
|
17
16
|
end
|
18
17
|
end
|
19
|
-
end
|
18
|
+
end
|
@@ -1,8 +1,7 @@
|
|
1
1
|
module Trogdir
|
2
2
|
module APIClient
|
3
3
|
class Emails < Weary::Client
|
4
|
-
|
5
|
-
use Weary::Middleware::HMACAuth, [TrogdirAPIClient.config.credentials]
|
4
|
+
include Settings
|
6
5
|
|
7
6
|
get :index, '/people/{uuid}/emails'
|
8
7
|
|
@@ -20,4 +19,4 @@ module Trogdir
|
|
20
19
|
delete :destroy, '/people/{uuid}/emails/{email_id}'
|
21
20
|
end
|
22
21
|
end
|
23
|
-
end
|
22
|
+
end
|
@@ -1,9 +1,7 @@
|
|
1
1
|
module Trogdir
|
2
2
|
module APIClient
|
3
3
|
class IDs < Weary::Client
|
4
|
-
|
5
|
-
# use Weary::Middleware::ContentType
|
6
|
-
use Weary::Middleware::HMACAuth, [TrogdirAPIClient.config.credentials]
|
4
|
+
include Settings
|
7
5
|
|
8
6
|
get :index, '/people/{uuid}/ids'
|
9
7
|
|
@@ -20,4 +18,4 @@ module Trogdir
|
|
20
18
|
delete :destroy, '/people/{uuid}/ids/{id_id}'
|
21
19
|
end
|
22
20
|
end
|
23
|
-
end
|
21
|
+
end
|
@@ -1,9 +1,7 @@
|
|
1
1
|
module Trogdir
|
2
2
|
module APIClient
|
3
3
|
class People < Weary::Client
|
4
|
-
|
5
|
-
# use Weary::Middleware::ContentType
|
6
|
-
use Weary::Middleware::HMACAuth, [TrogdirAPIClient.config.credentials]
|
4
|
+
include Settings
|
7
5
|
|
8
6
|
get :index, '/people' do |resource|
|
9
7
|
resource.optional :affiliation
|
@@ -49,4 +47,4 @@ module Trogdir
|
|
49
47
|
end
|
50
48
|
end
|
51
49
|
end
|
52
|
-
end
|
50
|
+
end
|
@@ -1,8 +1,7 @@
|
|
1
1
|
module Trogdir
|
2
2
|
module APIClient
|
3
3
|
class Phones < Weary::Client
|
4
|
-
|
5
|
-
use Weary::Middleware::HMACAuth, [TrogdirAPIClient.config.credentials]
|
4
|
+
include Settings
|
6
5
|
|
7
6
|
get :index, '/people/{uuid}/phones'
|
8
7
|
|
@@ -20,4 +19,4 @@ module Trogdir
|
|
20
19
|
delete :destroy, '/people/{uuid}/phones/{phone_id}'
|
21
20
|
end
|
22
21
|
end
|
23
|
-
end
|
22
|
+
end
|
@@ -1,8 +1,7 @@
|
|
1
1
|
module Trogdir
|
2
2
|
module APIClient
|
3
3
|
class Photos < Weary::Client
|
4
|
-
|
5
|
-
use Weary::Middleware::HMACAuth, [TrogdirAPIClient.config.credentials]
|
4
|
+
include Settings
|
6
5
|
|
7
6
|
get :index, '/people/{uuid}/photos'
|
8
7
|
|
@@ -19,4 +18,4 @@ module Trogdir
|
|
19
18
|
delete :destroy, '/people/{uuid}/photos/{photo_id}'
|
20
19
|
end
|
21
20
|
end
|
22
|
-
end
|
21
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
module Trogdir
|
2
|
+
module APIClient
|
3
|
+
module Settings
|
4
|
+
def self.included(base)
|
5
|
+
base.send :domain, TrogdirAPIClient.config.base_url
|
6
|
+
base.send :adapter, Weary::Adapter::NetHttpAdvanced
|
7
|
+
base.send :use, Weary::Middleware::HMACAuth, [TrogdirAPIClient.config.credentials]
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
data/lib/trogdir_api_client.rb
CHANGED
@@ -14,6 +14,7 @@ end
|
|
14
14
|
|
15
15
|
module Trogdir
|
16
16
|
module APIClient
|
17
|
+
autoload :Settings, 'trogdir/api_client/settings'
|
17
18
|
autoload :People, 'trogdir/api_client/people'
|
18
19
|
autoload :IDs, 'trogdir/api_client/ids'
|
19
20
|
autoload :Emails, 'trogdir/api_client/emails'
|
@@ -28,4 +29,8 @@ module Weary
|
|
28
29
|
module Middleware
|
29
30
|
autoload :HMACAuth, 'weary/middleware/hmac_auth'
|
30
31
|
end
|
31
|
-
|
32
|
+
|
33
|
+
module Adapter
|
34
|
+
autoload :NetHttpAdvanced, 'weary/adapters/net_http_advanced'
|
35
|
+
end
|
36
|
+
end
|
@@ -1,3 +1,3 @@
|
|
1
1
|
module TrogdirAPIClient
|
2
|
-
VERSION = '0.
|
3
|
-
end
|
2
|
+
VERSION = '0.2.0'
|
3
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Weary
|
2
|
+
module Adapter
|
3
|
+
class NetHttpAdvanced < NetHttp
|
4
|
+
class << self
|
5
|
+
attr_accessor :timeout
|
6
|
+
end
|
7
|
+
|
8
|
+
def self.connect(request)
|
9
|
+
connection = socket(request)
|
10
|
+
connection.read_timeout = timeout unless timeout.nil?
|
11
|
+
response = connection.request prepare(request)
|
12
|
+
Rack::Response.new response.body || "", response.code, normalize_response(response.to_hash)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: trogdir_api_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adam Crownoble
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-07-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: api-auth
|
@@ -151,9 +151,11 @@ files:
|
|
151
151
|
- lib/trogdir/api_client/people.rb
|
152
152
|
- lib/trogdir/api_client/phones.rb
|
153
153
|
- lib/trogdir/api_client/photos.rb
|
154
|
+
- lib/trogdir/api_client/settings.rb
|
154
155
|
- lib/trogdir_api_client.rb
|
155
156
|
- lib/trogdir_api_client/configuration.rb
|
156
157
|
- lib/trogdir_api_client/version.rb
|
158
|
+
- lib/weary/adapters/net_http_advanced.rb
|
157
159
|
- lib/weary/middleware/hmac_auth.rb
|
158
160
|
homepage: https://github.com/biola/trogdir-api-client
|
159
161
|
licenses:
|
@@ -180,3 +182,4 @@ signing_key:
|
|
180
182
|
specification_version: 4
|
181
183
|
summary: Client for the Trogdir directory API
|
182
184
|
test_files: []
|
185
|
+
has_rdoc:
|