sendbird 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +11 -0
- data/.rspec +2 -0
- data/.travis.yml +5 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +41 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/config/secrets.example.yml +1 -0
- data/lib/sendbird.rb +16 -0
- data/lib/sendbird/client.rb +46 -0
- data/lib/sendbird/configuration.rb +13 -0
- data/lib/sendbird/group_channel.rb +48 -0
- data/lib/sendbird/message.rb +42 -0
- data/lib/sendbird/meta_base.rb +43 -0
- data/lib/sendbird/meta_counter.rb +5 -0
- data/lib/sendbird/meta_data.rb +5 -0
- data/lib/sendbird/open_channel.rb +72 -0
- data/lib/sendbird/response.rb +25 -0
- data/lib/sendbird/user.rb +56 -0
- data/lib/sendbird/user_api.rb +90 -0
- data/lib/sendbird/version.rb +3 -0
- data/sendbird.gemspec +32 -0
- metadata +168 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 345394b76bf73ff1d473718670ae6093b7e0d659
|
4
|
+
data.tar.gz: 9ef4b5eb091e0c85f4aef67994c7bab7cb82c9d8
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: dc88d376b180ddbe99ad6f48ca957843ce80bcdb7a45bcdec25e1fff42aef90f0ed0b8be96743356120bae4d47bb3be47593091e32d44d3da10794dbcd092875
|
7
|
+
data.tar.gz: 2b5731b29fdcbaa32c33eaa344f97419d49f1c14bc077b680fb65d1f7b5dc728967ddc1c40e8308bf30d246a52ef7240303e5557e18ec522042311ff11551a8f
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at gustavocaso@gmail.com. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 GustavoCaso
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
# Sendbird
|
2
|
+
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/sendbird`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'sendbird'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install sendbird
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
TODO: Write usage instructions here
|
26
|
+
|
27
|
+
## Development
|
28
|
+
|
29
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
+
|
31
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/sendbird. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
36
|
+
|
37
|
+
|
38
|
+
## License
|
39
|
+
|
40
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
41
|
+
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "sendbird"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
api_key:
|
data/lib/sendbird.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
require "sendbird/client"
|
2
|
+
require "sendbird/configuration"
|
3
|
+
require "sendbird/response"
|
4
|
+
require "sendbird/user_api"
|
5
|
+
require "sendbird/user"
|
6
|
+
require "sendbird/open_channel"
|
7
|
+
require "sendbird/group_channel"
|
8
|
+
require "sendbird/message"
|
9
|
+
require "sendbird/meta_base"
|
10
|
+
require "sendbird/meta_data"
|
11
|
+
require "sendbird/meta_counter"
|
12
|
+
require "sendbird/version"
|
13
|
+
|
14
|
+
module Sendbird
|
15
|
+
extend Configuration
|
16
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'faraday'
|
2
|
+
|
3
|
+
module Sendbird
|
4
|
+
module Client
|
5
|
+
class ApiKeyMissingError < StandardError; end
|
6
|
+
PUBLIC_METHODS = [:get, :post, :put, :delete]
|
7
|
+
|
8
|
+
PUBLIC_METHODS.each do |method|
|
9
|
+
define_method(method) do |path: , params: nil , body: nil|
|
10
|
+
fail ApiKeyMissingError.new(api_key_message) if Sendbird.api_key.nil?
|
11
|
+
response = request(method: method, path: path, params: params, body: body)
|
12
|
+
Response.new(response.status, response.body)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def build_url(*args)
|
17
|
+
if args.any?
|
18
|
+
new_args = args.dup
|
19
|
+
new_args.insert(0, self.const_get('ENDPOINT')).join('/')
|
20
|
+
else
|
21
|
+
self.const_get('ENDPOINT')
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
def conn
|
27
|
+
@conn ||= Faraday.new(url: Sendbird::Configuration::SENDBIRD_ENDPOINT) do |c|
|
28
|
+
c.request :url_encoded
|
29
|
+
c.adapter Faraday.default_adapter
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def request(method:, path:, params:, body:)
|
34
|
+
conn.send(method) do |req|
|
35
|
+
req.url path, params
|
36
|
+
req.headers['Api-Token'] = Sendbird.api_key
|
37
|
+
req.headers['Content-Type'] = 'application/json, charset=utf8'
|
38
|
+
req.body = body.to_json if body
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def api_key_message
|
43
|
+
'Please set up your api key'
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
module Sendbird
|
2
|
+
class GroupChannel
|
3
|
+
extend Client
|
4
|
+
ENDPOINT = 'group_channels'.freeze
|
5
|
+
|
6
|
+
class << self
|
7
|
+
def create(body)
|
8
|
+
post(path: build_url, body: body)
|
9
|
+
end
|
10
|
+
|
11
|
+
def list(params={})
|
12
|
+
get(path: build_url, params: params)
|
13
|
+
end
|
14
|
+
|
15
|
+
def update(channel_url, body)
|
16
|
+
put(path: build_url(channel_url), body: body)
|
17
|
+
end
|
18
|
+
|
19
|
+
def destroy(channel_url)
|
20
|
+
delete(path: build_url(channel_url))
|
21
|
+
end
|
22
|
+
|
23
|
+
def view(channel_url, params={})
|
24
|
+
get(path: build_url(channel_url), params: params)
|
25
|
+
end
|
26
|
+
|
27
|
+
def members(channel_url, params={})
|
28
|
+
get(path: build_url(channel_url, 'members'), params: params)
|
29
|
+
end
|
30
|
+
|
31
|
+
def is_member?(channel_url, user_id)
|
32
|
+
get(path: build_url(channel_url, 'members', user_id))
|
33
|
+
end
|
34
|
+
|
35
|
+
def invite(channel_url, body)
|
36
|
+
post(path: build_url(channel_url, 'invite'), body: body)
|
37
|
+
end
|
38
|
+
|
39
|
+
def hide(channel_url, body)
|
40
|
+
put(path: build_url(channel_url, 'hide'), body: body)
|
41
|
+
end
|
42
|
+
|
43
|
+
def leave(channel_url, body)
|
44
|
+
put(path: build_url(channel_url, 'leave'), body: body)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
module Sendbird
|
2
|
+
class Message
|
3
|
+
extend Client
|
4
|
+
|
5
|
+
class << self
|
6
|
+
def send(channel_type, channel_url, body)
|
7
|
+
post(path: build_url(channel_type, channel_url, 'messages'), body: body)
|
8
|
+
end
|
9
|
+
|
10
|
+
# Get messages function can be called only
|
11
|
+
# from Park or Enterprise plan.
|
12
|
+
def list(channel_type, channel_url, params)
|
13
|
+
get(path: build_url(channel_type, channel_url, 'messages'), params: params)
|
14
|
+
end
|
15
|
+
|
16
|
+
def view(channel_type, channel_url, message_id)
|
17
|
+
get(path: build_url(channel_type, channel_url, 'messages', message_id))
|
18
|
+
end
|
19
|
+
|
20
|
+
def destroy(channel_type, channel_url, message_id)
|
21
|
+
delete(path: build_url(channel_type, channel_url, 'messages', message_id))
|
22
|
+
end
|
23
|
+
|
24
|
+
def mark_as_read(channel_type, channel_url, body)
|
25
|
+
put(path: build_url(channel_type, channel_url, 'messages', 'mark_as_read'), body: body)
|
26
|
+
end
|
27
|
+
|
28
|
+
def count(channel_type, channel_url)
|
29
|
+
get(path: build_url(channel_type, channel_url, 'messages', 'total_count'))
|
30
|
+
end
|
31
|
+
|
32
|
+
def unread_count(channel_type, channel_url, params)
|
33
|
+
get(path: build_url(channel_type, channel_url, 'messages', 'unread_count'), params: params)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def self.build_url(*args)
|
38
|
+
args_dup = args.dup
|
39
|
+
args_dup.join('/')
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
module Sendbird
|
2
|
+
class MetaBase
|
3
|
+
extend Client
|
4
|
+
class << self
|
5
|
+
def create(channel_type, channel_url, body)
|
6
|
+
post(path: build_url(channel_type, channel_url, endpoint), body: body)
|
7
|
+
end
|
8
|
+
|
9
|
+
def view(channel_type, channel_url, params={})
|
10
|
+
get(path: build_url(channel_type, channel_url, endpoint), params: params)
|
11
|
+
end
|
12
|
+
|
13
|
+
def view_by_key(channel_type, channel_url, key)
|
14
|
+
get(path: build_url(channel_type, channel_url, endpoint, key))
|
15
|
+
end
|
16
|
+
|
17
|
+
def update(channel_type, channel_url, body)
|
18
|
+
put(path: build_url(channel_type, channel_url, endpoint), body: body)
|
19
|
+
end
|
20
|
+
|
21
|
+
def update_by_key(channel_type, channel_url, key, body)
|
22
|
+
put(path: build_url(channel_type, channel_url, endpoint, key), body: body)
|
23
|
+
end
|
24
|
+
|
25
|
+
def destroy(channel_type, channel_url)
|
26
|
+
delete(path: build_url(channel_type, channel_url, endpoint))
|
27
|
+
end
|
28
|
+
|
29
|
+
def destroy_by_key(channel_type, channel_url, key)
|
30
|
+
delete(path: build_url(channel_type, channel_url, endpoint, key))
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def self.endpoint
|
35
|
+
self.const_get('ENDPOINT')
|
36
|
+
end
|
37
|
+
|
38
|
+
def self.build_url(*args)
|
39
|
+
args_dup = args.dup
|
40
|
+
args_dup.join('/')
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,72 @@
|
|
1
|
+
module Sendbird
|
2
|
+
class OpenChannel
|
3
|
+
extend Client
|
4
|
+
ENDPOINT = 'open_channels'.freeze
|
5
|
+
|
6
|
+
class << self
|
7
|
+
def view(channel_url, params={})
|
8
|
+
get(path: build_url(channel_url), params: params)
|
9
|
+
end
|
10
|
+
|
11
|
+
def create(body={})
|
12
|
+
post(path: build_url, body: body)
|
13
|
+
end
|
14
|
+
|
15
|
+
def list(params={})
|
16
|
+
get(path: build_url, params: params)
|
17
|
+
end
|
18
|
+
|
19
|
+
def destroy(channel_url)
|
20
|
+
delete(path: build_url(channel_url))
|
21
|
+
end
|
22
|
+
|
23
|
+
def update(channel_url, body)
|
24
|
+
put(path: build_url(channel_url), body: body)
|
25
|
+
end
|
26
|
+
|
27
|
+
def participants(channel_url, params)
|
28
|
+
get(path: build_url(channel_url, 'participants'), params: params)
|
29
|
+
end
|
30
|
+
|
31
|
+
def freeze(channel_url, body)
|
32
|
+
put(path: build_url(channel_url, 'freeze'), body: body)
|
33
|
+
end
|
34
|
+
|
35
|
+
def ban_user(channel_url, body)
|
36
|
+
post(path: build_url(channel_url, 'ban'), body: body)
|
37
|
+
end
|
38
|
+
|
39
|
+
def ban_list(channel_url, params={})
|
40
|
+
get(path: build_url(channel_url, 'ban'), params: params)
|
41
|
+
end
|
42
|
+
|
43
|
+
def ban_update(channel_url, user_id, body)
|
44
|
+
put(path: build_url(channel_url, 'ban', user_id), body: body)
|
45
|
+
end
|
46
|
+
|
47
|
+
def ban_delete(channel_url, user_id)
|
48
|
+
delete(path: build_url(channel_url, 'ban', user_id))
|
49
|
+
end
|
50
|
+
|
51
|
+
def ban_view(channel_url, user_id)
|
52
|
+
get(path: build_url(channel_url, 'ban', user_id))
|
53
|
+
end
|
54
|
+
|
55
|
+
def mute(channel_url, body)
|
56
|
+
post(path: build_url(channel_url, 'mute'), body: body)
|
57
|
+
end
|
58
|
+
|
59
|
+
def mute_list(channel_url, params={})
|
60
|
+
get(path: build_url(channel_url, 'mute'), params: params)
|
61
|
+
end
|
62
|
+
|
63
|
+
def mute_delete(channel_url, user_id)
|
64
|
+
delete(path: build_url(channel_url, 'mute', user_id))
|
65
|
+
end
|
66
|
+
|
67
|
+
def mute_view(channel_url, user_id)
|
68
|
+
get(path: build_url(channel_url, 'mute', user_id))
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module Sendbird
|
2
|
+
class Response
|
3
|
+
attr_reader :status, :body
|
4
|
+
def initialize(status, body)
|
5
|
+
@status = status
|
6
|
+
@body = JSON[body]
|
7
|
+
end
|
8
|
+
|
9
|
+
def error_message
|
10
|
+
if body['error']
|
11
|
+
body['message']
|
12
|
+
else
|
13
|
+
'Not any error to report'
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def error_code
|
18
|
+
if body['error']
|
19
|
+
body['code']
|
20
|
+
else
|
21
|
+
'Not any error to report'
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
module Sendbird
|
2
|
+
class User < Struct.new(:user_id, :nickname, :profile_url, :access_token, :last_seen_at, :is_online)
|
3
|
+
def self.create_or_initialize(params)
|
4
|
+
case params
|
5
|
+
when Response
|
6
|
+
new(*params.body.map{|x| x.last})
|
7
|
+
when Hash
|
8
|
+
response = UserApi.show(params[:user_id])
|
9
|
+
if response.status == 200
|
10
|
+
new(*response.body.map{|x| x.last})
|
11
|
+
else
|
12
|
+
new_user = UserApi.create(params)
|
13
|
+
new(*new_user.body.map{|x| x.last})
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
private_class_method :new
|
19
|
+
|
20
|
+
def view
|
21
|
+
UserApi.show(user_id)
|
22
|
+
end
|
23
|
+
|
24
|
+
def update(body)
|
25
|
+
UserApi.update(user_id, body)
|
26
|
+
end
|
27
|
+
|
28
|
+
def unread_count
|
29
|
+
UserApi.unread_count(user_id)
|
30
|
+
end
|
31
|
+
|
32
|
+
def mark_as_read_all
|
33
|
+
UserApi.mark_as_read_all(user_id)
|
34
|
+
end
|
35
|
+
|
36
|
+
def register_gcm_token(token)
|
37
|
+
UserApi.register_gcm_token(user_id, token)
|
38
|
+
end
|
39
|
+
|
40
|
+
def register_apns_token(token)
|
41
|
+
UserApi.register_apns_token(user_id, token)
|
42
|
+
end
|
43
|
+
|
44
|
+
def unregister_gcm_token(token)
|
45
|
+
UserApi.unregister_gcm_token(user_id, token)
|
46
|
+
end
|
47
|
+
|
48
|
+
def unregister_apns_token(token)
|
49
|
+
UserApi.unregister_apns_token(user_id, token)
|
50
|
+
end
|
51
|
+
|
52
|
+
def unregister_all_device_token
|
53
|
+
UserApi.unregister_all_device_token(user_id)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,90 @@
|
|
1
|
+
module Sendbird
|
2
|
+
class UserApi
|
3
|
+
extend Client
|
4
|
+
ENDPOINT = 'users'.freeze
|
5
|
+
|
6
|
+
class << self
|
7
|
+
def show(user_id)
|
8
|
+
get(path: build_url(user_id))
|
9
|
+
end
|
10
|
+
|
11
|
+
def create(body)
|
12
|
+
post(path: build_url, body: body)
|
13
|
+
end
|
14
|
+
|
15
|
+
def list(params={})
|
16
|
+
get(path: build_url, params: params)
|
17
|
+
end
|
18
|
+
|
19
|
+
def update(user_id, body)
|
20
|
+
put(path: build_url(user_id), body: body)
|
21
|
+
end
|
22
|
+
|
23
|
+
def unread_count(user_id)
|
24
|
+
get(path: build_url(user_id, 'unread_count'))
|
25
|
+
end
|
26
|
+
|
27
|
+
def activate(user_id, body)
|
28
|
+
put(path: build_url(user_id, 'activate'), body: body)
|
29
|
+
end
|
30
|
+
|
31
|
+
def block(user_id, body)
|
32
|
+
post(path: build_url(user_id, 'block'), body: body)
|
33
|
+
end
|
34
|
+
|
35
|
+
def unblock(user_id, unblock_user_id)
|
36
|
+
delete(path: build_url(user_id, 'block', unblock_user_id))
|
37
|
+
end
|
38
|
+
|
39
|
+
def block_list(user_id, params={})
|
40
|
+
get(path: build_url(user_id, 'block'), params: params)
|
41
|
+
end
|
42
|
+
|
43
|
+
def mark_as_read_all(user_id)
|
44
|
+
put(path: build_url(user_id, 'mark_as_read_all'))
|
45
|
+
end
|
46
|
+
|
47
|
+
def register_gcm_token(user_id, token)
|
48
|
+
register_token(user_id, 'gcm', {gcm_reg_token: token})
|
49
|
+
end
|
50
|
+
|
51
|
+
def register_apns_token(user_id, token)
|
52
|
+
register_token(user_id, 'apns', {apns_device_token: token})
|
53
|
+
end
|
54
|
+
|
55
|
+
def unregister_gcm_token(user_id, token)
|
56
|
+
unregister_token(user_id, 'gcm', token)
|
57
|
+
end
|
58
|
+
|
59
|
+
def unregister_apns_token(user_id, token)
|
60
|
+
unregister_token(user_id, 'apns', token)
|
61
|
+
end
|
62
|
+
|
63
|
+
def unregister_all_device_token(user_id)
|
64
|
+
delete(path: build_url(user_id, 'push'))
|
65
|
+
end
|
66
|
+
|
67
|
+
def push_preferences(user_id)
|
68
|
+
get(path: build_url(user_id, 'push_preference'))
|
69
|
+
end
|
70
|
+
|
71
|
+
def update_push_preferences(user_id, body)
|
72
|
+
put(path: build_url(user_id, 'push_preference'), body: body)
|
73
|
+
end
|
74
|
+
|
75
|
+
def delete_push_preferences(user_id)
|
76
|
+
delete(path: build_url(user_id, 'push_preference'))
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
def self.register_token(user_id,token_type, body)
|
81
|
+
post(path: build_url(user_id, 'push', token_type), body: body)
|
82
|
+
end
|
83
|
+
|
84
|
+
def self.unregister_token(user_id, token_type, token)
|
85
|
+
delete(path: build_url(user_id, 'push', token_type, token))
|
86
|
+
end
|
87
|
+
|
88
|
+
private_class_method :register_token, :unregister_token
|
89
|
+
end
|
90
|
+
end
|
data/sendbird.gemspec
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'sendbird/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "sendbird"
|
8
|
+
spec.version = Sendbird::VERSION
|
9
|
+
spec.authors = ["GustavoCaso"]
|
10
|
+
spec.email = ["gustavocaso@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{Wrapper for the Sendbird Platform API}
|
13
|
+
spec.description = %q{Wrapper for the Sendbird Platform API}
|
14
|
+
spec.homepage = "https://github.com/GustavoCaso/sendbird/"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
18
|
+
f.match(%r{^(test|spec|features)/})
|
19
|
+
end
|
20
|
+
spec.bindir = "exe"
|
21
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
22
|
+
spec.require_paths = ["lib"]
|
23
|
+
|
24
|
+
spec.add_development_dependency "bundler", "~> 1.13"
|
25
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
26
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
27
|
+
spec.add_development_dependency "pry"
|
28
|
+
spec.add_development_dependency "webmock"
|
29
|
+
spec.add_development_dependency "vcr"
|
30
|
+
|
31
|
+
spec.add_runtime_dependency 'faraday'
|
32
|
+
end
|
metadata
ADDED
@@ -0,0 +1,168 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: sendbird
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- GustavoCaso
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-10-17 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.13'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.13'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: pry
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: webmock
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: vcr
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: faraday
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :runtime
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
description: Wrapper for the Sendbird Platform API
|
112
|
+
email:
|
113
|
+
- gustavocaso@gmail.com
|
114
|
+
executables: []
|
115
|
+
extensions: []
|
116
|
+
extra_rdoc_files: []
|
117
|
+
files:
|
118
|
+
- ".gitignore"
|
119
|
+
- ".rspec"
|
120
|
+
- ".ruby-gemset"
|
121
|
+
- ".travis.yml"
|
122
|
+
- CODE_OF_CONDUCT.md
|
123
|
+
- Gemfile
|
124
|
+
- LICENSE.txt
|
125
|
+
- README.md
|
126
|
+
- Rakefile
|
127
|
+
- bin/console
|
128
|
+
- bin/setup
|
129
|
+
- config/secrets.example.yml
|
130
|
+
- lib/sendbird.rb
|
131
|
+
- lib/sendbird/client.rb
|
132
|
+
- lib/sendbird/configuration.rb
|
133
|
+
- lib/sendbird/group_channel.rb
|
134
|
+
- lib/sendbird/message.rb
|
135
|
+
- lib/sendbird/meta_base.rb
|
136
|
+
- lib/sendbird/meta_counter.rb
|
137
|
+
- lib/sendbird/meta_data.rb
|
138
|
+
- lib/sendbird/open_channel.rb
|
139
|
+
- lib/sendbird/response.rb
|
140
|
+
- lib/sendbird/user.rb
|
141
|
+
- lib/sendbird/user_api.rb
|
142
|
+
- lib/sendbird/version.rb
|
143
|
+
- sendbird.gemspec
|
144
|
+
homepage: https://github.com/GustavoCaso/sendbird/
|
145
|
+
licenses:
|
146
|
+
- MIT
|
147
|
+
metadata: {}
|
148
|
+
post_install_message:
|
149
|
+
rdoc_options: []
|
150
|
+
require_paths:
|
151
|
+
- lib
|
152
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
153
|
+
requirements:
|
154
|
+
- - ">="
|
155
|
+
- !ruby/object:Gem::Version
|
156
|
+
version: '0'
|
157
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
158
|
+
requirements:
|
159
|
+
- - ">="
|
160
|
+
- !ruby/object:Gem::Version
|
161
|
+
version: '0'
|
162
|
+
requirements: []
|
163
|
+
rubyforge_project:
|
164
|
+
rubygems_version: 2.5.1
|
165
|
+
signing_key:
|
166
|
+
specification_version: 4
|
167
|
+
summary: Wrapper for the Sendbird Platform API
|
168
|
+
test_files: []
|