rongcloud-server-sdk 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 59cfd97613387ba8f0d9935ee385ea2cd22b63ec3af3cbf9eb0d20621e163607
4
+ data.tar.gz: 9ad92c2b7ee3326c6785899d5f576d3e1f6a58d436e03e37e90832acc64b11e8
5
+ SHA512:
6
+ metadata.gz: 519d20363f451a358dba1bd6a01c3a446d82e3bd548f0d61e2d901411092c5e60e29a34f603773ff4d159a2d9b3db91736cef67e553c22ab9cd333c99fe33532
7
+ data.tar.gz: f233475c85c2d2a1aee92253d6a0661a569fe10ea4b55b3ccad16f2a8b3c17a2b1be72dbccbda89383c3d9bd342c6b9bf1aa5dab21376e7ec3c4331f05594eef
data/.editorconfig ADDED
@@ -0,0 +1,9 @@
1
+ root = true
2
+
3
+ [*]
4
+ charset = utf-8
5
+ indent_style = space
6
+ indent_size = 2
7
+ insert_final_newline = true
8
+ trim_trailing_whitespace = true
9
+ end_of_line = lf
data/.overcommit.yml ADDED
@@ -0,0 +1,26 @@
1
+ # Use this file to configure the Overcommit hooks you wish to use. This will
2
+ # extend the default configuration defined in:
3
+ # https://github.com/sds/overcommit/blob/master/config/default.yml
4
+ #
5
+ # At the topmost level of this YAML file is a key representing type of hook
6
+ # being run (e.g. pre-commit, commit-msg, etc.). Within each type you can
7
+ # customize each hook, such as whether to only run it on certain files (via
8
+ # `include`), whether to only display output if it fails (via `quiet`), etc.
9
+ #
10
+ # For a complete list of hooks, see:
11
+ # https://github.com/sds/overcommit/tree/master/lib/overcommit/hook
12
+ #
13
+ # For a complete list of options that you can use to customize hooks, see:
14
+ # https://github.com/sds/overcommit#configuration
15
+ #
16
+ # Uncomment the following lines to make the configuration take effect.
17
+
18
+ PreCommit:
19
+ RuboCop:
20
+ enabled: true
21
+ command: 'bin/rubocop'
22
+
23
+ PrePush:
24
+ RSpec:
25
+ enabled: true
26
+ command: 'bin/rspec'
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.rubocop ADDED
File without changes
data/.rubocop.yml ADDED
@@ -0,0 +1,11 @@
1
+ require: standard
2
+
3
+ inherit_gem:
4
+ standard: config/base.yml
5
+
6
+ AllCops:
7
+ SuggestExtensions: false
8
+ Exclude:
9
+ - 'bin/**/*'
10
+ - 'vendor/**/*'
11
+
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 3.1.1
data/.yardopts ADDED
@@ -0,0 +1,2 @@
1
+ --markup=markdown
2
+ --markup-provider=redcarpet
@@ -0,0 +1,84 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
6
+
7
+ We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
8
+
9
+ ## Our Standards
10
+
11
+ Examples of behavior that contributes to a positive environment for our community include:
12
+
13
+ * Demonstrating empathy and kindness toward other people
14
+ * Being respectful of differing opinions, viewpoints, and experiences
15
+ * Giving and gracefully accepting constructive feedback
16
+ * Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
17
+ * Focusing on what is best not just for us as individuals, but for the overall community
18
+
19
+ Examples of unacceptable behavior include:
20
+
21
+ * The use of sexualized language or imagery, and sexual attention or
22
+ advances of any kind
23
+ * Trolling, insulting or derogatory comments, and personal or political attacks
24
+ * Public or private harassment
25
+ * Publishing others' private information, such as a physical or email
26
+ address, without their explicit permission
27
+ * Other conduct which could reasonably be considered inappropriate in a
28
+ professional setting
29
+
30
+ ## Enforcement Responsibilities
31
+
32
+ Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
33
+
34
+ Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
35
+
36
+ ## Scope
37
+
38
+ This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
39
+
40
+ ## Enforcement
41
+
42
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at johndoe@example.com. All complaints will be reviewed and investigated promptly and fairly.
43
+
44
+ All community leaders are obligated to respect the privacy and security of the reporter of any incident.
45
+
46
+ ## Enforcement Guidelines
47
+
48
+ Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
49
+
50
+ ### 1. Correction
51
+
52
+ **Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
53
+
54
+ **Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
55
+
56
+ ### 2. Warning
57
+
58
+ **Community Impact**: A violation through a single incident or series of actions.
59
+
60
+ **Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
61
+
62
+ ### 3. Temporary Ban
63
+
64
+ **Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
65
+
66
+ **Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
67
+
68
+ ### 4. Permanent Ban
69
+
70
+ **Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
71
+
72
+ **Consequence**: A permanent ban from any sort of public interaction within the community.
73
+
74
+ ## Attribution
75
+
76
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
77
+ available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
78
+
79
+ Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
80
+
81
+ [homepage]: https://www.contributor-covenant.org
82
+
83
+ For answers to common questions about this code of conduct, see the FAQ at
84
+ https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
data/Gemfile ADDED
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in rongcloud-server-sdk.gemspec
6
+ gemspec
7
+
8
+ # rake
9
+ gem "rake", "~> 13.0"
10
+
11
+ # lint
12
+ gem "rubocop", "~> 1.29"
13
+ gem "standard", "~> 1.12"
14
+
15
+ # test
16
+ gem "dotenv", "~> 2.7"
17
+ gem "rspec", "~> 3.0"
18
+ gem "vcr", "~> 6.0"
19
+ gem "webmock", "~> 3.18"
20
+
21
+ # doc
22
+ gem "yard", "~> 0.9"
23
+ gem "redcarpet", "~> 3.5"
24
+
25
+ # misc
26
+ gem "overcommit", "~> 0.59"
data/Gemfile.lock ADDED
@@ -0,0 +1,113 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ rongcloud-server-sdk (1.0.1)
5
+ http (~> 5.0)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ addressable (2.8.1)
11
+ public_suffix (>= 2.0.2, < 6.0)
12
+ ast (2.4.2)
13
+ childprocess (4.1.0)
14
+ crack (0.4.5)
15
+ rexml
16
+ diff-lcs (1.5.0)
17
+ domain_name (0.5.20190701)
18
+ unf (>= 0.0.5, < 1.0.0)
19
+ dotenv (2.8.1)
20
+ ffi (1.15.5)
21
+ ffi-compiler (1.0.1)
22
+ ffi (>= 1.0.0)
23
+ rake
24
+ hashdiff (1.0.1)
25
+ http (5.1.0)
26
+ addressable (~> 2.8)
27
+ http-cookie (~> 1.0)
28
+ http-form_data (~> 2.2)
29
+ llhttp-ffi (~> 0.4.0)
30
+ http-cookie (1.0.5)
31
+ domain_name (~> 0.5)
32
+ http-form_data (2.3.0)
33
+ iniparse (1.5.0)
34
+ json (2.6.2)
35
+ llhttp-ffi (0.4.0)
36
+ ffi-compiler (~> 1.0)
37
+ rake (~> 13.0)
38
+ overcommit (0.59.1)
39
+ childprocess (>= 0.6.3, < 5)
40
+ iniparse (~> 1.4)
41
+ rexml (~> 3.2)
42
+ parallel (1.22.1)
43
+ parser (3.1.2.1)
44
+ ast (~> 2.4.1)
45
+ public_suffix (5.0.0)
46
+ rainbow (3.1.1)
47
+ rake (13.0.6)
48
+ redcarpet (3.5.1)
49
+ regexp_parser (2.6.0)
50
+ rexml (3.2.5)
51
+ rspec (3.11.0)
52
+ rspec-core (~> 3.11.0)
53
+ rspec-expectations (~> 3.11.0)
54
+ rspec-mocks (~> 3.11.0)
55
+ rspec-core (3.11.0)
56
+ rspec-support (~> 3.11.0)
57
+ rspec-expectations (3.11.1)
58
+ diff-lcs (>= 1.2.0, < 2.0)
59
+ rspec-support (~> 3.11.0)
60
+ rspec-mocks (3.11.1)
61
+ diff-lcs (>= 1.2.0, < 2.0)
62
+ rspec-support (~> 3.11.0)
63
+ rspec-support (3.11.1)
64
+ rubocop (1.35.1)
65
+ json (~> 2.3)
66
+ parallel (~> 1.10)
67
+ parser (>= 3.1.2.1)
68
+ rainbow (>= 2.2.2, < 4.0)
69
+ regexp_parser (>= 1.8, < 3.0)
70
+ rexml (>= 3.2.5, < 4.0)
71
+ rubocop-ast (>= 1.20.1, < 2.0)
72
+ ruby-progressbar (~> 1.7)
73
+ unicode-display_width (>= 1.4.0, < 3.0)
74
+ rubocop-ast (1.21.0)
75
+ parser (>= 3.1.1.0)
76
+ rubocop-performance (1.14.3)
77
+ rubocop (>= 1.7.0, < 2.0)
78
+ rubocop-ast (>= 0.4.0)
79
+ ruby-progressbar (1.11.0)
80
+ standard (1.16.1)
81
+ rubocop (= 1.35.1)
82
+ rubocop-performance (= 1.14.3)
83
+ unf (0.1.4)
84
+ unf_ext
85
+ unf_ext (0.0.8.2)
86
+ unicode-display_width (2.3.0)
87
+ vcr (6.1.0)
88
+ webmock (3.18.1)
89
+ addressable (>= 2.8.0)
90
+ crack (>= 0.3.2)
91
+ hashdiff (>= 0.4.0, < 2.0.0)
92
+ webrick (1.7.0)
93
+ yard (0.9.28)
94
+ webrick (~> 1.7.0)
95
+
96
+ PLATFORMS
97
+ x86_64-linux
98
+
99
+ DEPENDENCIES
100
+ dotenv (~> 2.7)
101
+ overcommit (~> 0.59)
102
+ rake (~> 13.0)
103
+ redcarpet (~> 3.5)
104
+ rongcloud-server-sdk!
105
+ rspec (~> 3.0)
106
+ rubocop (~> 1.29)
107
+ standard (~> 1.12)
108
+ vcr (~> 6.0)
109
+ webmock (~> 3.18)
110
+ yard (~> 0.9)
111
+
112
+ BUNDLED WITH
113
+ 2.3.7
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2022 John Doe
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,98 @@
1
+ # rongcloud-server-sdk-ruby
2
+
3
+ Rong Cloud Server SDK in Ruby.
4
+
5
+
6
+ ## Installation
7
+
8
+ Add this line to your application's Gemfile:
9
+
10
+ ```ruby
11
+ gem 'rongcloud-server-sdk', require: 'rongcloud'
12
+ ```
13
+
14
+ And then execute:
15
+
16
+ $ bundle install
17
+
18
+ Or install it yourself as:
19
+
20
+ $ gem install rongcloud-server-sdk
21
+
22
+
23
+ ## Usage
24
+
25
+ ```ruby
26
+ rongcloud = RongCloud::Client::new(
27
+ app_key: ENV["RONGCLOUD_APP_KEY"],
28
+ app_secret: ENV["RONGCLOUD_APP_SECRET"],
29
+ host: "api-cn.ronghub.com"
30
+ )
31
+
32
+ rongcloud.api.user.gettoken(
33
+ userId: 'nutzer'
34
+ )
35
+ ```
36
+
37
+ The API name is converted from the corresponding URI, E.g.
38
+
39
+ | URI | Call use |
40
+ |----------------------------|------------------------------|
41
+ | /user/getToken.json | api.user.gettoken(...) |
42
+ | /user/token/expire.json | api.user.token\_expire(...) |
43
+ | /push.json | api.push.(...) |
44
+ | /push/custom.json | api.push.custom(...) |
45
+ | /stat/getDayPushData.json | api.stat.getdaypushdata(...) |
46
+ | /stat/getPushIdData.json | api.stat.getpushiddata(...) |
47
+ | ... | ... |
48
+
49
+ ### Timeout
50
+
51
+ ```ruby
52
+ rongcloud = RongCloud::Client::new(
53
+ app_key: ENV["RONGCLOUD_APP_KEY"],
54
+ app_secret: ENV["RONGCLOUD_APP_SECRET"],
55
+ host: "api-cn.ronghub.com",
56
+ http: {
57
+ timeout_class: HTTP::Timeout::Global,
58
+ timeout_options: {global_timeout: 2}
59
+ }
60
+ )
61
+ ```
62
+
63
+ ### Logging
64
+
65
+ ```ruby
66
+ rongcloud = RongCloud::Client::new(
67
+ app_key: ENV["RONGCLOUD_APP_KEY"],
68
+ app_secret: ENV["RONGCLOUD_APP_SECRET"],
69
+ host: "api-cn.ronghub.com",
70
+ http: {
71
+ features: {
72
+ logging: {logger: Logger.new($stdout)}
73
+ }
74
+ }
75
+ )
76
+ ```
77
+
78
+
79
+ ## Development
80
+
81
+ 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.
82
+
83
+ 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 the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
84
+
85
+
86
+ ## Contributing
87
+
88
+ Bug reports and pull requests are welcome on GitHub at https://github.com/souk4711/rongcloud-server-sdk-ruby. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/souk4711/rongcloud-server-sdk-ruby/blob/main/CODE_OF_CONDUCT.md).
89
+
90
+
91
+ ## License
92
+
93
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
94
+
95
+
96
+ ## Code of Conduct
97
+
98
+ Everyone interacting in the rongcloud-server-sdk-ruby project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/souk4711/rongcloud-server-sdk-ruby/blob/main/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+
5
+ require "rubocop/rake_task"
6
+ RuboCop::RakeTask.new
7
+
8
+ require "rspec/core/rake_task"
9
+ RSpec::Core::RakeTask.new(:spec)
10
+
11
+ task default: %i[rubocop spec]
@@ -0,0 +1,46 @@
1
+ module RongCloud
2
+ module API
3
+ module Chatroom
4
+ include Resourceable
5
+
6
+ member "/chatroom/create.json"
7
+ member "/chatroom/destroy.json"
8
+ member "/chatroom/query.json"
9
+
10
+ member "/chatroom/correlation/rtc.json"
11
+ member "/chatroom/entry/query.json"
12
+ member "/chatroom/entry/remove.json"
13
+ member "/chatroom/entry/set.json"
14
+ member "/chatroom/keepalive/add.json"
15
+ member "/chatroom/keepalive/query.json"
16
+ member "/chatroom/keepalive/remove.json"
17
+ member "/chatroom/whitelist/add.json"
18
+ member "/chatroom/whitelist/delete.json"
19
+ member "/chatroom/whitelist/query.json"
20
+
21
+ member "/chatroom/message/priority/add.json"
22
+ member "/chatroom/message/priority/query.json"
23
+ member "/chatroom/message/priority/remove.json"
24
+
25
+ member "/chatroom/ban/add.json"
26
+ member "/chatroom/ban/check.json"
27
+ member "/chatroom/ban/query.json"
28
+ member "/chatroom/ban/rollback.json"
29
+ member "/chatroom/user/ban/add.json"
30
+ member "/chatroom/user/ban/query.json"
31
+ member "/chatroom/user/ban/remove.json"
32
+ member "/chatroom/user/block/add.json"
33
+ member "/chatroom/user/block/list.json"
34
+ member "/chatroom/user/block/rollback.json"
35
+ member "/chatroom/user/gag/add.json"
36
+ member "/chatroom/user/gag/list.json"
37
+ member "/chatroom/user/gag/rollback.json"
38
+ member "/chatroom/user/query.json"
39
+ member "/chatroom/user/whitelist/add.json"
40
+ member "/chatroom/user/whitelist/query.json"
41
+ member "/chatroom/user/whitelist/remove.json"
42
+ member "/chatroom/user/exist.json"
43
+ member "/chatroom/users/exist.json"
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,14 @@
1
+ module RongCloud
2
+ module API
3
+ module Conversation
4
+ include Resourceable
5
+
6
+ member "/conversation/message/history/clean.json"
7
+ member "/conversation/notification/get.json"
8
+ member "/conversation/notification/set.json"
9
+ member "/conversation/top/set.json"
10
+ member "/conversation/type/notification/get.json"
11
+ member "/conversation/type/notification/set.json"
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,29 @@
1
+ module RongCloud
2
+ module API
3
+ module Group
4
+ include Resourceable
5
+
6
+ member "/group/create.json"
7
+ member "/group/dismiss.json"
8
+ member "/group/join.json"
9
+ member "/group/quit.json"
10
+ member "/group/refresh.json"
11
+ member "/group/sync.json"
12
+
13
+ member "/group/ban/add.json"
14
+ member "/group/ban/query.json"
15
+ member "/group/ban/rollback.json"
16
+ member "/group/user/ban/whitelist/add.json"
17
+ member "/group/user/ban/whitelist/query.json"
18
+ member "/group/user/ban/whitelist/rollback.json"
19
+ member "/group/user/gag/add.json"
20
+ member "/group/user/gag/list.json"
21
+ member "/group/user/gag/rollback.json"
22
+ member "/group/user/query.json"
23
+
24
+ member "/group/remarks/del.json"
25
+ member "/group/remarks/get.json"
26
+ member "/group/remarks/set.json"
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,9 @@
1
+ module RongCloud
2
+ module API
3
+ module Jwt
4
+ include Resourceable
5
+
6
+ member "/jwt/getToken.json"
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,24 @@
1
+ module RongCloud
2
+ module API
3
+ module Message
4
+ include Resourceable
5
+
6
+ member "/message/broadcast.json"
7
+ member "/message/recall.json"
8
+
9
+ member "/message/chatroom/broadcast.json"
10
+ member "/message/chatroom/publish.json"
11
+ member "/message/private/publish.json"
12
+ member "/message/private/publish_template.json", format: :json
13
+ member "/message/group/publish.json"
14
+ member "/message/online/broadcast.json"
15
+ member "/message/system/publish.json"
16
+ member "/message/system/publish_template.json", format: :json
17
+ member "/message/ultragroup/publish.json", format: :json
18
+
19
+ member "/message/expansion/delete.json"
20
+ member "/message/expansion/query.json"
21
+ member "/message/expansion/set.json"
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,11 @@
1
+ module RongCloud
2
+ module API
3
+ module Push
4
+ include Resourceable
5
+
6
+ member "/push.json", as: :call, format: :json
7
+ member "/push/custom.json", format: :json
8
+ member "/push/user.json", format: :json
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,12 @@
1
+ module RongCloud
2
+ module API
3
+ module Sensitiveword
4
+ include Resourceable
5
+
6
+ member "/sensitiveword/add.json"
7
+ member "/sensitiveword/delete.json"
8
+ member "/sensitiveword/list.json"
9
+ member "/sensitiveword/batch/delete.json"
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,10 @@
1
+ module RongCloud
2
+ module API
3
+ module Stat
4
+ include Resourceable
5
+
6
+ member "/stat/getDayPushData"
7
+ member "/stat/getPushIdData"
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,10 @@
1
+ module RongCloud
2
+ module API
3
+ module Statusmessage
4
+ include Resourceable
5
+
6
+ member "/statusmessage/group/publish.json"
7
+ member "/statusmessage/private/publish.json"
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,37 @@
1
+ module RongCloud
2
+ module API
3
+ module Ultragroup
4
+ include Resourceable
5
+
6
+ member "/ultragroup/create.json"
7
+ member "/ultragroup/dis.json"
8
+ member "/ultragroup/join.json"
9
+ member "/ultragroup/quit.json"
10
+ member "/ultragroup/refresh.json"
11
+
12
+ member "/ultragroup/channel/create.json"
13
+ member "/ultragroup/channel/del.json"
14
+ member "/ultragroup/channel/get.json"
15
+ member "/ultragroup/channel/private/users/add.json"
16
+ member "/ultragroup/channel/private/users/del.json"
17
+ member "/ultragroup/channel/private/users/get.json"
18
+ member "/ultragroup/channel/type/change.json"
19
+
20
+ member "/ultragroup/message/expansion/delete.json"
21
+ member "/ultragroup/message/expansion/query.json"
22
+ member "/ultragroup/message/expansion/set.json"
23
+
24
+ member "/ultragroup/banned/whitelist/add.json"
25
+ member "/ultragroup/banned/whitelist/del.json"
26
+ member "/ultragroup/banned/whitelist/get.json"
27
+ member "/ultragroup/globalbanned/get.json"
28
+ member "/ultragroup/globalbanned/set.json"
29
+ member "/ultragroup/member/exist.json"
30
+ member "/ultragroup/notdisturb/get.json"
31
+ member "/ultragroup/notdisturb/set.json"
32
+ member "/ultragroup/userbanned/add.json"
33
+ member "/ultragroup/userbanned/del.json"
34
+ member "/ultragroup/userbanned/get.json"
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,33 @@
1
+ module RongCloud
2
+ module API
3
+ module User
4
+ include Resourceable
5
+
6
+ member "/user/getToken.json"
7
+ member "/user/token/expire.json"
8
+ member "/user/info.json"
9
+ member "/user/refresh.json"
10
+
11
+ member "/user/block.json"
12
+ member "/user/block/query.json"
13
+ member "/user/unblock.json"
14
+ member "/user/checkOnline.json"
15
+ member "/user/group/query.json"
16
+
17
+ member "/user/blacklist/add.json"
18
+ member "/user/blacklist/query.json"
19
+ member "/user/blacklist/remove.json"
20
+ member "/user/whitelist/add.json"
21
+ member "/user/whitelist/query.json"
22
+ member "/user/whitelist/remove.json"
23
+ member "/user/whitesetting/query.json"
24
+ member "/user/whitesetting/set.json"
25
+ member "/user/chat/fb/set.json"
26
+ member "/user/chat/fb/querylist.json"
27
+
28
+ member "/user/remarks/del.json"
29
+ member "/user/remarks/get.json"
30
+ member "/user/remarks/set.json"
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,56 @@
1
+ module RongCloud
2
+ module API
3
+ module Resourceable
4
+ def self.included(klass)
5
+ klass.extend(ClassMethods)
6
+ end
7
+
8
+ module ClassMethods
9
+ def resources(name)
10
+ require_relative "api/#{name}"
11
+
12
+ class_eval <<-CODE, __FILE__, __LINE__ + 1
13
+ def #{name}
14
+ @#{name} ||= Struct.new(:client) do
15
+ include ::RongCloud::API::#{name.to_s.capitalize}
16
+ end.new(client)
17
+ end
18
+ CODE
19
+ end
20
+
21
+ def member(url, options = {})
22
+ meth = if options[:as]
23
+ options[:as]
24
+ else
25
+ resources_name = name.split("::").last.downcase
26
+ resources_name_in_url = "/#{resources_name}/"
27
+ raise ArgumentError unless url.start_with?(resources_name_in_url)
28
+ url.delete_prefix(resources_name_in_url)
29
+ .delete_suffix(".json")
30
+ .tr("/", "_")
31
+ .downcase
32
+ end
33
+
34
+ format = options[:format] || :form
35
+ define_method(meth) do |payload|
36
+ client.post(url, format => payload)
37
+ end
38
+ end
39
+ end
40
+ end
41
+
42
+ include Resourceable
43
+
44
+ resources :chatroom
45
+ resources :conversation
46
+ resources :group
47
+ resources :jwt
48
+ resources :message
49
+ resources :push
50
+ resources :sensitiveword
51
+ resources :stat
52
+ resources :statusmessage
53
+ resources :ultragroup
54
+ resources :user
55
+ end
56
+ end
@@ -0,0 +1,25 @@
1
+ module RongCloud
2
+ class Client
3
+ extend Forwardable
4
+
5
+ attr_reader :app_key, :app_secret
6
+
7
+ def_delegators :@http, :post
8
+
9
+ def initialize(options)
10
+ @app_key = options.fetch(:app_key)
11
+ @app_secret = options.fetch(:app_secret)
12
+ @http = Http.new(
13
+ self,
14
+ host: options.fetch(:host),
15
+ options: options[:http] || {}
16
+ )
17
+ end
18
+
19
+ def api
20
+ @api ||= Struct.new(:client) do
21
+ include ::RongCloud::API
22
+ end.new(self)
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,12 @@
1
+ module RongCloud
2
+ class Exceptions
3
+ # Generic error
4
+ Error = Class.new(StandardError)
5
+
6
+ # Generic HTTP error
7
+ HttpError = Class.new(Error)
8
+
9
+ # Generic API error, non 200 response code
10
+ APIError = Class.new(Error)
11
+ end
12
+ end
@@ -0,0 +1,96 @@
1
+ module RongCloud
2
+ class Http
3
+ def initialize(client, options)
4
+ @client = client
5
+ @host = options.fetch(:host)
6
+ @options = options.fetch(:options)
7
+ end
8
+
9
+ def post(path, options)
10
+ request(:post, path, options)
11
+ end
12
+
13
+ private
14
+
15
+ def request(verb, path, options)
16
+ uri = uri_for(path)
17
+
18
+ nonce = random_str(16)
19
+ timestamp = (Time.now.to_f * 1000).to_i.to_s
20
+ options[:headers] = {
21
+ "RC-App-Key" => @client.app_key,
22
+ "RC-Nonce" => nonce,
23
+ "RC-Timestamp" => timestamp,
24
+ "RC-Signature" => Signer.generate({
25
+ app_secret: @client.app_secret,
26
+ nonce: nonce,
27
+ timestamp: timestamp
28
+ })
29
+ }
30
+
31
+ begin
32
+ response = http(@options).request(verb, uri, options)
33
+ rescue HTTP::Error => e
34
+ raise RongCloud::Exceptions::HttpError, e.message
35
+ end
36
+
37
+ parse_response(response) do |parse_as, result|
38
+ case parse_as
39
+ when :json
40
+ break result if result["code"] == 200
41
+ raise RongCloud::Exceptions::APIError, result["errorMessage"]
42
+ else
43
+ result
44
+ end
45
+ end
46
+ end
47
+
48
+ def uri_for(path)
49
+ uri_options = {scheme: "https", host: @host, path: path}
50
+ Addressable::URI.new(uri_options)
51
+ end
52
+
53
+ def random_str(str_size)
54
+ chars = [*("a".."z"), *("A".."Z"), *("0".."9")]
55
+ chars.sample(str_size).join
56
+ end
57
+
58
+ def http(options)
59
+ HTTP::Client.new(HTTP::Options.new(options))
60
+ end
61
+
62
+ def parse_response(response)
63
+ content_type = response.headers[:content_type]
64
+ parse_as = {
65
+ %r{^application/json} => :json,
66
+ %r{^text/plain} => :plain
67
+ }.each_with_object([]) { |match, memo| memo << match[1] if content_type&.match?(match[0]) }.first || :plain
68
+
69
+ if parse_as == :plain
70
+ result = begin
71
+ parse_json_response(response)
72
+ rescue
73
+ nil
74
+ end
75
+ if result
76
+ return yield(:json, result)
77
+ else
78
+ return yield(:plain, response.body)
79
+ end
80
+ end
81
+
82
+ result = case parse_as
83
+ when :json
84
+ parse_json_response(response)
85
+ else
86
+ response.body
87
+ end
88
+
89
+ yield(parse_as, result)
90
+ end
91
+
92
+ def parse_json_response(response)
93
+ JSON.parse(response.body.to_s)
94
+ end
95
+ end
96
+ end
@@ -0,0 +1,15 @@
1
+ module RongCloud
2
+ class Signer
3
+ def self.generate(params)
4
+ app_secret = params.fetch(:app_secret)
5
+ nonce = params.fetch(:nonce)
6
+ timestamp = params.fetch(:timestamp)
7
+ string = "#{app_secret}#{nonce}#{timestamp}"
8
+ Digest::SHA1.hexdigest(string)
9
+ end
10
+
11
+ def self.verify?(params)
12
+ params.fetch(:signature) == generate(params)
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,3 @@
1
+ module RongCloud
2
+ VERSION = "1.0.1"
3
+ end
data/lib/rongcloud.rb ADDED
@@ -0,0 +1,9 @@
1
+ require "forwardable"
2
+ require "http"
3
+
4
+ require_relative "rongcloud/api"
5
+ require_relative "rongcloud/client"
6
+ require_relative "rongcloud/exceptions"
7
+ require_relative "rongcloud/http"
8
+ require_relative "rongcloud/signer"
9
+ require_relative "rongcloud/version"
metadata ADDED
@@ -0,0 +1,92 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rongcloud-server-sdk
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.1
5
+ platform: ruby
6
+ authors:
7
+ - John Doe
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2022-10-13 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: http
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '5.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '5.0'
27
+ description: RongCloud Server SDK in Ruby.
28
+ email:
29
+ - johndoe@example.com
30
+ executables: []
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - ".editorconfig"
35
+ - ".overcommit.yml"
36
+ - ".rspec"
37
+ - ".rubocop"
38
+ - ".rubocop.yml"
39
+ - ".ruby-version"
40
+ - ".yardopts"
41
+ - CODE_OF_CONDUCT.md
42
+ - Gemfile
43
+ - Gemfile.lock
44
+ - LICENSE.txt
45
+ - README.md
46
+ - Rakefile
47
+ - lib/rongcloud.rb
48
+ - lib/rongcloud/api.rb
49
+ - lib/rongcloud/api/chatroom.rb
50
+ - lib/rongcloud/api/conversation.rb
51
+ - lib/rongcloud/api/group.rb
52
+ - lib/rongcloud/api/jwt.rb
53
+ - lib/rongcloud/api/message.rb
54
+ - lib/rongcloud/api/push.rb
55
+ - lib/rongcloud/api/sensitiveword.rb
56
+ - lib/rongcloud/api/stat.rb
57
+ - lib/rongcloud/api/statusmessage.rb
58
+ - lib/rongcloud/api/ultragroup.rb
59
+ - lib/rongcloud/api/user.rb
60
+ - lib/rongcloud/client.rb
61
+ - lib/rongcloud/exceptions.rb
62
+ - lib/rongcloud/http.rb
63
+ - lib/rongcloud/signer.rb
64
+ - lib/rongcloud/version.rb
65
+ homepage: https://github.com/souk4711/rongcloud-server-sdk-ruby
66
+ licenses:
67
+ - MIT
68
+ metadata:
69
+ homepage_uri: https://github.com/souk4711/rongcloud-server-sdk-ruby
70
+ source_code_uri: https://github.com/souk4711/rongcloud-server-sdk-ruby
71
+ changelog_uri: https://github.com/souk4711/rongcloud-server-sdk-ruby
72
+ rubygems_mfa_required: 'true'
73
+ post_install_message:
74
+ rdoc_options: []
75
+ require_paths:
76
+ - lib
77
+ required_ruby_version: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - ">="
80
+ - !ruby/object:Gem::Version
81
+ version: 2.7.0
82
+ required_rubygems_version: !ruby/object:Gem::Requirement
83
+ requirements:
84
+ - - ">="
85
+ - !ruby/object:Gem::Version
86
+ version: '0'
87
+ requirements: []
88
+ rubygems_version: 3.3.7
89
+ signing_key:
90
+ specification_version: 4
91
+ summary: RongCloud Server SDK in Ruby.
92
+ test_files: []