planning_client 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ NjkzNTdjMDcxMGYzZjBlZWM3ZTEzMmQ0ZjYxZWYwZDZiNjM5MDBjYw==
5
+ data.tar.gz: !binary |-
6
+ ZDI0NDA2ODU3MjJkODYzNzY2MDA2MWNkNzY3ZjkxMjE5ZGM4ZmYyOA==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ MmM5ZDRlODE4OGNlNmIzZjA1NDc5MDMwNzBjZGM4N2JhNGI4M2I1M2Y0NDEw
10
+ ZDE1OTg2NjU2YWMwZDE0OTlmOTkxZTc1MDdkNTkyMGI5MjBlYTU0MmFlZWMx
11
+ YzllMGVlMjk1MDE1MDZiZTM1ODVjNTU5YTkyNWNjZDQwYmQxYTM=
12
+ data.tar.gz: !binary |-
13
+ MjI5Y2IyMTc2N2ZmM2YzZmU5ZDVlOWI3YjA4ZTVhOWIwNzAzY2ZjYjNlNTc5
14
+ YzBlMmNlZTU5MDQxN2ZmODYzNWI2YmZjYzc1Nzg1MmQxMTBmMDk5NTUyNjI4
15
+ YzhjYjAxOTM0NTE3MWJiODgyOWNmNjUzNzFmN2EzMThhYWI5YzQ=
@@ -0,0 +1,37 @@
1
+ require 'planning_client/service_configuration'
2
+
3
+ module PlanningClient
4
+ class Checklist < LogicalModel
5
+ include PlanningClient::ServiceConfiguration
6
+
7
+ set_resource_path '/v0/checklists'
8
+
9
+ attribute :id
10
+ attribute :name
11
+ attribute :description
12
+
13
+ has_many :items, class: 'PlanningClient::ChecklistItem'
14
+
15
+ ##
16
+ # Copies checklists items as to_dos
17
+ #
18
+ # @param options [Hash]
19
+ # @option options [String] responsible_username
20
+ # @option options [String] requester_username
21
+ #
22
+ # @example @checklist.assign(responsible_username: 'dwayne', requester_username: 'lucia')
23
+ #
24
+ # @return [Boolean]
25
+ def assign_to(options={})
26
+ resp = Typhoeus::Request.get("#{self.class.resource_uri(self.id)}/assign",
27
+ params: self.class.merge_key(options))
28
+ if resp.code == 200
29
+ log_ok(resp)
30
+ true
31
+ else
32
+ log_failed(resp)
33
+ false
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,21 @@
1
+ require 'planning_client/service_configuration'
2
+
3
+ module PlanningClient
4
+ class ChecklistItem < LogicalModel
5
+ include PlanningClient::ServiceConfiguration
6
+
7
+ set_resource_path '/v0/checklist_items'
8
+
9
+ attribute :id
10
+
11
+ belongs_to :checklist, class: 'PlanningClient::Checklist'
12
+
13
+ attribute :description
14
+ attribute :offset
15
+ attribute :offset_type
16
+
17
+ attribute :context_id
18
+ attribute :context_type
19
+
20
+ end
21
+ end
@@ -0,0 +1,68 @@
1
+ require 'planning_client/service_configuration'
2
+
3
+ module PlanningClient
4
+ class ToDo < LogicalModel
5
+ include PlanningClient::ServiceConfiguration
6
+
7
+ set_resource_path '/v0/to_dos'
8
+
9
+ attribute :id
10
+
11
+ attribute :state
12
+
13
+ attribute :context_id
14
+ attribute :contact_type
15
+
16
+ attribute :requester_username
17
+ attribute :responsible_username
18
+
19
+ attribute :description
20
+
21
+ attribute :due_at
22
+
23
+ attribute :account_name
24
+
25
+ # mark ToDo as in progress
26
+ def start
27
+ if self.status_transition("start")
28
+ self.state = 'in_progress'
29
+ self
30
+ else
31
+ nil
32
+ end
33
+ end
34
+
35
+ # mark ToDo as in stand by
36
+ def hold
37
+ if self.status_transition("hold")
38
+ self.state = 'stand_by'
39
+ self
40
+ else
41
+ nil
42
+ end
43
+ end
44
+
45
+ # mark ToDo as completed
46
+ def complete
47
+ if self.status_transition("complete")
48
+ self.state = 'completed'
49
+ self
50
+ else
51
+ nil
52
+ end
53
+ end
54
+
55
+ protected
56
+
57
+ def status_transition(transition)
58
+ response = Typhoeus::Request.get( "#{self.class.resource_uri(id)}/#{transition}", params: self.class.merge_key({}) )
59
+ if response.code == 200
60
+ log_ok(response)
61
+ return self
62
+ else
63
+ log_failed(response)
64
+ return nil
65
+ end
66
+ end
67
+ end
68
+ end
@@ -0,0 +1,4 @@
1
+ module PlanningClient
2
+ class Engine < Rails::Engine
3
+ end
4
+ end
@@ -0,0 +1,19 @@
1
+ module PlanningClient
2
+ module ServiceConfiguration
3
+ def self.included(base)
4
+ base.send('use_hydra', PlanningClient::HYDRA)
5
+
6
+ host = case ENV['RACK_ENV']
7
+ when 'development'
8
+ PlanningClient::HOST
9
+ when 'production'
10
+ 'padma-planning.heroku.com'
11
+ end
12
+
13
+ base.send('set_resource_host', host)
14
+ base.send('configure_index_response', {collection: 'collection', total: 'total'})
15
+
16
+ base.send('set_api_key','app_key',ENV['planning_api_key'])
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,5 @@
1
+ require 'logical_model'
2
+ if defined?(Rails)
3
+ require 'planning_client/railties'
4
+ require 'planning_client/service_configuration'
5
+ end
metadata ADDED
@@ -0,0 +1,78 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: planning_client
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Dwayne Macgowan
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-05-06 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: railties
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ! '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '3.1'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ! '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '3.1'
27
+ - !ruby/object:Gem::Dependency
28
+ name: logical_model
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: 0.5.12
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: 0.5.12
41
+ description: Padma Planning client with LogicalModel
42
+ email:
43
+ - dwaynemac@gmail.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - app/models/planning_client/checklist_item.rb
49
+ - app/models/planning_client/checklist.rb
50
+ - app/models/planning_client/to_do.rb
51
+ - lib/planning_client/railties.rb
52
+ - lib/planning_client/service_configuration.rb
53
+ - lib/planning_client.rb
54
+ homepage: ''
55
+ licenses: []
56
+ metadata: {}
57
+ post_install_message:
58
+ rdoc_options: []
59
+ require_paths:
60
+ - lib
61
+ required_ruby_version: !ruby/object:Gem::Requirement
62
+ requirements:
63
+ - - ! '>='
64
+ - !ruby/object:Gem::Version
65
+ version: '0'
66
+ required_rubygems_version: !ruby/object:Gem::Requirement
67
+ requirements:
68
+ - - ! '>='
69
+ - !ruby/object:Gem::Version
70
+ version: '0'
71
+ requirements: []
72
+ rubyforge_project:
73
+ rubygems_version: 2.1.11
74
+ signing_key:
75
+ specification_version: 4
76
+ summary: Client library for padma-planning-ws
77
+ test_files: []
78
+ has_rdoc: