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 CHANGED
@@ -41,40 +41,42 @@ module Quill
41
41
  response
42
42
  end
43
43
 
44
- class Endpoint
45
- attr_accessor :name, :api
44
+ module Endpoint
45
+ class Base
46
+ attr_accessor :name, :api
46
47
 
47
- def initialize api, name, definition
48
- @api = api
49
- @name = name
50
- @attributes = definition['attributes'].keys
51
- @readonly_attributes = definition['readonly_attributes'].try(:keys) || []
52
- end
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
- def find id, params = {}
55
- check_keys(params)
56
- response = api.get([name,id].join('/'), params)
57
- Hashie::Mash.new(response.body['object'])
58
- end
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
- def create params
61
- check_keys(params)
62
- response = api.post(name, params)
63
- Hashie::Mash.new(response.body['object'])
64
- end
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
- def update id, params
67
- check_keys(params)
68
- response = api.put([name,id].join('/'), params)
69
- Hashie::Mash.new(response.body['object'])
70
- end
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
- def list
73
- end
73
+ def list
74
+ end
74
75
 
75
- def check_keys params
76
- invalid_keys = params.stringify_keys.keys - @attributes - @readonly_attributes
77
- raise InvalidKeys, "Endpoint ##{name} does not support key(s) #{invalid_keys.join(', ')}" unless invalid_keys.empty?
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
- Client::Endpoint.new(self, "activities", {"attributes"=>{"data"=>{}, "name"=>nil, "description"=>nil}, "access"=>{"list"=>["all"], "read"=>["all"], "update"=>["admin"], "create"=>["admin"], "destroy"=>["owner", "admin"]}})
5
+ Quill::Endpoints::Activities.new(self)
6
6
  end
7
7
 
8
8
  def activity_sessions
9
- Client::Endpoint.new(self, "activity_sessions", {"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"]}})
9
+ Quill::Endpoints::ActivitySessions.new(self)
10
10
  end
11
11
 
12
12
  def me
13
- Client::Endpoint.new(self, "me", {"attributes"=>{"role"=>nil}, "options"=>{"singular"=>true}, "access"=>nil})
13
+ Quill::Endpoints::Me.new(self)
14
14
  end
15
15
 
16
16
  def ping
17
- Client::Endpoint.new(self, "ping", {"attributes"=>{"session_id"=>nil, "status"=>nil}, "options"=>{"singular"=>true}, "access"=>{"read"=>["all"], "update"=>["owner", "admin"], "create"=>["user"], "destroy"=>["owner", "admin"]}})
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.5
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-13 00:00:00.000000000 Z
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: &70182730883920 !ruby/object:Gem::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: *70182730883920
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