trogdir_api 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/trogdir/versions/v1/addresses_api.rb +14 -5
- data/lib/trogdir/versions/v1/change_syncs_api.rb +10 -10
- data/lib/trogdir/versions/v1/emails_api.rb +14 -5
- data/lib/trogdir/versions/v1/entities/address.rb +1 -0
- data/lib/trogdir/versions/v1/entities/email.rb +1 -0
- data/lib/trogdir/versions/v1/entities/id.rb +1 -0
- data/lib/trogdir/versions/v1/entities/phone.rb +1 -0
- data/lib/trogdir/versions/v1/entities/photo.rb +1 -0
- data/lib/trogdir/versions/v1/ids_api.rb +14 -5
- data/lib/trogdir/versions/v1/people_api.rb +7 -4
- data/lib/trogdir/versions/v1/phones_api.rb +14 -5
- data/lib/trogdir/versions/v1/photos_api.rb +14 -5
- data/lib/trogdir_api/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 94a2d90b3c249f0b5eecb43e9cbe7122582b9570
|
4
|
+
data.tar.gz: 3ac808217184e16102e5ca11555c9bd7ef7707d2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d5e189f20a678f1880920e53b5970daaa6127d94e678e9abb4af7861df9cc7ffba8fdbc4abf15126657333064b95696f03fe18430317d3d2f435492db30ce1f1
|
7
|
+
data.tar.gz: 0d4cd9d6477690cbaf5889100bb2b14417f260922ccb395a4e24c13fe08cfd8b72ca3d16bd0ca72b000b689e2c199c9aa9b556c495c7cf8e250ddadae62ba787
|
@@ -2,15 +2,20 @@ module Trogdir
|
|
2
2
|
module V1
|
3
3
|
class AddressesAPI < Grape::API
|
4
4
|
resource :addresses do
|
5
|
+
before do
|
6
|
+
@person = Person.find_by(uuid: params[:person_id]) if params[:person_id]
|
7
|
+
@address = @person.addresses.find(params[:address_id]) if params[:address_id]
|
8
|
+
end
|
9
|
+
|
5
10
|
get do
|
6
|
-
present
|
11
|
+
present @person.addresses, with: AddressEntity
|
7
12
|
end
|
8
13
|
|
9
14
|
params do
|
10
15
|
requires :address_id, type: String
|
11
16
|
end
|
12
17
|
get ':address_id' do
|
13
|
-
present
|
18
|
+
present @address, with: AddressEntity
|
14
19
|
end
|
15
20
|
|
16
21
|
params do
|
@@ -23,7 +28,7 @@ module Trogdir
|
|
23
28
|
optional :contry, type: String
|
24
29
|
end
|
25
30
|
post do
|
26
|
-
|
31
|
+
present @person.addresses.create!(clean_params(except: :person_id)), with: AddressEntity
|
27
32
|
end
|
28
33
|
|
29
34
|
params do
|
@@ -37,14 +42,18 @@ module Trogdir
|
|
37
42
|
optional :contry, type: String
|
38
43
|
end
|
39
44
|
put ':address_id' do
|
40
|
-
|
45
|
+
@address.update_attributes! clean_params(except: [:person_id, :address_id])
|
46
|
+
|
47
|
+
present @address, with: AddressEntity
|
41
48
|
end
|
42
49
|
|
43
50
|
params do
|
44
51
|
requires :address_id, type: String
|
45
52
|
end
|
46
53
|
delete ':address_id' do
|
47
|
-
|
54
|
+
@address.destroy
|
55
|
+
|
56
|
+
present @address, with: AddressEntity
|
48
57
|
end
|
49
58
|
end
|
50
59
|
end
|
@@ -2,6 +2,14 @@ module Trogdir
|
|
2
2
|
module V1
|
3
3
|
class ChangeSyncsAPI < Grape::API
|
4
4
|
resource :change_syncs do
|
5
|
+
before do
|
6
|
+
if params[:sync_log_id]
|
7
|
+
@sync_log = SyncLog.find_through_parents(params[:sync_log_id])
|
8
|
+
|
9
|
+
unauthorized! unless @sync_log.syncinator == current_syncinator
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
5
13
|
desc "Return and starts change_syncs that haven't been started"
|
6
14
|
put :start do
|
7
15
|
syncinator = current_syncinator
|
@@ -20,11 +28,7 @@ module Trogdir
|
|
20
28
|
requires :message, type: String
|
21
29
|
end
|
22
30
|
put 'error/:sync_log_id' do
|
23
|
-
sync_log
|
24
|
-
|
25
|
-
unauthorized! unless sync_log.syncinator == current_syncinator
|
26
|
-
|
27
|
-
current_syncinator.error! sync_log, params[:message]
|
31
|
+
current_syncinator.error! @sync_log, params[:message]
|
28
32
|
end
|
29
33
|
|
30
34
|
desc "Return a sync_log and mark it as succeeded"
|
@@ -34,11 +38,7 @@ module Trogdir
|
|
34
38
|
optional :message, type: String
|
35
39
|
end
|
36
40
|
put 'finish/:sync_log_id' do
|
37
|
-
sync_log
|
38
|
-
|
39
|
-
unauthorized! unless sync_log.syncinator == current_syncinator
|
40
|
-
|
41
|
-
current_syncinator.finish! sync_log, params[:action], params[:message]
|
41
|
+
current_syncinator.finish! @sync_log, params[:action], params[:message]
|
42
42
|
end
|
43
43
|
end
|
44
44
|
end
|
@@ -2,15 +2,20 @@ module Trogdir
|
|
2
2
|
module V1
|
3
3
|
class EmailsAPI < Grape::API
|
4
4
|
resource :emails do
|
5
|
+
before do
|
6
|
+
@person = Person.find_by(uuid: params[:person_id]) if params[:person_id]
|
7
|
+
@email = @person.emails.find(params[:email_id]) if params[:email_id]
|
8
|
+
end
|
9
|
+
|
5
10
|
get do
|
6
|
-
present
|
11
|
+
present @person.emails, with: EmailEntity
|
7
12
|
end
|
8
13
|
|
9
14
|
params do
|
10
15
|
requires :email_id, type: String
|
11
16
|
end
|
12
17
|
get ':email_id' do
|
13
|
-
present
|
18
|
+
present @email, with: EmailEntity
|
14
19
|
end
|
15
20
|
|
16
21
|
params do
|
@@ -19,7 +24,7 @@ module Trogdir
|
|
19
24
|
optional :primary, type: Boolean
|
20
25
|
end
|
21
26
|
post do
|
22
|
-
|
27
|
+
present @person.emails.create!(clean_params(except: :person_id)), with: EmailEntity
|
23
28
|
end
|
24
29
|
|
25
30
|
params do
|
@@ -29,14 +34,18 @@ module Trogdir
|
|
29
34
|
optional :primary, type: Boolean
|
30
35
|
end
|
31
36
|
put ':email_id' do
|
32
|
-
|
37
|
+
@email.update_attributes! clean_params(except: [:person_id, :email_id])
|
38
|
+
|
39
|
+
present @email, with: EmailEntity
|
33
40
|
end
|
34
41
|
|
35
42
|
params do
|
36
43
|
requires :email_id, type: String
|
37
44
|
end
|
38
45
|
delete ':email_id' do
|
39
|
-
|
46
|
+
@email.destroy
|
47
|
+
|
48
|
+
present @email, with: EmailEntity
|
40
49
|
end
|
41
50
|
end
|
42
51
|
end
|
@@ -2,8 +2,13 @@ module Trogdir
|
|
2
2
|
module V1
|
3
3
|
class IDsAPI < Grape::API
|
4
4
|
resource :ids do
|
5
|
+
before do
|
6
|
+
@person = Person.find_by(uuid: params[:person_id])
|
7
|
+
@id = @person.ids.find(params[:id_id]) if params[:id_id]
|
8
|
+
end
|
9
|
+
|
5
10
|
get do
|
6
|
-
present
|
11
|
+
present @person.ids, with: IDEntity
|
7
12
|
end
|
8
13
|
|
9
14
|
params do
|
@@ -11,7 +16,7 @@ module Trogdir
|
|
11
16
|
requires :id_id, type: String
|
12
17
|
end
|
13
18
|
get ':id_id' do
|
14
|
-
present
|
19
|
+
present @id, with: IDEntity
|
15
20
|
end
|
16
21
|
|
17
22
|
params do
|
@@ -19,7 +24,7 @@ module Trogdir
|
|
19
24
|
requires :identifier
|
20
25
|
end
|
21
26
|
post do
|
22
|
-
|
27
|
+
present @person.ids.create!(clean_params(except: :person_id)), with: IDEntity
|
23
28
|
end
|
24
29
|
|
25
30
|
params do
|
@@ -28,14 +33,18 @@ module Trogdir
|
|
28
33
|
optional :identifier
|
29
34
|
end
|
30
35
|
put ':id_id' do
|
31
|
-
|
36
|
+
@id.update_attributes! clean_params(except: [:person_id, :id_id])
|
37
|
+
|
38
|
+
present @id, with: IDEntity
|
32
39
|
end
|
33
40
|
|
34
41
|
params do
|
35
42
|
requires :id_id, type: String
|
36
43
|
end
|
37
44
|
delete ':id_id' do
|
38
|
-
|
45
|
+
@id.destroy
|
46
|
+
|
47
|
+
present @id, with: IDEntity
|
39
48
|
end
|
40
49
|
end
|
41
50
|
end
|
@@ -4,6 +4,10 @@ module Trogdir
|
|
4
4
|
UUID_REGEXP = /[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/
|
5
5
|
|
6
6
|
resource :people do
|
7
|
+
before do
|
8
|
+
@person = Person.find_by(uuid: params[:person_id]) if params[:person_id]
|
9
|
+
end
|
10
|
+
|
7
11
|
desc 'Get a list of people'
|
8
12
|
params do
|
9
13
|
optional :affiliation, type: String
|
@@ -32,7 +36,7 @@ module Trogdir
|
|
32
36
|
requires :person_id, desc: 'Person ID'
|
33
37
|
end
|
34
38
|
get ':person_id', requirements: {person_id: UUID_REGEXP} do
|
35
|
-
present
|
39
|
+
present @person, with: PersonEntity
|
36
40
|
end
|
37
41
|
|
38
42
|
desc 'Create a person'
|
@@ -116,10 +120,9 @@ module Trogdir
|
|
116
120
|
optional :pay_type, type: Symbol
|
117
121
|
end
|
118
122
|
put ':person_id', requirements: {person_id: UUID_REGEXP} do
|
119
|
-
person
|
120
|
-
person.update_attributes! clean_params(except: :person_id)
|
123
|
+
@person.update_attributes! clean_params(except: :person_id)
|
121
124
|
|
122
|
-
present person, with: PersonEntity
|
125
|
+
present @person, with: PersonEntity
|
123
126
|
end
|
124
127
|
end
|
125
128
|
end
|
@@ -2,15 +2,20 @@ module Trogdir
|
|
2
2
|
module V1
|
3
3
|
class PhonesAPI < Grape::API
|
4
4
|
resource :phones do
|
5
|
+
before do
|
6
|
+
@person = Person.find_by(uuid: params[:person_id]) if params[:person_id]
|
7
|
+
@phone = @person.phones.find(params[:phone_id]) if params[:phone_id]
|
8
|
+
end
|
9
|
+
|
5
10
|
get do
|
6
|
-
present
|
11
|
+
present @person.phones, with: PhoneEntity
|
7
12
|
end
|
8
13
|
|
9
14
|
params do
|
10
15
|
requires :phone_id, type: String
|
11
16
|
end
|
12
17
|
get ':phone_id' do
|
13
|
-
present
|
18
|
+
present @phone, with: PhoneEntity
|
14
19
|
end
|
15
20
|
|
16
21
|
params do
|
@@ -19,7 +24,7 @@ module Trogdir
|
|
19
24
|
optional :primary, type: Boolean
|
20
25
|
end
|
21
26
|
post do
|
22
|
-
|
27
|
+
present @person.phones.create!(clean_params(except: :person_id)), with: PhoneEntity
|
23
28
|
end
|
24
29
|
|
25
30
|
params do
|
@@ -29,14 +34,18 @@ module Trogdir
|
|
29
34
|
optional :primary, type: Boolean
|
30
35
|
end
|
31
36
|
put ':phone_id' do
|
32
|
-
|
37
|
+
@phone.update_attributes! clean_params(except: [:person_id, :phone_id])
|
38
|
+
|
39
|
+
present @phone, with: PhoneEntity
|
33
40
|
end
|
34
41
|
|
35
42
|
params do
|
36
43
|
requires :phone_id, type: String
|
37
44
|
end
|
38
45
|
delete ':phone_id' do
|
39
|
-
|
46
|
+
@phone.destroy
|
47
|
+
|
48
|
+
present @phone, with: PhoneEntity
|
40
49
|
end
|
41
50
|
end
|
42
51
|
end
|
@@ -2,15 +2,20 @@ module Trogdir
|
|
2
2
|
module V1
|
3
3
|
class PhotosAPI < Grape::API
|
4
4
|
resource :photos do
|
5
|
+
before do
|
6
|
+
@person = Person.find_by(uuid: params[:person_id]) if params[:person_id]
|
7
|
+
@photo = @person.photos.find(params[:photo_id]) if params[:photo_id]
|
8
|
+
end
|
9
|
+
|
5
10
|
get do
|
6
|
-
present
|
11
|
+
present @person.photos, with: PhotoEntity
|
7
12
|
end
|
8
13
|
|
9
14
|
params do
|
10
15
|
requires :photo_id, type: String
|
11
16
|
end
|
12
17
|
get ':photo_id' do
|
13
|
-
present
|
18
|
+
present @photo, with: PhotoEntity
|
14
19
|
end
|
15
20
|
|
16
21
|
params do
|
@@ -20,7 +25,7 @@ module Trogdir
|
|
20
25
|
optional :width, type: Integer
|
21
26
|
end
|
22
27
|
post do
|
23
|
-
|
28
|
+
present @person.photos.create!(clean_params(except: :person_id)), with: PhotoEntity
|
24
29
|
end
|
25
30
|
|
26
31
|
params do
|
@@ -31,14 +36,18 @@ module Trogdir
|
|
31
36
|
optional :width, type: Integer
|
32
37
|
end
|
33
38
|
put ':photo_id' do
|
34
|
-
|
39
|
+
@photo.update_attributes! clean_params(except: [:person_id, :photo_id])
|
40
|
+
|
41
|
+
present @photo, with: PhotoEntity
|
35
42
|
end
|
36
43
|
|
37
44
|
params do
|
38
45
|
requires :photo_id, type: String
|
39
46
|
end
|
40
47
|
delete ':photo_id' do
|
41
|
-
|
48
|
+
@photo.destroy
|
49
|
+
|
50
|
+
present @photo, with: PhotoEntity
|
42
51
|
end
|
43
52
|
end
|
44
53
|
end
|
data/lib/trogdir_api/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: trogdir_api
|
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-04-
|
11
|
+
date: 2014-04-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: api-auth
|