flock_os 0.0.3 → 0.0.4

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b4344db63440885fbd91ac908f218ccf10d380a8fb4027e73f13b4fe4676da6c
4
- data.tar.gz: c7ab15fb63bd81c90bb96ce23c03a86b5941f0b595034ec4005206b7d6a8627f
3
+ metadata.gz: c2744e0d6da7cf08099fe98a00fcb03667bff47ba224f5a31a937bc3a52e3838
4
+ data.tar.gz: 34d4c7690b38cadd8c69de2ec39d5a1751216017c33597364d6f010775e467a7
5
5
  SHA512:
6
- metadata.gz: d54e36365b3c0151fe0fdb432f5ad257d3acb7bc6eb88d48a008796d9e73f13e9954f857251f416378ba7725e843c744479f387251ac59d2d7df2f7a6e59c870
7
- data.tar.gz: 031cd9a483e246cea0f005309b078cb908084475413b329c7953413e8c2e98d2f27548eee27e70f1d22c0dd9885177732fe4134165758b74ca4a35a84b6f49c5
6
+ metadata.gz: eafc8df537f37515b1ed94fc017558fe98a07e4a732d3500c86bda8cb81885615b0c07bf7a98a4fcaa952e6ef55bc82e82b0de0f1aabe0cf2a5996e4dc0aeb93
7
+ data.tar.gz: 606987185ba26f60429924fcbc8ce13ac0bee6454a081e2c75b73ab74e1810fc8ff8fa6a46643b87b9b3e5fc2e57370994a899119b07e3d19b61f63c487d58bf
@@ -35,10 +35,8 @@ module FlockOs
35
35
  FlockOs::Collection::Channel.new(response)
36
36
  end
37
37
 
38
- def list_members(channel_id)
39
- response = @client.post("#{PATH}.listMembers", {
40
- channelId: channel_id
41
- })
38
+ def list_members(params)
39
+ response = @client.post("#{PATH}.listMembers", params)
42
40
 
43
41
  FlockOs::Collection::ChannelMember.new(response)
44
42
  end
@@ -1,3 +1,3 @@
1
1
  module FlockOs
2
- VERSION = '0.0.3'
2
+ VERSION = '0.0.4'
3
3
  end
@@ -2,73 +2,32 @@ require 'spec_helper'
2
2
 
3
3
  describe FlockOs::Api::Channels do
4
4
  let(:client) { FlockOs::Client.new }
5
- let(:stub_fetch_response) do
6
- [
7
- {
8
- "from": "u:xxx",
9
- "to": "u:xxx",
10
- "uid": "fd4877b719b1",
11
- "text": "Hello"
12
- }
13
- ]
14
- end
15
-
16
- let(:send_message_params) do
5
+ let(:stub_add_members_response) do
17
6
  {
18
- "to": "u:xxx",
19
- "text": "Hello"
7
+ members: {
8
+ "u:id1": { status: "added" },
9
+ "u:id2": { status: "failed", error: "UserNotFound" }
10
+ }
20
11
  }
21
12
  end
22
-
23
- let(:stub_send_response) { { uid: 'uuid' } }
24
13
 
25
14
  subject(:chat) { described_class.new(client) }
15
+ subject(:add_member) { chat.add_members('channel_id', ['member']) }
26
16
 
27
17
  describe '#add_members' do
18
+ before do
19
+ allow_any_instance_of(FlockOs::Client).to receive(:post).and_return(stub_add_members_response)
20
+ end
21
+
28
22
  context 'when successfully fetch messages' do
29
23
  it 'return message collection class' do
30
- expect(chat.add_members('channel_id', ['member'])).to be_an FlockOs::Collection::Message
24
+ expect(add_member).to be_an FlockOs::Model::ModifyChannelMember
31
25
  end
32
26
 
33
- it 'return message collection class' do
34
- allow_any_instance_of(FlockOs::Client).to receive(:post).and_return(stub_fetch_response)
35
-
36
- response = chat.fetch_messages('chat', 'user_uids')
37
- messages = response.collection
38
- message = messages.first
39
-
40
- expect(messages.count).to eq 1
41
-
42
- expect(message.text).to eq stub_fetch_response.first[:text]
43
- expect(message.from).to eq stub_fetch_response.first[:from]
44
- expect(message.to).to eq stub_fetch_response.first[:to]
45
- expect(message.uid).to eq stub_fetch_response.first[:uid]
46
- end
47
- end
48
- end
49
-
50
- describe '#send_message' do
51
- context 'when successfully send message' do
52
- it 'return message model class' do
53
- expect(chat.send_message(send_message_params)).to be_an FlockOs::Model::SendMessage
54
- end
55
-
56
- it 'return uuid' do
57
- allow_any_instance_of(FlockOs::Client).to receive(:post).and_return(stub_send_response)
58
-
59
- response = chat.send_message(send_message_params)
60
-
61
- expect(response.uid).to eq stub_send_response[:uid]
62
- end
63
- end
64
-
65
- pending 'when send message failed' do
66
- it 'uuid nil' do
67
- allow_any_instance_of(FlockOs::Client).to receive(:post).and_return({})
27
+ it 'return correct attribute values' do
28
+ response = add_member
68
29
 
69
- response = chat.send_message(send_message_params)
70
-
71
- expect(response.uid).to eq nil
30
+ expect(response.members).to eq stub_add_members_response[:members]
72
31
  end
73
32
  end
74
33
  end
@@ -5,13 +5,7 @@ describe FlockOs::Collection::ChannelMember do
5
5
  (1..3).map do |n|
6
6
  {
7
7
  userId: "u:#{n}",
8
- affiliation: "member",
9
- publicProfile: {
10
- id: "u:#{n}",
11
- firstName: "Nicole #{n}",
12
- lastName: "Sullivan",
13
- profileImage: "https://i.flockusercontent.com/xxxxxx"
14
- }
8
+ affiliation: "member"
15
9
  }
16
10
  end
17
11
  end
@@ -19,20 +13,56 @@ describe FlockOs::Collection::ChannelMember do
19
13
  subject(:collection) { described_class.new(channel_members) }
20
14
 
21
15
  describe '#initialize' do
22
- it 'return described class' do
23
- expect(collection).to be_an described_class
24
- end
25
-
26
- it 'collection is not empty' do
27
- expect(collection.collection).to be_an Array
16
+ context 'without show public profile' do
17
+ it 'return described class' do
18
+ expect(collection).to be_an described_class
19
+ end
20
+
21
+ it 'collection is not empty' do
22
+ expect(collection.collection).to be_an Array
23
+ end
24
+
25
+ it 'first collection has correct attributes' do
26
+ first_collection = collection.collection.first
27
+
28
+ expect(first_collection.user_id).to eq 'u:1'
29
+ expect(first_collection.affiliation).to eq 'member'
30
+ expect(first_collection.public_profile).to eq nil
31
+ end
28
32
  end
29
-
30
- it 'first collection has correct attributes' do
31
- first_collection = collection.collection.first
32
33
 
33
- expect(first_collection.user_id).to eq 'u:1'
34
- expect(first_collection.affiliation).to eq 'member'
35
- expect(first_collection.public_profile).to be_an Hash
34
+ context 'with show public profile' do
35
+ let(:channel_members) do
36
+ (1..3).map do |n|
37
+ {
38
+ userId: "u:#{n}",
39
+ affiliation: "member",
40
+ publicProfile: {
41
+ id: "u:#{n}",
42
+ firstName: "Nicole #{n}",
43
+ lastName: "Sullivan",
44
+ profileImage: "https://i.flockusercontent.com/xxxxxx"
45
+ }
46
+ }
47
+ end
48
+ end
49
+
50
+ it 'return described class' do
51
+ expect(collection).to be_an described_class
52
+ end
53
+
54
+ it 'collection is not empty' do
55
+ expect(collection.collection).to be_an Array
56
+ end
57
+
58
+ it 'first collection has correct attributes' do
59
+ first_collection = collection.collection.first
60
+
61
+ expect(first_collection.user_id).to eq 'u:1'
62
+ expect(first_collection.affiliation).to eq 'member'
63
+ expect(first_collection.public_profile).to be_an Hash
64
+ expect(first_collection.public_profile[:firstName]).to eq 'Nicole 1'
65
+ end
36
66
  end
37
67
  end
38
68
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: flock_os
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Risal Hidayat