youroom_api 0.0.10
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/History.txt +6 -0
- data/Manifest.txt +19 -0
- data/README.txt +106 -0
- data/Rakefile +12 -0
- data/lib/object_extention.rb +52 -0
- data/lib/youroom_api/base.rb +17 -0
- data/lib/youroom_api/base_url.rb +6 -0
- data/lib/youroom_api/request/add_participation.rb +24 -0
- data/lib/youroom_api/request/add_room.rb +20 -0
- data/lib/youroom_api/request/add_user.rb +28 -0
- data/lib/youroom_api/request/destroy_entry.rb +16 -0
- data/lib/youroom_api/request/destroy_participation.rb +24 -0
- data/lib/youroom_api/request/entry.rb +4 -0
- data/lib/youroom_api/request/get_entry.rb +21 -0
- data/lib/youroom_api/request/get_room_list.rb +15 -0
- data/lib/youroom_api/request/get_user_list.rb +15 -0
- data/lib/youroom_api/request/my_group.rb +7 -0
- data/lib/youroom_api/request/participation.rb +15 -0
- data/lib/youroom_api/request/post_entry.rb +23 -0
- data/lib/youroom_api/request/room_timeline.rb +23 -0
- data/lib/youroom_api/request/show_attachment.rb +15 -0
- data/lib/youroom_api/request/timeline.rb +8 -0
- data/lib/youroom_api/request/unread_timeline.rb +12 -0
- data/lib/youroom_api/request/verify_credentials.rb +7 -0
- data/lib/youroom_api/request.rb +85 -0
- data/lib/youroom_api/version.rb +3 -0
- data/lib/youroom_api/youroom.rb +32 -0
- data/lib/youroom_api.rb +44 -0
- data/spec/setup_test_model.rb +34 -0
- data/spec/spec.opts +2 -0
- data/spec/spec_helper.rb +130 -0
- data/spec/youroom_api/add_participation_spec.rb +89 -0
- data/spec/youroom_api/add_room_spec.rb +67 -0
- data/spec/youroom_api/add_user_spec.rb +75 -0
- data/spec/youroom_api/destroy_entry_spec.rb +68 -0
- data/spec/youroom_api/destroy_participation_spec.rb +89 -0
- data/spec/youroom_api/entry_spec.rb +5 -0
- data/spec/youroom_api/get_entry_spec.rb +82 -0
- data/spec/youroom_api/get_room_list_spec.rb +55 -0
- data/spec/youroom_api/get_user_list_spec.rb +55 -0
- data/spec/youroom_api/my_group_spec.rb +44 -0
- data/spec/youroom_api/object_extention_spec.rb +65 -0
- data/spec/youroom_api/participation_spec.rb +56 -0
- data/spec/youroom_api/post_entry_spec.rb +75 -0
- data/spec/youroom_api/request_spec.rb +145 -0
- data/spec/youroom_api/room_timeline_spec.rb +127 -0
- data/spec/youroom_api/show_attachment_spec.rb +30 -0
- data/spec/youroom_api/timeline_spec.rb +47 -0
- data/spec/youroom_api/unread_timeline_spec.rb +42 -0
- data/spec/youroom_api/verify_credentials_spec.rb +30 -0
- data/spec/youroom_api/youroom_spec.rb +92 -0
- metadata +125 -0
data/History.txt
ADDED
data/Manifest.txt
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
.autotest
|
2
|
+
History.txt
|
3
|
+
Manifest.txt
|
4
|
+
README.txt
|
5
|
+
Rakefile
|
6
|
+
lib/youroom_api.rb
|
7
|
+
lib//object_extention.rb
|
8
|
+
lib/youroom_api/youroom.rb
|
9
|
+
lib/youroom_api/base.rb
|
10
|
+
lib/youroom_api/request.rb
|
11
|
+
lib/youroom_api/room.rb
|
12
|
+
lib/youroom_api/user.rb
|
13
|
+
lib/youroom_api/entry.rb
|
14
|
+
lib/youroom_api/participation.rb
|
15
|
+
lib/youroom_api/create_participation.rb
|
16
|
+
lib/youroom_api/destroy_participation.rb
|
17
|
+
lib/youroom_api/youroom_oauth.rb
|
18
|
+
|
19
|
+
|
data/README.txt
ADDED
@@ -0,0 +1,106 @@
|
|
1
|
+
= youroom_api
|
2
|
+
|
3
|
+
* http://github.com/pochi/youroom_api
|
4
|
+
|
5
|
+
== DESCRIPTION:
|
6
|
+
|
7
|
+
simple api for youroom.
|
8
|
+
|
9
|
+
== FEATURES/PROBLEMS:
|
10
|
+
|
11
|
+
* youroom client (list of features or problems)
|
12
|
+
|
13
|
+
-----------------------------
|
14
|
+
how to use
|
15
|
+
-----------------------------
|
16
|
+
|
17
|
+
This api follow youroom api using oauth.(api doc:http://apidoc.youroom.in/)
|
18
|
+
Each api follow:
|
19
|
+
Enterprise:Group/create ----> create_room(billing_id, name)
|
20
|
+
Enterprise:Group/index ----> get_room_list(billing_id)
|
21
|
+
Enterprise:Participation/add ----> create_participation(billing_id, billing_group_id, email)
|
22
|
+
Enterprise:Participation/remove ----> create_participation(billing_id, billing_group_id, email)
|
23
|
+
Enterprise:User/create ----> create_user(billing_id, user_params)
|
24
|
+
Enterprise:User/index ----> get_user_list(billing_id)
|
25
|
+
REST:Entry/create ----> post_entry(room_id, content)
|
26
|
+
REST:Entry/destroy ----> destroy_entry(room_id, mutter_id)
|
27
|
+
REST:Entry/show ----> get_entry(room_id, mutter_id)
|
28
|
+
REST:Group/my ----> get_my_group
|
29
|
+
REST:Home Timeline(all) ----> get_all_timeline
|
30
|
+
REST:Home Timeline(unreads) ----> get_unread_timeline
|
31
|
+
REST:Room Timeline ----> get_entry(room_id)
|
32
|
+
|
33
|
+
-----------------------------
|
34
|
+
sample1: Get my timeline
|
35
|
+
-----------------------------
|
36
|
+
|
37
|
+
require 'rubygems'
|
38
|
+
require 'youroom_api'
|
39
|
+
|
40
|
+
YOUROOM_URL = "https://www.youroom.in/"
|
41
|
+
|
42
|
+
consumer = OAuth::Consumer.new(consumer_key,
|
43
|
+
consumer_sercret,
|
44
|
+
:site => YOUROOM_URL)
|
45
|
+
|
46
|
+
info = consumer.get_access_token(nil, { },
|
47
|
+
{:x_auth_mode=>"client_auth",
|
48
|
+
:x_auth_username=> "pochi.black@gmail.com",
|
49
|
+
:x_auth_password=> password})
|
50
|
+
|
51
|
+
access_token = OAuth::AccessToken.new(consumer,
|
52
|
+
info.params['oauth_token'],
|
53
|
+
info.params['oauth_token_secret'])
|
54
|
+
|
55
|
+
client = Youroom::Request.new(access_token)
|
56
|
+
client.get_all_timeline.each do |topic|
|
57
|
+
puts topic["entry"]["content"]
|
58
|
+
end
|
59
|
+
|
60
|
+
== SYNOPSIS:
|
61
|
+
|
62
|
+
FIX (code sample of usage)
|
63
|
+
|
64
|
+
== REQUIREMENTS:
|
65
|
+
|
66
|
+
* ruby 1.8.7 or later
|
67
|
+
* rspec 1.3.0 or later
|
68
|
+
* ww
|
69
|
+
|
70
|
+
== INSTALL:
|
71
|
+
|
72
|
+
* FIX (sudo gem install, anything else)
|
73
|
+
|
74
|
+
== DEVELOPERS:
|
75
|
+
|
76
|
+
After checking out the source, run:
|
77
|
+
|
78
|
+
$ rake newb
|
79
|
+
|
80
|
+
This task will install any missing dependencies, run the tests/specs,
|
81
|
+
and generate the RDoc.
|
82
|
+
|
83
|
+
== LICENSE:
|
84
|
+
|
85
|
+
(The MIT License)
|
86
|
+
|
87
|
+
Copyright (c) 2010 FIX
|
88
|
+
|
89
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
90
|
+
a copy of this software and associated documentation files (the
|
91
|
+
'Software'), to deal in the Software without restriction, including
|
92
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
93
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
94
|
+
permit persons to whom the Software is furnished to do so, subject to
|
95
|
+
the following conditions:
|
96
|
+
|
97
|
+
The above copyright notice and this permission notice shall be
|
98
|
+
included in all copies or substantial portions of the Software.
|
99
|
+
|
100
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
101
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
102
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
103
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
104
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
105
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
106
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
class Hash
|
2
|
+
# TODO: Refactoring
|
3
|
+
def optimize
|
4
|
+
routes = []
|
5
|
+
singleton_hash = {}
|
6
|
+
first_keys = self.keys
|
7
|
+
second_keys = []
|
8
|
+
third_keys = []
|
9
|
+
|
10
|
+
first_keys.each do |key|
|
11
|
+
unless self[key].is_a?(Hash)
|
12
|
+
routes << [key]
|
13
|
+
next
|
14
|
+
end
|
15
|
+
second_keys << [key, self[key].keys]
|
16
|
+
end
|
17
|
+
|
18
|
+
second_keys.each do |second_key|
|
19
|
+
second_key.last.each do |key|
|
20
|
+
unless self[second_key.first][key].is_a?(Hash)
|
21
|
+
routes << [second_key.first, key]
|
22
|
+
next
|
23
|
+
end
|
24
|
+
third_keys << [second_key.first, key, self[second_key.first][key].keys]
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
third_keys.each do |third_key|
|
29
|
+
third_key.last.each do |key|
|
30
|
+
unless self[third_key.first][third_key[1]][key].is_a?(Hash)
|
31
|
+
routes << [third_key.first, third_key[1], key]
|
32
|
+
next
|
33
|
+
end
|
34
|
+
force_keys << [third_key.first, third_key[1], key, self[third_key.first][third_key[1]][key].keys]
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
routes.each do |route|
|
39
|
+
val = self.dup
|
40
|
+
route.each do |key|
|
41
|
+
val = val[key]
|
42
|
+
end
|
43
|
+
base = route.shift.to_s
|
44
|
+
key_name = route.inject(base) {|key, map| key.to_s + "[" + map.to_s + "]" }
|
45
|
+
singleton_hash.update({key_name=>val.to_s})
|
46
|
+
end
|
47
|
+
|
48
|
+
singleton_hash
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Youroom
|
2
|
+
class Base
|
3
|
+
attr_reader :url, :host, :port
|
4
|
+
|
5
|
+
private
|
6
|
+
def required_structure(name, *elements)
|
7
|
+
raise ArgumentError unless elements.include?(name.class)
|
8
|
+
end
|
9
|
+
|
10
|
+
def parse(url)
|
11
|
+
@url = url
|
12
|
+
uri = URI.parse(url)
|
13
|
+
@host, @port = uri.host, uri.port
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Youroom
|
2
|
+
class AddParticipation < Request
|
3
|
+
attr_reader :billing_id, :billing_group_id, :email
|
4
|
+
|
5
|
+
def initialize(access_token, billing_id, billing_group_id, email, url=BASE_URL)
|
6
|
+
[billing_id, billing_group_id].each {|arg| required_structure(arg, String, Symbol, Fixnum)}
|
7
|
+
required_structure(email, String)
|
8
|
+
@billing_id, @billing_group_id, @email = billing_id.to_s, billing_group_id.to_s, email
|
9
|
+
super(access_token, url)
|
10
|
+
end
|
11
|
+
|
12
|
+
def path
|
13
|
+
if url == BASE_URL
|
14
|
+
File.join(::Youroom::BASE_URL, 'billings', billing_id, 'billing_groups', billing_group_id, 'participations', 'add?format=json')
|
15
|
+
else
|
16
|
+
File.join(url, 'enterprise', 'billings', billing_id, 'billing_groups', billing_group_id, 'participations', 'add?format=json')
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def params
|
21
|
+
{ :email => email }.optimize
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Youroom
|
2
|
+
class AddRoom < Request
|
3
|
+
attr_reader :name, :billing_id
|
4
|
+
|
5
|
+
def initialize(access_token, billing_id, name, url=BASE_URL)
|
6
|
+
required_structure(billing_id, String, Fixnum)
|
7
|
+
required_structure(name, String, Symbol)
|
8
|
+
@billing_id, @name = billing_id.to_s, name.to_s
|
9
|
+
super(access_token, url)
|
10
|
+
end
|
11
|
+
|
12
|
+
def path
|
13
|
+
File.join(url, 'billings', billing_id, 'billing_groups?format=json')
|
14
|
+
end
|
15
|
+
|
16
|
+
def params
|
17
|
+
{ :billing_group => { :group_attributes => { :name => name } } }.optimize
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module Youroom
|
2
|
+
class AddUser < Request
|
3
|
+
attr_reader :attributes, :billing_id
|
4
|
+
|
5
|
+
def initialize(access_token, billing_id, attributes, url=BASE_URL)
|
6
|
+
required_structure(billing_id, String, Fixnum)
|
7
|
+
required_structure(attributes, Hash)
|
8
|
+
@billing_id, @attributes = billing_id.to_s, attributes
|
9
|
+
super(access_token, url)
|
10
|
+
end
|
11
|
+
|
12
|
+
def path
|
13
|
+
File.join(url, 'billings', billing_id, 'billing_users?format=json')
|
14
|
+
end
|
15
|
+
|
16
|
+
def params
|
17
|
+
{ :billing_user => { :name => name,
|
18
|
+
:user_attributes => { :email => email,
|
19
|
+
:password => password,
|
20
|
+
:password_confirmation => password_confirmation }}}.optimize
|
21
|
+
end
|
22
|
+
|
23
|
+
# TODO: refactoring
|
24
|
+
def method_missing(name, *args)
|
25
|
+
attributes[name.to_sym]
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Youroom
|
2
|
+
class DestroyEntry < Entry
|
3
|
+
attr_reader :room_id, :mutter_id
|
4
|
+
|
5
|
+
def initialize(access_token, room_id, mutter_id, url=BASE_URL)
|
6
|
+
required_structure(room_id, String, Symbol, Fixnum)
|
7
|
+
required_structure(mutter_id, String, Fixnum)
|
8
|
+
@room_id, @mutter_id = room_id, mutter_id
|
9
|
+
super(access_token, url)
|
10
|
+
end
|
11
|
+
|
12
|
+
def path
|
13
|
+
File.join(url, 'r', room_id.to_s, 'entries', mutter_id.to_s+'?format=json')
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Youroom
|
2
|
+
class DestroyParticipation < Request
|
3
|
+
attr_reader :billing_id, :billing_group_id, :email
|
4
|
+
|
5
|
+
def initialize(access_token, billing_id, billing_group_id, email, url=BASE_URL)
|
6
|
+
[billing_id, billing_group_id].each {|arg| required_structure(arg, String, Symbol, Fixnum)}
|
7
|
+
required_structure(email, String)
|
8
|
+
@billing_id, @billing_group_id, @email = billing_id.to_s, billing_group_id.to_s, email
|
9
|
+
super(access_token, url)
|
10
|
+
end
|
11
|
+
|
12
|
+
def path
|
13
|
+
if url == BASE_URL
|
14
|
+
File.join(::Youroom::BASE_URL, 'billings', billing_id, 'billing_groups', billing_group_id, 'participations', 'remove?format=json')
|
15
|
+
else
|
16
|
+
File.join(url, 'enterprise', 'billings', billing_id, 'billing_groups', billing_group_id, 'participations', 'remove?format=json')
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def params
|
21
|
+
{ :email => email }.optimize
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Youroom
|
2
|
+
class GetEntry < Entry
|
3
|
+
attr_reader :room_id, :mutter_id
|
4
|
+
|
5
|
+
def initialize(access_token, room_id, mutter_id=nil, url=BASE_URL)
|
6
|
+
required_structure(room_id, String, Symbol, Fixnum)
|
7
|
+
required_structure(mutter_id, String, Symbol, Fixnum, NilClass)
|
8
|
+
@room_id, @mutter_id = room_id, mutter_id
|
9
|
+
super(access_token, url)
|
10
|
+
end
|
11
|
+
|
12
|
+
# Refactoring required
|
13
|
+
def path
|
14
|
+
if !mutter_id.nil?
|
15
|
+
File.join(url, 'r', room_id.to_s, 'entries', mutter_id.to_s+'.json')
|
16
|
+
else
|
17
|
+
File.join(url, 'r', room_id.to_s, 'all?format=json')
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Youroom
|
2
|
+
class GetRoomList < Request
|
3
|
+
attr_reader :billing_id
|
4
|
+
|
5
|
+
def initialize(access_token, billing_id, url=BASE_URL)
|
6
|
+
required_structure(billing_id, String, Fixnum)
|
7
|
+
@billing_id = billing_id.to_s
|
8
|
+
super(access_token, url)
|
9
|
+
end
|
10
|
+
|
11
|
+
def path
|
12
|
+
File.join(url, 'billings', billing_id, 'billing_groups?format=json')
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Youroom
|
2
|
+
class GetUserList < Request
|
3
|
+
attr_reader :billing_id
|
4
|
+
|
5
|
+
def initialize(access_token, billing_id, url=BASE_URL)
|
6
|
+
required_structure(billing_id, String, Fixnum)
|
7
|
+
@billing_id = billing_id.to_s
|
8
|
+
super(access_token, url)
|
9
|
+
end
|
10
|
+
|
11
|
+
def path
|
12
|
+
File.join(url, 'billings', billing_id, 'billing_users?format=json')
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Youroom
|
2
|
+
class Participation < Request
|
3
|
+
attr_reader :room_id, :participation_id
|
4
|
+
|
5
|
+
def initialize(access_token, room_id, participation_id, url=BASE_URL)
|
6
|
+
[room_id, participation_id].each {|arg| required_structure(arg, String, Fixnum) }
|
7
|
+
@room_id, @participation_id = room_id, participation_id
|
8
|
+
super(access_token, url)
|
9
|
+
end
|
10
|
+
|
11
|
+
def path
|
12
|
+
File.join(url, "group", room_id.to_s, "participations", participation_id.to_s+".json")
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Youroom
|
2
|
+
class PostEntry < Entry
|
3
|
+
attr_reader :room_id, :content, :parent_id
|
4
|
+
|
5
|
+
def initialize(access_token, room_id, content, parent_id=nil, url=BASE_URL)
|
6
|
+
[room_id, content].each { |arg| required_structure(arg, String, Symbol, Fixnum) }
|
7
|
+
@room_id, @content, @parent_id = room_id, content, parent_id
|
8
|
+
super(access_token, url)
|
9
|
+
end
|
10
|
+
|
11
|
+
def path
|
12
|
+
File.join(url, 'r', room_id.to_s, 'entries?format=json')
|
13
|
+
end
|
14
|
+
|
15
|
+
def params
|
16
|
+
if parent_id
|
17
|
+
{ :entry => { :content => content.to_s, :parent_id => parent_id }, :insert_mention => "" }
|
18
|
+
else
|
19
|
+
{ :entry => { :content => content.to_s }, :insert_mention => "" }
|
20
|
+
end.optimize
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Youroom
|
2
|
+
class RoomTimeline < Request
|
3
|
+
attr_reader :room_id, :since, :page, :flat, :search_query, :read_state
|
4
|
+
QUERY_KEYS = %w[since page flat search_query read_state]
|
5
|
+
|
6
|
+
def initialize(access_token, room_id, params={}, url=BASE_URL)
|
7
|
+
required_structure(room_id, String, Symbol, Fixnum)
|
8
|
+
required_structure(params, Hash)
|
9
|
+
@room_id = room_id
|
10
|
+
params.each { |k,v| self.instance_variable_set("@#{k}", v)}
|
11
|
+
super(access_token, url)
|
12
|
+
end
|
13
|
+
|
14
|
+
def path
|
15
|
+
query_str = "&"
|
16
|
+
QUERY_KEYS.each do |query_key|
|
17
|
+
val = self.instance_variable_get("@#{query_key}")
|
18
|
+
query_str += "#{query_key}=#{val}&" if !val.nil?
|
19
|
+
end
|
20
|
+
File.join(url, 'r', room_id.to_s, '?format=json'+"#{query_str.chop}")
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Youroom
|
2
|
+
class ShowAttachment < Request
|
3
|
+
attr_reader :room_id, :entry_id
|
4
|
+
def initialize(access_token, room_id, entry_id, url=BASE_URL)
|
5
|
+
[room_id, entry_id].each { |e| required_structure(e, String, Symbol, Fixnum) }
|
6
|
+
@room_id = room_id
|
7
|
+
@entry_id = entry_id
|
8
|
+
super(access_token, url)
|
9
|
+
end
|
10
|
+
|
11
|
+
def path
|
12
|
+
File.join(url, 'r', room_id.to_s, 'entries', entry_id.to_s, 'attachment', '?format=json')
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module Youroom
|
2
|
+
class UnreadTimeline < Request
|
3
|
+
# TODO: Request parameter feel bad
|
4
|
+
def path
|
5
|
+
if url == BASE_URL
|
6
|
+
File.join(url, '?format=json&read_state=unread')
|
7
|
+
else
|
8
|
+
File.join(url, 'home', '?format=json&read_state=unread')
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,85 @@
|
|
1
|
+
module Youroom
|
2
|
+
class Request < Base
|
3
|
+
attr_reader :access_token
|
4
|
+
|
5
|
+
def initialize(access_token, url=BASE_URL)
|
6
|
+
required_structure(access_token, ::OAuth::AccessToken)
|
7
|
+
@access_token = access_token
|
8
|
+
parse(url)
|
9
|
+
end
|
10
|
+
|
11
|
+
def get_entry(room_id, mutter_id=nil)
|
12
|
+
GetEntry.new(access_token, room_id, mutter_id, url).get
|
13
|
+
end
|
14
|
+
|
15
|
+
def get_verify_credentials
|
16
|
+
VerifyCredentials.new(access_token, url).get
|
17
|
+
end
|
18
|
+
|
19
|
+
def get_attachment(room_id, mutter_id)
|
20
|
+
ShowAttachment.new(access_token, room_id, mutter_id, url).get
|
21
|
+
end
|
22
|
+
|
23
|
+
def get_all_timeline
|
24
|
+
HomeTimeline.new(access_token, url).get
|
25
|
+
end
|
26
|
+
|
27
|
+
def get_unread_timeline
|
28
|
+
UnreadTimeline.new(access_token, url).get
|
29
|
+
end
|
30
|
+
|
31
|
+
def get_room_timeline(room_id, params={ })
|
32
|
+
RoomTimeline.new(access_token, room_id, params, url).get
|
33
|
+
end
|
34
|
+
|
35
|
+
def create_entry(room_id, content, parent_id=nil)
|
36
|
+
PostEntry.new(access_token, room_id, content, parent_id, url).post
|
37
|
+
end
|
38
|
+
|
39
|
+
def destroy_entry(room_id, mutter_id)
|
40
|
+
DestroyEntry.new(access_token, room_id, mutter_id, url).delete
|
41
|
+
end
|
42
|
+
|
43
|
+
def get_my_group
|
44
|
+
MyGroup.new(access_token, url).get
|
45
|
+
end
|
46
|
+
|
47
|
+
def get
|
48
|
+
JSON.parse(access_token.get(path).body)
|
49
|
+
end
|
50
|
+
|
51
|
+
def post
|
52
|
+
JSON.parse(access_token.post(path, params).body)
|
53
|
+
end
|
54
|
+
|
55
|
+
def delete
|
56
|
+
JSON.parse(access_token.delete(path).body)
|
57
|
+
end
|
58
|
+
|
59
|
+
# enterprise api
|
60
|
+
def create_room(billing_id, name)
|
61
|
+
AddRoom.new(access_token, billing_id, name, url).post
|
62
|
+
end
|
63
|
+
|
64
|
+
def create_participation(billing_id, billin_group_id, email)
|
65
|
+
AddParticipation.new(access_token, billing_id, billin_group_id, email, url).post
|
66
|
+
end
|
67
|
+
|
68
|
+
def destroy_participation(billing_id, billing_group_id, email)
|
69
|
+
DestroyParticipation.new(access_token, billing_id, billing_group_id, email, url).delete
|
70
|
+
end
|
71
|
+
|
72
|
+
def get_room_list(billing_id)
|
73
|
+
GetRoomList.new(access_token, billing_id, url).get
|
74
|
+
end
|
75
|
+
|
76
|
+
def create_user(billing_id, user)
|
77
|
+
AddUser.new(access_token, billing_id, user, url).post
|
78
|
+
end
|
79
|
+
|
80
|
+
def get_user_list(billing_id)
|
81
|
+
GetUserList.new(access_token, billing_id, url).get
|
82
|
+
end
|
83
|
+
|
84
|
+
end
|
85
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module Youroom
|
2
|
+
|
3
|
+
class OAuth < Base
|
4
|
+
attr_accessor :request
|
5
|
+
|
6
|
+
def initialize(access_token, url=BASE_URL)
|
7
|
+
@request = Request.new(access_token, url)
|
8
|
+
end
|
9
|
+
|
10
|
+
def entry(room_id, mutter_id=nil)
|
11
|
+
request.get_entry(room_id, mutter_id)
|
12
|
+
end
|
13
|
+
|
14
|
+
def participation(room_id, participation_id)
|
15
|
+
request.get_participation(room_id, participation_id)
|
16
|
+
end
|
17
|
+
|
18
|
+
def all_timeline
|
19
|
+
request.get_all_timeline
|
20
|
+
end
|
21
|
+
|
22
|
+
def unread_timeline
|
23
|
+
request.get_unread_timeline
|
24
|
+
end
|
25
|
+
|
26
|
+
def update(room_id, content)
|
27
|
+
request.post_entry(room_id, content)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
|