streamsb 0.1.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: 45b92014d373523ec893250475955c1bc1eea0e65bcbbe6e5bd92b003bb1e9c5
4
+ data.tar.gz: 933c8d8fcca5cfb6164e3f15d3944f13977a0b0e0bf72e0e79d817d90625516f
5
+ SHA512:
6
+ metadata.gz: d8e445b2e2d3475936456140108a1735fbe2fcfbe3472abcd0b6aa7b581dd021d24876ac2bd7821330d8fcf589200838d482c604c9a1fcc449b60b5e00ba0158
7
+ data.tar.gz: 50641ab9ca0cc10e64fd4f0b5e45bcb1776c8e780359c1a76a317ae2fcc42bfc774de7620ce147b9075f7c313c283c3279f6d22aef76915aaae9a8ab740c3eef
data/.rubocop.yml ADDED
@@ -0,0 +1,13 @@
1
+ AllCops:
2
+ TargetRubyVersion: 2.6
3
+
4
+ Style/StringLiterals:
5
+ Enabled: true
6
+ EnforcedStyle: double_quotes
7
+
8
+ Style/StringLiteralsInInterpolation:
9
+ Enabled: true
10
+ EnforcedStyle: double_quotes
11
+
12
+ Layout/LineLength:
13
+ Max: 120
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ ## [Unreleased]
2
+
3
+ ## [0.1.0] - 2022-12-24
4
+
5
+ - Initial release
@@ -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 ochiengotieno71@gmail.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,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in streamsb.gemspec
6
+ gemspec
7
+
8
+ gem "rake", "~> 13.0"
9
+
10
+ gem "minitest", "~> 5.0"
11
+
12
+ gem "rubocop", "~> 1.21"
data/Gemfile.lock ADDED
@@ -0,0 +1,74 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ streamsb (0.1.1)
5
+ faraday (~> 1.7)
6
+ faraday_middleware (~> 1.2)
7
+ json
8
+
9
+ GEM
10
+ remote: https://rubygems.org/
11
+ specs:
12
+ ast (2.4.2)
13
+ faraday (1.10.2)
14
+ faraday-em_http (~> 1.0)
15
+ faraday-em_synchrony (~> 1.0)
16
+ faraday-excon (~> 1.1)
17
+ faraday-httpclient (~> 1.0)
18
+ faraday-multipart (~> 1.0)
19
+ faraday-net_http (~> 1.0)
20
+ faraday-net_http_persistent (~> 1.0)
21
+ faraday-patron (~> 1.0)
22
+ faraday-rack (~> 1.0)
23
+ faraday-retry (~> 1.0)
24
+ ruby2_keywords (>= 0.0.4)
25
+ faraday-em_http (1.0.0)
26
+ faraday-em_synchrony (1.0.0)
27
+ faraday-excon (1.1.0)
28
+ faraday-httpclient (1.0.1)
29
+ faraday-multipart (1.0.4)
30
+ multipart-post (~> 2)
31
+ faraday-net_http (1.0.1)
32
+ faraday-net_http_persistent (1.2.0)
33
+ faraday-patron (1.0.0)
34
+ faraday-rack (1.0.0)
35
+ faraday-retry (1.0.3)
36
+ faraday_middleware (1.2.0)
37
+ faraday (~> 1.0)
38
+ json (2.6.2)
39
+ minitest (5.16.3)
40
+ multipart-post (2.2.3)
41
+ parallel (1.22.1)
42
+ parser (3.1.2.1)
43
+ ast (~> 2.4.1)
44
+ rainbow (3.1.1)
45
+ rake (13.0.6)
46
+ regexp_parser (2.6.1)
47
+ rexml (3.2.5)
48
+ rubocop (1.39.0)
49
+ json (~> 2.3)
50
+ parallel (~> 1.10)
51
+ parser (>= 3.1.2.1)
52
+ rainbow (>= 2.2.2, < 4.0)
53
+ regexp_parser (>= 1.8, < 3.0)
54
+ rexml (>= 3.2.5, < 4.0)
55
+ rubocop-ast (>= 1.23.0, < 2.0)
56
+ ruby-progressbar (~> 1.7)
57
+ unicode-display_width (>= 1.4.0, < 3.0)
58
+ rubocop-ast (1.23.0)
59
+ parser (>= 3.1.1.0)
60
+ ruby-progressbar (1.11.0)
61
+ ruby2_keywords (0.0.5)
62
+ unicode-display_width (2.3.0)
63
+
64
+ PLATFORMS
65
+ x86_64-linux
66
+
67
+ DEPENDENCIES
68
+ minitest (~> 5.0)
69
+ rake (~> 13.0)
70
+ rubocop (~> 1.21)
71
+ streamsb!
72
+
73
+ BUNDLED WITH
74
+ 2.3.22
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2022 Ochieng Otieno
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,121 @@
1
+ # Streamsb Ruby Client
2
+
3
+ ## Installation
4
+
5
+ Install the gem and add to the application's Gemfile by executing:
6
+
7
+ bundle add streamsb
8
+
9
+ If bundler is not being used to manage dependencies, install the gem by executing:
10
+
11
+ gem install streamsb
12
+
13
+ ## Usage
14
+
15
+ ### Initialize Streamsb Client
16
+
17
+ ```ruby
18
+ require "streamsb"
19
+
20
+ @client = Streamsb::Client.new(api_key: ENV['STREAMSB_API_KEY'])
21
+ ```
22
+
23
+ Make API calls using the @client object
24
+
25
+ ### 1. Account
26
+
27
+ #### 1.1 Info
28
+
29
+ ```ruby
30
+ account_info = @client.account_info
31
+ ```
32
+
33
+ #### 1.2 Stats
34
+
35
+ ```ruby
36
+ account_info = @client.account_stats
37
+ ```
38
+
39
+ ### 2. File
40
+
41
+ #### 2.1 File Info
42
+
43
+ ```ruby
44
+ file_info = @client.file_info(file_code)
45
+ ```
46
+
47
+ - `file_code`: file code `REQUIRED`
48
+
49
+ #### 2.2 Rename File
50
+
51
+ ```ruby
52
+ rename_file = @client.rename_file(file_code, title, name)
53
+ ```
54
+
55
+ - `file_code`: file code `REQUIRED`
56
+ - `title`: new file title `REQUIRED`
57
+ - `name`: new file name `REQUIRED`
58
+
59
+ #### 2.3 Clone File
60
+
61
+ ```ruby
62
+ clone_info = @client.clone_file(file_code)
63
+ ```
64
+
65
+ - `file_code`: file code `REQUIRED`
66
+
67
+ #### 2.4 List Files
68
+
69
+ ```ruby
70
+ file_list = @client.list_files(page, per_page, fld_id, is_public, created, title)
71
+
72
+ ```
73
+
74
+ - `page`: page number `OPTIONAL`,
75
+ - `per_page`: results per page `OPTIONAL`
76
+ - `fld_id`: folder id `OPTIONAL`
77
+ - `is_public`: show public (1) or private (0) files only `OPTIONAL`
78
+ - `created`: show only files uploaded after timestamp `OPTIONAL`
79
+ - `title`: filter video titles `OPTIONAL`
80
+
81
+ #### 2.5 Get Direct All
82
+
83
+ ```ruby
84
+ direct_all = @client.get_direct_all(file_code)
85
+ ```
86
+
87
+ - `file_code`: file code `REQUIRED`
88
+
89
+ #### 2.6 Get Direct Quality
90
+
91
+ ```ruby
92
+ direct_quality = @client.get_direct_quality(file_code, quality)
93
+ ```
94
+
95
+ - `file_code`: file code `REQUIRED`
96
+ - `quality`: video quality if exist, possible values: `n` , `h` , `l` `OPTIONAL`
97
+
98
+ ```ruby
99
+ set_folder = @client.set_folder(file_code, folder_id)
100
+ ```
101
+
102
+ - `file_code`: file code `REQUIRED`
103
+ - `folder_id`: folder id `REQUIRED`
104
+
105
+ ## Development
106
+
107
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
108
+
109
+ 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).
110
+
111
+ ## Contributing
112
+
113
+ Bug reports and pull requests are welcome on GitHub at <https://github.com/[USERNAME>]/streamsb. 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/[USERNAME]/streamsb/blob/main/CODE_OF_CONDUCT.md).
114
+
115
+ ## License
116
+
117
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
118
+
119
+ ## Code of Conduct
120
+
121
+ Everyone interacting in the Streamsb project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/streamsb/blob/main/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rake/testtask"
5
+
6
+ Rake::TestTask.new(:test) do |t|
7
+ t.libs << "test"
8
+ t.libs << "lib"
9
+ t.test_files = FileList["test/**/test_*.rb"]
10
+ end
11
+
12
+ require "rubocop/rake_task"
13
+
14
+ RuboCop::RakeTask.new
15
+
16
+ task default: %i[test rubocop]
@@ -0,0 +1,121 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "faraday"
4
+ require "faraday_middleware"
5
+ require "json"
6
+
7
+ module Streamsb
8
+ class Client
9
+ API_ENDPOINT = "https://api.streamsb.com/api"
10
+
11
+ attr_reader :api_key, :adapter
12
+
13
+ def initialize(api_key:, adapter: Faraday.default_adapter)
14
+ @api_key = api_key
15
+ @adapter = adapter
16
+ end
17
+
18
+ def account_info
19
+ data = {
20
+ key: api_key
21
+ }
22
+ request(http_method: :get, endpoint: "account/info", params: data)
23
+ end
24
+
25
+ def account_stats
26
+ data = {
27
+ key: api_key
28
+ }
29
+ request(http_method: :get, endpoint: "account/stats", params: data)
30
+ end
31
+
32
+ def file_info(file_code)
33
+ data = {
34
+ key: api_key,
35
+ file_code: file_code
36
+ }
37
+ request(http_method: :get, endpoint: "file/info", params: data)
38
+ end
39
+
40
+ def rename_file(file_code, title, name)
41
+ data = {
42
+ key: api_key,
43
+ file_code: file_code,
44
+ title: title,
45
+ name: name
46
+ }
47
+ request(http_method: :get, endpoint: "file/rename", params: data)
48
+ end
49
+
50
+ def clone_file(file_code)
51
+ data = {
52
+ key: api_key,
53
+ file_code: file_code
54
+ }
55
+ request(http_method: :get, endpoint: "file/clone", params: data)
56
+ end
57
+
58
+ def list_files(page = nil, per_page = nil, fld_id = nil, is_public = nil, created = nil, title = nil)
59
+ data = {
60
+ key: api_key,
61
+ page: page,
62
+ per_page: per_page,
63
+ fld_id: fld_id,
64
+ public: is_public,
65
+ created: created,
66
+ title: title
67
+ }
68
+
69
+ request(http_method: :get, endpoint: "file/list", params: data)
70
+ end
71
+
72
+ def get_direct_all(file_code)
73
+ data = {
74
+ key: api_key,
75
+ file_code: file_code
76
+ }
77
+
78
+ request(http_method: :get, endpoint: "file/direct", params: data)
79
+ end
80
+
81
+ def get_direct_quality(file_code, quality = nil)
82
+ data = {
83
+ key: api_key,
84
+ file_code: file_code,
85
+ q: quality
86
+ }
87
+
88
+ request(http_method: :get, endpoint: "file/direct_link", params: data)
89
+ end
90
+
91
+ def set_folder(file_code, folder_id)
92
+ data = {
93
+ key: api_key,
94
+ file_code: file_code,
95
+ folder_id: folder_id
96
+ }
97
+
98
+ request(http_method: :get, endpoint: "file/set_folder", params: data)
99
+ end
100
+
101
+ def inspect
102
+ "#<Streamsb::Client>"
103
+ end
104
+
105
+ private
106
+
107
+ def connection
108
+ @connection ||= Faraday.new do |conn|
109
+ conn.url_prefix = API_ENDPOINT
110
+ conn.request :json
111
+ conn.response :json, content_type: "application/json"
112
+ conn.adapter adapter
113
+ end
114
+ end
115
+
116
+ def request(http_method:, endpoint:, params: { key: api_key })
117
+ response = connection.send(http_method, endpoint, params)
118
+ OpenStruct.new(response.body)
119
+ end
120
+ end
121
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Streamsb
4
+ class Error < StandardError; end
5
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Streamsb
4
+ VERSION = "0.1.1"
5
+ end
data/lib/streamsb.rb ADDED
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "streamsb/version"
4
+
5
+ module Streamsb
6
+ autoload :Client, "streamsb/client"
7
+ autoload :Error, "streamsb/error"
8
+ end
metadata ADDED
@@ -0,0 +1,100 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: streamsb
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - Ochieng Otieno
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2022-12-24 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: faraday
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.7'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.7'
27
+ - !ruby/object:Gem::Dependency
28
+ name: faraday_middleware
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.2'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.2'
41
+ - !ruby/object:Gem::Dependency
42
+ name: json
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: StreamSB ruby client
56
+ email:
57
+ - ochiengotieno71@gmail.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - ".rubocop.yml"
63
+ - CHANGELOG.md
64
+ - CODE_OF_CONDUCT.md
65
+ - Gemfile
66
+ - Gemfile.lock
67
+ - LICENSE.txt
68
+ - README.md
69
+ - Rakefile
70
+ - lib/streamsb.rb
71
+ - lib/streamsb/client.rb
72
+ - lib/streamsb/error.rb
73
+ - lib/streamsb/version.rb
74
+ homepage: https://github.com/ochiengotieno304/streamsb-ruby
75
+ licenses:
76
+ - MIT
77
+ metadata:
78
+ homepage_uri: https://github.com/ochiengotieno304/streamsb-ruby
79
+ source_code_uri: https://github.com/ochiengotieno304/streamsb-ruby
80
+ changelog_uri: https://github.com/ochiengotieno304/streamsb-ruby/CHANGELOG.md
81
+ post_install_message:
82
+ rdoc_options: []
83
+ require_paths:
84
+ - lib
85
+ required_ruby_version: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: 2.6.0
90
+ required_rubygems_version: !ruby/object:Gem::Requirement
91
+ requirements:
92
+ - - ">="
93
+ - !ruby/object:Gem::Version
94
+ version: '0'
95
+ requirements: []
96
+ rubygems_version: 3.3.7
97
+ signing_key:
98
+ specification_version: 4
99
+ summary: StreamSB ruby client
100
+ test_files: []