quill-api-client 0.1.5 → 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/quill/client.rb +30 -28
- data/lib/quill/endpoint_definitions.rb +4 -4
- data/lib/quill/endpoints.rb +88 -0
- metadata +5 -4
data/lib/quill/client.rb
CHANGED
@@ -41,40 +41,42 @@ module Quill
|
|
41
41
|
response
|
42
42
|
end
|
43
43
|
|
44
|
-
|
45
|
-
|
44
|
+
module Endpoint
|
45
|
+
class Base
|
46
|
+
attr_accessor :name, :api
|
46
47
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
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
|
53
54
|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
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
|
59
60
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
61
|
+
def create params
|
62
|
+
check_keys(params)
|
63
|
+
response = api.post(name, params)
|
64
|
+
Hashie::Mash.new(response.body['object'])
|
65
|
+
end
|
65
66
|
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
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
|
71
72
|
|
72
|
-
|
73
|
-
|
73
|
+
def list
|
74
|
+
end
|
74
75
|
|
75
|
-
|
76
|
-
|
77
|
-
|
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
|
78
80
|
end
|
79
81
|
end
|
80
82
|
end
|
@@ -2,19 +2,19 @@ module Quill
|
|
2
2
|
module EndpointDefinitions
|
3
3
|
|
4
4
|
def activities
|
5
|
-
|
5
|
+
Quill::Endpoints::Activities.new(self)
|
6
6
|
end
|
7
7
|
|
8
8
|
def activity_sessions
|
9
|
-
|
9
|
+
Quill::Endpoints::ActivitySessions.new(self)
|
10
10
|
end
|
11
11
|
|
12
12
|
def me
|
13
|
-
|
13
|
+
Quill::Endpoints::Me.new(self)
|
14
14
|
end
|
15
15
|
|
16
16
|
def ping
|
17
|
-
|
17
|
+
Quill::Endpoints::Ping.new(self)
|
18
18
|
end
|
19
19
|
|
20
20
|
end
|
@@ -0,0 +1,88 @@
|
|
1
|
+
module Quill
|
2
|
+
module Endpoint
|
3
|
+
|
4
|
+
class Activities < Base
|
5
|
+
# Programmatically interact with Activities on Compass. Typically only will
|
6
|
+
# read individual records from this resource.
|
7
|
+
# @param id [String] the id of the Activity
|
8
|
+
def find *args
|
9
|
+
super
|
10
|
+
end
|
11
|
+
|
12
|
+
# Programmatically interact with Activities on Compass. Typically only will
|
13
|
+
# read individual records from this resource.
|
14
|
+
# @param [Hash] properties properties for create
|
15
|
+
# @option properties [String] :data
|
16
|
+
# @option properties [String] :name
|
17
|
+
# @option properties [String] :description
|
18
|
+
def create *args
|
19
|
+
super
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
class ActivitySessions < Base
|
24
|
+
# Compass activity sessions are used to store progress information about a
|
25
|
+
# user's interaction with an activity. Session's can be created without an
|
26
|
+
# +access_token+ to allow anonymous access. If you have an ID of an
|
27
|
+
# anonymous session you should also be able to update it without an
|
28
|
+
# +access_token+.
|
29
|
+
# @param id [String] the id of the Activity session
|
30
|
+
def find *args
|
31
|
+
super
|
32
|
+
end
|
33
|
+
|
34
|
+
# Compass activity sessions are used to store progress information about a
|
35
|
+
# user's interaction with an activity. Session's can be created without an
|
36
|
+
# +access_token+ to allow anonymous access. If you have an ID of an
|
37
|
+
# anonymous session you should also be able to update it without an
|
38
|
+
# +access_token+.
|
39
|
+
# @param [Hash] properties properties for create
|
40
|
+
# @option properties [String] :percentage
|
41
|
+
# @option properties [String] :time_spent
|
42
|
+
# @option properties [String] :state
|
43
|
+
# @option properties [String] :completed_at
|
44
|
+
# @option properties [String] :data
|
45
|
+
# @option properties [String] :temporary
|
46
|
+
# @option properties [String] :activity_uid
|
47
|
+
# @option properties [String] :anonymous
|
48
|
+
def create *args
|
49
|
+
super
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
class Me < Base
|
54
|
+
# Request information about the current authenticated user based on
|
55
|
+
# +access_token+.
|
56
|
+
def find *args
|
57
|
+
super
|
58
|
+
end
|
59
|
+
|
60
|
+
# Request information about the current authenticated user based on
|
61
|
+
# +access_token+.
|
62
|
+
# @param [Hash] properties properties for create
|
63
|
+
# @option properties [String] :role
|
64
|
+
# @option properties [String] :name
|
65
|
+
# @option properties [String] :email
|
66
|
+
# @option properties [String] :username
|
67
|
+
def create *args
|
68
|
+
super
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
class Ping < Base
|
73
|
+
# Alive check.
|
74
|
+
def find *args
|
75
|
+
super
|
76
|
+
end
|
77
|
+
|
78
|
+
# Alive check.
|
79
|
+
# @param [Hash] properties properties for create
|
80
|
+
# @option properties [String] :session_id
|
81
|
+
# @option properties [String] :status
|
82
|
+
def create *args
|
83
|
+
super
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
end
|
88
|
+
end
|
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.1.
|
4
|
+
version: 0.1.6
|
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-03-
|
12
|
+
date: 2014-03-24 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: oauth2
|
16
|
-
requirement: &
|
16
|
+
requirement: &70335961783660 !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: *70335961783660
|
25
25
|
description: Wrapper to Quill API
|
26
26
|
email: quinn@tastehoneyco.com
|
27
27
|
executables: []
|
@@ -34,6 +34,7 @@ files:
|
|
34
34
|
- lib/quill/client.rb
|
35
35
|
- lib/quill/configuration.rb
|
36
36
|
- lib/quill/endpoint_definitions.rb
|
37
|
+
- lib/quill/endpoints.rb
|
37
38
|
- lib/quill/oauth.rb
|
38
39
|
- lib/quill-api-client.rb
|
39
40
|
- lib/quill.rb
|