quickblox-rb 0.1.3 → 0.1.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
  SHA1:
3
- metadata.gz: 4f4740bda5465f46b1f3c9dd2321aaaa2b5e5428
4
- data.tar.gz: b882aa81e405f1d845232e04b3309cb0fe515386
3
+ metadata.gz: 5820abca6b74c61f331706b606c961d602e1bbfa
4
+ data.tar.gz: a2379eb5f453b95372ae43b635aa8bb76c8adda4
5
5
  SHA512:
6
- metadata.gz: e070f238a42d8ef3e2a97821394b6f66922c84d2576750365d18ccdc7b61ab1b20a0e450ba0324c6983717dd00cb6627ce635f02584c1ceda6d9c3ca4093d668
7
- data.tar.gz: d94f4698d3964e202c6bf76e470602500d43dcad0ca6ac9061b8608d2dc7e09c10ee6f14e329323dcbd58a3921b3b7a18ec189b1292f3a5285c0706fbd47c42f
6
+ metadata.gz: 09705b851c4f7bbe59d7b2194f8d9da80421ab63ede95d2ce0755470acd4950e51e61bd2fa812d3cc3b72ed908e5ee0b1417d65e82c913c9dfdc020bca24b970
7
+ data.tar.gz: f90dac84d7be4ae9f0d69ef6b30d0ff1ec718009d3d1749a500c527c769d6760d6154ded0382a42d8a719bf7b34e7682a1aeb88f7ca5f057b870b18e4c88c5b3
data/Makefile CHANGED
@@ -1,4 +1,10 @@
1
- build:
1
+ test:
2
2
  RUBYLIB=./lib cutest test/**/*_test.rb
3
3
 
4
- .PHONY: build
4
+ build: quickblox-rb.gemspec
5
+ gem build $?
6
+
7
+ clean:
8
+ rm *.gem
9
+
10
+ .PHONY: test
data/lib/api.rb CHANGED
@@ -60,7 +60,7 @@ class Quickblox::API
60
60
  headers: {
61
61
  QB_HEADER_API_VERSION => "0.1.1",
62
62
  QB_HEADER_TOKEN => session_token
63
- },
63
+ }
64
64
  )
65
65
 
66
66
  @last_response = response
@@ -119,6 +119,29 @@ class Quickblox::API
119
119
  end
120
120
  end
121
121
 
122
+ def get_dialogs
123
+ response = Requests.get(
124
+ QB_ENDPOINT + "/chat/Dialog.json",
125
+ headers: {
126
+ QB_HEADER_API_VERSION => "0.1.1",
127
+ QB_HEADER_TOKEN => session_token
128
+ },
129
+ params: {
130
+ type: 3
131
+ }
132
+ )
133
+
134
+ @last_response = response
135
+
136
+ if response.status == 200
137
+ dialogs = response.json.fetch("items")
138
+
139
+ if dialogs && !dialogs.empty?
140
+ Quickblox::Models::Dialog.batch_build(dialogs)
141
+ end
142
+ end
143
+ end
144
+
122
145
  def chat_transcript(dialog_id:)
123
146
  messages = get_messages(dialog_id: dialog_id)
124
147
  occupant_ids = messages.map(&:sender_id).uniq
data/lib/models.rb CHANGED
@@ -74,6 +74,10 @@ module Quickblox::Models
74
74
  attribute :created_at, cast: Types::DateTime
75
75
  attribute :updated_at, cast: Types::DateTime
76
76
 
77
+ def self.batch_build(dialogs)
78
+ dialogs.map { |dialog| build(dialog) }
79
+ end
80
+
77
81
  def self.build(hash)
78
82
  new(
79
83
  id: hash.fetch("_id"),
@@ -88,6 +92,7 @@ module Quickblox::Models
88
92
  class Message
89
93
  include Silueta
90
94
 
95
+ attribute :id
91
96
  attribute :created_at, cast: Types::DateTime
92
97
  attribute :text
93
98
  attribute :dialog_id
@@ -100,6 +105,7 @@ module Quickblox::Models
100
105
 
101
106
  def self.build(message)
102
107
  new(
108
+ id: message.fetch("_id"),
103
109
  created_at: message.fetch("created_at"),
104
110
  text: message.fetch("message"),
105
111
  dialog_id: message.fetch("chat_dialog_id"),
data/quickblox-rb.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "quickblox-rb"
3
- s.version = "0.1.3"
3
+ s.version = "0.1.4"
4
4
  s.summary = "Ruby gem to work with Quickblox API"
5
5
  s.description = s.summary
6
6
  s.authors = ["Lucas Tolchinsky"]
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: quickblox-rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lucas Tolchinsky
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-05-05 00:00:00.000000000 Z
11
+ date: 2016-05-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: requests