chatwork 0.0.7 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 25204d174d123a033c044404f9c910d6241e5ff1
4
- data.tar.gz: 69e0eae2716d3daf0e106aab1fa503adc963b209
3
+ metadata.gz: 6695bd548cc4e8fa03c3ebd1ca71aa59cada6f24
4
+ data.tar.gz: 0754d76d9bb12746246b36512904fa461e384412
5
5
  SHA512:
6
- metadata.gz: d5b2e1d16fb62d7d060d30e829cf870e820912cf18ecb82c6d517270967238541ca3b2583d693352dcdb2f73f0710095ac3cd0cc5f4985a05fd9ca4508216b49
7
- data.tar.gz: d99e7c85eafec243c9125d394b8f9fc9160565154a8dcf8a9f2b469fcf07dad048a7eeed8751b4adae488c24665eb7fee8a5fac1c553ddd3d45c49439afe5844
6
+ metadata.gz: 4835a4b56f6acf2bec2021ff1547036e6da14673c222c2a3c18f80ed2c8c4bb126358d4d1cf508e1f6571c1f1f03065d45c8c3f701ce76a5e32fca6f82a757d7
7
+ data.tar.gz: e630f861861cbfba42b70ba078eae787176fc1d17ee18429bf70e8517b55065e7fec566c8074441bc83f5d35b2cc8b51827e4c947a8560b0c433dabf19c2fc4d
data/lib/chatwork.rb CHANGED
@@ -10,6 +10,7 @@ module ChatWork
10
10
  autoload(:Entity, 'chatwork/entity')
11
11
  autoload(:Message, 'chatwork/message')
12
12
  autoload(:Me, 'chatwork/me')
13
+ autoload(:MyTask, 'chatwork/my_task')
13
14
  autoload(:Task, 'chatwork/task')
14
15
 
15
16
  @api_base = 'https://api.chatwork.com/'
@@ -0,0 +1,13 @@
1
+ module ChatWork
2
+ class MyTask < Entity
3
+ install_class_operations :get
4
+
5
+ def self.path
6
+ "/my/tasks"
7
+ end
8
+
9
+ def path
10
+ "/my/tasks"
11
+ end
12
+ end
13
+ end
@@ -1,5 +1,9 @@
1
1
  module ChatWork
2
2
  module Operations
3
+ ACCEPT_PARAMS_ID = %i(file_id task_id message_id)
4
+
5
+ attr_accessor :assign_path
6
+
3
7
  def install_class_operations(*operations)
4
8
  define_create if operations.include?(:create)
5
9
  define_get if operations.include?(:get)
@@ -8,8 +12,9 @@ module ChatWork
8
12
  def define_get
9
13
  instance_eval do
10
14
  def get(params = {})
11
- assign_path = parse_if_hash_key_exists(path, params, :room_id)
12
- convert(ChatWork.client.get(assign_path, params))
15
+ @assign_path = parse_if_hash_key_exists(path, params, :room_id)
16
+ attach_nested_resource_id(params)
17
+ convert(ChatWork.client.get(@assign_path, params))
13
18
  end
14
19
  end
15
20
  end
@@ -17,10 +22,9 @@ module ChatWork
17
22
  def define_create
18
23
  instance_eval do
19
24
  def create(params = {})
20
- # TODO: Consider other pattern
21
- # /rooms and /rooms/:room_id
22
- assign_path = parse_if_hash_key_exists(path, params, :room_id)
23
- convert(ChatWork.client.post(assign_path, params))
25
+ @assign_path = parse_if_hash_key_exists(path, params, :room_id)
26
+ attach_nested_resource_id(params)
27
+ convert(ChatWork.client.post(@assign_path, params))
24
28
  end
25
29
  end
26
30
  end
@@ -33,5 +37,12 @@ module ChatWork
33
37
  string
34
38
  end
35
39
  end
40
+
41
+ def attach_nested_resource_id(params)
42
+ ACCEPT_PARAMS_ID.each do |id_name|
43
+ next unless params.include? id_name
44
+ @assign_path += "/#{params.delete(id_name)}"
45
+ end
46
+ end
36
47
  end
37
48
  end
data/lib/chatwork/task.rb CHANGED
@@ -1,13 +1,9 @@
1
1
  module ChatWork
2
2
  class Task < Entity
3
- install_class_operations :get
3
+ install_class_operations :get, :create
4
4
 
5
5
  def self.path
6
- "/my/tasks"
7
- end
8
-
9
- def path
10
- "/my/tasks"
6
+ "/rooms/%d/tasks"
11
7
  end
12
8
  end
13
9
  end
@@ -1,3 +1,3 @@
1
1
  module ChatWork
2
- VERSION = "0.0.7"
2
+ VERSION = "0.1.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chatwork
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - asonas
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-20 00:00:00.000000000 Z
11
+ date: 2015-01-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -85,6 +85,7 @@ files:
85
85
  - lib/chatwork/entity.rb
86
86
  - lib/chatwork/me.rb
87
87
  - lib/chatwork/message.rb
88
+ - lib/chatwork/my_task.rb
88
89
  - lib/chatwork/operations.rb
89
90
  - lib/chatwork/room.rb
90
91
  - lib/chatwork/task.rb