youroom_api 0.0.11 → 0.0.12

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,15 @@
1
+ module Youroom
2
+ class Picture < 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, Integer) }
7
+ @room_id, @participation_id = room_id, participation_id
8
+ super(access_token, url)
9
+ end
10
+
11
+ def path
12
+ File.join(url, "r", room_id, "participations", participation_id, "picture.image")
13
+ end
14
+ end
15
+ end
@@ -81,5 +81,25 @@ module Youroom
81
81
  GetUserList.new(access_token, billing_id, url).get
82
82
  end
83
83
 
84
+ def get_picture(room_id, participation_id)
85
+ Picture.new(access_token, room_id, participation_id).get(false)
86
+ end
87
+
88
+ def get(parse=true)
89
+ parse ? JSON.parse(access_token.get(path).body) : access_token.get(path)
90
+ rescue => e
91
+ puts "[Error forward to] " + path
92
+ puts "[Error access_token is]"
93
+ puts access_token.inspect
94
+ puts e.inspect
95
+ end
96
+
97
+ def post
98
+ JSON.parse(access_token.post(path, params).body)
99
+ end
100
+
101
+ def delete
102
+ JSON.parse(access_token.delete(path).body)
103
+ end
84
104
  end
85
105
  end
data/lib/youroom_api.rb CHANGED
@@ -40,5 +40,8 @@ module Youroom
40
40
  autoload :Participation, 'youroom_api/request/participation'
41
41
  autoload :AddParticipation, 'youroom_api/request/add_participation' # enterprise only
42
42
  autoload :DestroyParticipation, 'youroom_api/request/destroy_participation' # enterprise only
43
+
44
+ # for picture
45
+ autoload :Picture, 'youroom_api/request/get_picture'
43
46
  end
44
47
 
data/spec/spec_helper.rb CHANGED
@@ -121,6 +121,10 @@ RSpec.configure do |config|
121
121
  @get_user_list_request ||= mock(Youroom::GetUserList)
122
122
  end
123
123
 
124
+ def picture
125
+ @picture ||= mock(Youroom::Picture)
126
+ end
127
+
124
128
  def user_params
125
129
  { :name => 'new user',
126
130
  :email => 'pochi.black@gmail.com',
@@ -0,0 +1,38 @@
1
+ require File.expand_path("../spec_helper", File.dirname(__FILE__))
2
+
3
+ describe Youroom::Picture do
4
+ describe "#initialize" do
5
+ context "when can not create instanse" do
6
+ before do
7
+ @error_data1 = ["hoge", nil]
8
+ @error_data2 = [nil, "hoge"]
9
+ end
10
+
11
+ it do
12
+ lambda { Youroom::Picture.new(*@error_data1) }.should raise_exception(ArgumentError)
13
+ end
14
+
15
+ it do
16
+ lambda { Youroom::Picture.new(*@error_data2) }.should raise_exception(ArgumentError)
17
+ end
18
+
19
+ end
20
+
21
+ context "when can create user instance" do
22
+ subject { Youroom::Picture.new(access_token, "room_id", "participation_id") }
23
+ it { should be_a(Youroom::Picture) }
24
+ its(:url) { should == Youroom::BASE_URL }
25
+ its(:room_id) { should == "room_id" }
26
+ its(:participation_id) { should == "participation_id" }
27
+ end
28
+ end
29
+
30
+ describe "#path" do
31
+ before do
32
+ @picture = Youroom::Picture.new(access_token, "room_id", "participation_id", WW_URL)
33
+ end
34
+
35
+ subject { @picture.path }
36
+ it { should == File.join(WW_URL, 'r', 'room_id', 'participations', 'participation_id', 'picture.image') }
37
+ end
38
+ end
@@ -46,7 +46,7 @@ describe Youroom::Request do
46
46
  end
47
47
  end
48
48
 
49
- describe "#destroy_entry(room_id, mutter_id" do
49
+ describe "#destroy_entry(room_id, mutter_id)" do
50
50
  it "should get DestroyEntry.new" do
51
51
  Youroom::DestroyEntry.should_receive(:new).and_return(destroy_entry)
52
52
  destroy_entry.should_receive(:delete)
@@ -141,5 +141,13 @@ describe Youroom::Request do
141
141
  Youroom::Request.new(access_token).get_user_list("3")
142
142
  end
143
143
  end
144
+
145
+ describe "#get_picture(room_id, participation_id)" do
146
+ it "should get Picture.new" do
147
+ Youroom::Picture.should_receive(:new).and_return(picture)
148
+ picture.should_receive(:get)
149
+ Youroom::Request.new(access_token).get_picture("room_id", "participation_id")
150
+ end
151
+ end
144
152
  end
145
153
 
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 11
9
- version: 0.0.11
8
+ - 12
9
+ version: 0.0.12
10
10
  platform: ruby
11
11
  authors:
12
12
  - pochi
@@ -78,6 +78,8 @@ files:
78
78
  - spec/youroom_api/add_participation_spec.rb
79
79
  - lib/youroom_api/request/destroy_participation.rb
80
80
  - spec/youroom_api/destroy_participation_spec.rb
81
+ - lib/youroom_api/request/get_picture.rb
82
+ - spec/youroom_api/picture_spec.rb
81
83
  has_rdoc: true
82
84
  homepage: https://home.youroom.in/
83
85
  licenses: []