quickblox-rb 0.1.2 → 0.1.3

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: 8e377ebc8c37c660d792ca2c9cdf4f79cffbe660
4
- data.tar.gz: 3015e3ca62ca96333a72bdfa672f5eb3fd37e160
3
+ metadata.gz: 4f4740bda5465f46b1f3c9dd2321aaaa2b5e5428
4
+ data.tar.gz: b882aa81e405f1d845232e04b3309cb0fe515386
5
5
  SHA512:
6
- metadata.gz: 0cfaae607b05a0e0eaa23f2192d702b1e8780fe31545e92a3d888caabed7a9eaffbae191dd6a0746779a317abad3a05900df0f9d926ad1c7d7621341fe5c9d08
7
- data.tar.gz: 06c41ebc410955294692754dd549715075803fd41697d2ef30b38d41a7f909ba3bec5023ba6e7c7a933912d8dca21b1b7329650f5ba761a7d8c2257303db230c
6
+ metadata.gz: e070f238a42d8ef3e2a97821394b6f66922c84d2576750365d18ccdc7b61ab1b20a0e450ba0324c6983717dd00cb6627ce635f02584c1ceda6d9c3ca4093d668
7
+ data.tar.gz: d94f4698d3964e202c6bf76e470602500d43dcad0ca6ac9061b8608d2dc7e09c10ee6f14e329323dcbd58a3921b3b7a18ec189b1292f3a5285c0706fbd47c42f
data/README.md CHANGED
@@ -2,6 +2,69 @@
2
2
 
3
3
  This is a gem to work with [Quickblox API](http://quickblox.com/developers/Overview) in Ruby.
4
4
 
5
+ ## Use
6
+
7
+ It all starts by creating a `Quickblox::API` instance with your credentials.
8
+
9
+ ```ruby
10
+ require "quickblox"
11
+
12
+ qb_api = Quickblox::API.new(
13
+ auth_key: "AUTH_KEY",
14
+ auth_secret: "AUTH_SECRET",
15
+ application_id: 1234,
16
+ email: "account@owner.com",
17
+ password: "foobarbaz"
18
+ )
19
+ ```
20
+
21
+ This will create a user-level token associated to the account with `email` and `password`.
22
+
23
+ If you don't provide `email` nor `password`, it'll create an application level token.
24
+
25
+ You don't need to worry about the token itself when using `quickblox-rb`, but it's important to keep in mind that the actions you can make with the API are associated with the token's access right. More about this [here](http://quickblox.com/developers/Authentication_and_Authorization#Access_Rights).
26
+
27
+ Now you can query the API.
28
+
29
+ ```ruby
30
+ qb_api.create_session
31
+ # All the methods below use `create_session` if they have to. No need to call it explicitly.
32
+
33
+ qb_api.get_user(id: 1234)
34
+
35
+ qb_api.get_dialog(id: "dialog-id")
36
+
37
+ qb_api.get_messages(dialog_id: "dialog-id")
38
+
39
+ qb_api.chat_transcript(dialog_id: "dialog-id")
40
+ ```
41
+
42
+ These methods return instances of `Quickblox::Models`. I encourage you to [read the source](https://github.com/properati/quickblox-rb/blob/master/lib/models.rb) [and tests](https://github.com/properati/quickblox-rb/blob/master/test/quickblox_api_test.rb) to find more about them.
43
+
44
+ ### Other nice things
45
+
46
+ Use `Quickblox::API#last_response` to inspect the HTTP response of your latest request. Useful for debugging!
47
+
48
+ ```ruby
49
+ qb_api.get_user(id: 123)
50
+
51
+ qb_api.last_response
52
+ ```
53
+
54
+ Inspect your current session:
55
+
56
+ ```ruby
57
+ qb_api.create_session
58
+
59
+ qb_api.session
60
+ ```
61
+
62
+ ## Install
63
+
64
+ ```
65
+ $ gem install quickblox-rb
66
+ ```
67
+
5
68
  ## Development
6
69
 
7
70
  1. Install [dep](https://github.com/cyx/dep) with `gem install dep`.
File without changes
data/lib/models.rb CHANGED
@@ -32,17 +32,18 @@ module Quickblox::Models
32
32
  attribute :email
33
33
  attribute :login
34
34
  attribute :phone
35
- attribute :tags
35
+ attribute :tags, cast: ->(value) { value && value.split(",") }
36
+ attribute :custom_data
36
37
 
37
38
  def self.build(hash)
38
- email = hash.fetch("email") || JSON.parse(hash.fetch("custom_data")).fetch("email")
39
39
  new(
40
40
  id: hash.fetch("id"),
41
41
  full_name: hash.fetch("full_name"),
42
- email: email,
42
+ email: hash.fetch("email"),
43
43
  login: hash.fetch("login"),
44
44
  phone: hash.fetch("phone"),
45
- tags: hash.fetch("user_tags")
45
+ tags: hash.fetch("user_tags"),
46
+ custom_data: hash.fetch("custom_data")
46
47
  )
47
48
  end
48
49
  end
data/lib/quickblox.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  Quickblox = Module.new
2
2
 
3
- require_relative "quickblox_api"
3
+ require_relative "api"
4
4
  require_relative "models"
5
5
 
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.2"
3
+ s.version = "0.1.3"
4
4
  s.summary = "Ruby gem to work with Quickblox API"
5
5
  s.description = s.summary
6
6
  s.authors = ["Lucas Tolchinsky"]
@@ -109,6 +109,8 @@ test "#get_user" do
109
109
  assert_equal "Mr One", user.full_name
110
110
  assert_equal "1133445566", user.phone
111
111
  assert_equal "One", user.login
112
+ assert_equal ["tag1", "tag2"], user.tags
113
+ assert user.custom_data.nil?
112
114
  end
113
115
 
114
116
  test "#get_dialog" do
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.2
4
+ version: 0.1.3
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-04 00:00:00.000000000 Z
11
+ date: 2016-05-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: requests
@@ -77,11 +77,11 @@ files:
77
77
  - ".gitignore"
78
78
  - Makefile
79
79
  - README.md
80
+ - lib/api.rb
80
81
  - lib/models.rb
81
82
  - lib/quickblox.rb
82
- - lib/quickblox_api.rb
83
83
  - quickblox-rb.gemspec
84
- - test/quickblox_api_test.rb
84
+ - test/api_test.rb
85
85
  - test/quickblox_responses.rb
86
86
  homepage: https://github.com/properati/quickblox-rb
87
87
  licenses: