quill-api-client 0.1.6 → 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.
- data/lib/quill.rb +1 -0
- data/lib/quill/client.rb +0 -40
- data/lib/quill/endpoint_base.rb +41 -0
- data/lib/quill/endpoint_definitions.rb +6 -4
- data/lib/quill/endpoints.rb +1 -0
- metadata +5 -4
data/lib/quill.rb
CHANGED
@@ -6,6 +6,7 @@ module Quill
|
|
6
6
|
autoload :BaseModel, 'quill/base_model'
|
7
7
|
autoload :Client, 'quill/client'
|
8
8
|
autoload :Configuration, 'quill/configuration'
|
9
|
+
autoload :Endpoint, 'quill/endpoints'
|
9
10
|
autoload :EndpointDefinitions, 'quill/endpoint_definitions'
|
10
11
|
autoload :Oauth, 'quill/oauth'
|
11
12
|
|
data/lib/quill/client.rb
CHANGED
@@ -40,45 +40,5 @@ module Quill
|
|
40
40
|
raise response.error if response.status == 401
|
41
41
|
response
|
42
42
|
end
|
43
|
-
|
44
|
-
module Endpoint
|
45
|
-
class Base
|
46
|
-
attr_accessor :name, :api
|
47
|
-
|
48
|
-
def initialize api, name, definition
|
49
|
-
@api = api
|
50
|
-
@name = name
|
51
|
-
@attributes = definition['attributes'].keys
|
52
|
-
@readonly_attributes = definition['readonly_attributes'].try(:keys) || []
|
53
|
-
end
|
54
|
-
|
55
|
-
def find id, params = {}
|
56
|
-
check_keys(params)
|
57
|
-
response = api.get([name,id].join('/'), params)
|
58
|
-
Hashie::Mash.new(response.body['object'])
|
59
|
-
end
|
60
|
-
|
61
|
-
def create params
|
62
|
-
check_keys(params)
|
63
|
-
response = api.post(name, params)
|
64
|
-
Hashie::Mash.new(response.body['object'])
|
65
|
-
end
|
66
|
-
|
67
|
-
def update id, params
|
68
|
-
check_keys(params)
|
69
|
-
response = api.put([name,id].join('/'), params)
|
70
|
-
Hashie::Mash.new(response.body['object'])
|
71
|
-
end
|
72
|
-
|
73
|
-
def list
|
74
|
-
end
|
75
|
-
|
76
|
-
def check_keys params
|
77
|
-
invalid_keys = params.stringify_keys.keys - @attributes - @readonly_attributes
|
78
|
-
raise InvalidKeys, "Endpoint ##{name} does not support key(s) #{invalid_keys.join(', ')}" unless invalid_keys.empty?
|
79
|
-
end
|
80
|
-
end
|
81
|
-
end
|
82
43
|
end
|
83
|
-
|
84
44
|
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
module Quill
|
2
|
+
module Endpoint
|
3
|
+
class Base
|
4
|
+
attr_accessor :name, :api
|
5
|
+
class InvalidKeys < Exception ; end
|
6
|
+
|
7
|
+
def initialize api, name, definition
|
8
|
+
@api = api
|
9
|
+
@name = name
|
10
|
+
@attributes = definition['attributes'].keys
|
11
|
+
@readonly_attributes = definition['readonly_attributes'].try(:keys) || []
|
12
|
+
end
|
13
|
+
|
14
|
+
def find id, params = {}
|
15
|
+
check_keys(params)
|
16
|
+
response = api.get([name,id].join('/'), params)
|
17
|
+
Hashie::Mash.new(response.body['object'])
|
18
|
+
end
|
19
|
+
|
20
|
+
def create params
|
21
|
+
check_keys(params)
|
22
|
+
response = api.post(name, params)
|
23
|
+
Hashie::Mash.new(response.body['object'])
|
24
|
+
end
|
25
|
+
|
26
|
+
def update id, params
|
27
|
+
check_keys(params)
|
28
|
+
response = api.put([name,id].join('/'), params)
|
29
|
+
Hashie::Mash.new(response.body['object'])
|
30
|
+
end
|
31
|
+
|
32
|
+
def list
|
33
|
+
end
|
34
|
+
|
35
|
+
def check_keys params
|
36
|
+
invalid_keys = params.stringify_keys.keys - @attributes - @readonly_attributes
|
37
|
+
raise InvalidKeys, "Endpoint ##{name} does not support key(s) #{invalid_keys.join(', ')}" unless invalid_keys.empty?
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -1,20 +1,22 @@
|
|
1
|
+
require 'quill/endpoints'
|
2
|
+
|
1
3
|
module Quill
|
2
4
|
module EndpointDefinitions
|
3
5
|
|
4
6
|
def activities
|
5
|
-
Quill::
|
7
|
+
Quill::Endpoint::Activities.new(self, 'activities', {"description"=>"\nProgrammatically interact with Activities on Compass. Typically only will\nread individual records from this resource.\n", "attributes"=>{"data"=>{}, "name"=>nil, "description"=>nil}, "access"=>{"list"=>["all"], "read"=>["all"], "update"=>["admin"], "create"=>["admin"], "destroy"=>["owner", "admin"]}, "options"=>{}})
|
6
8
|
end
|
7
9
|
|
8
10
|
def activity_sessions
|
9
|
-
Quill::
|
11
|
+
Quill::Endpoint::ActivitySessions.new(self, 'activity_sessions', {"description"=>"\nCompass activity sessions are used to store progress information about a\nuser's interaction with an activity. Session's can be created without an\n+access_token+ to allow anonymous access. If you have an ID of an\nanonymous session you should also be able to update it without an\n+access_token+.\n", "attributes"=>{"percentage"=>nil, "time_spent"=>nil, "state"=>nil, "completed_at"=>nil, "data"=>{}, "temporary"=>nil, "activity_uid"=>nil, "anonymous"=>nil}, "access"=>{"list"=>["all"], "read"=>["owner"], "update"=>["owner", "admin"], "create"=>["all"], "destroy"=>["owner", "admin"]}, "options"=>{}})
|
10
12
|
end
|
11
13
|
|
12
14
|
def me
|
13
|
-
Quill::
|
15
|
+
Quill::Endpoint::Me.new(self, 'me', {"description"=>"\nRequest information about the current authenticated user based on\n+access_token+.\n", "attributes"=>{"role"=>nil, "name"=>nil, "email"=>nil, "username"=>nil}, "options"=>{"singular"=>true}, "access"=>{"read"=>["all"], "update"=>["owner", "admin"], "create"=>["user"], "destroy"=>["owner", "admin"]}})
|
14
16
|
end
|
15
17
|
|
16
18
|
def ping
|
17
|
-
Quill::
|
19
|
+
Quill::Endpoint::Ping.new(self, 'ping', {"description"=>"Alive check.\n", "attributes"=>{"session_id"=>nil, "status"=>nil}, "options"=>{"singular"=>true}, "access"=>{"read"=>["all"], "update"=>["owner", "admin"], "create"=>["user"], "destroy"=>["owner", "admin"]}})
|
18
20
|
end
|
19
21
|
|
20
22
|
end
|
data/lib/quill/endpoints.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: quill-api-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-
|
12
|
+
date: 2014-04-10 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: oauth2
|
16
|
-
requirement: &
|
16
|
+
requirement: &70353735723940 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,7 +21,7 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70353735723940
|
25
25
|
description: Wrapper to Quill API
|
26
26
|
email: quinn@tastehoneyco.com
|
27
27
|
executables: []
|
@@ -33,6 +33,7 @@ files:
|
|
33
33
|
- lib/quill/base_model.rb
|
34
34
|
- lib/quill/client.rb
|
35
35
|
- lib/quill/configuration.rb
|
36
|
+
- lib/quill/endpoint_base.rb
|
36
37
|
- lib/quill/endpoint_definitions.rb
|
37
38
|
- lib/quill/endpoints.rb
|
38
39
|
- lib/quill/oauth.rb
|