chatoperastore 0.0.8
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 +7 -0
- data/.env.sample +1 -0
- data/.rspec +3 -0
- data/.rubocop.yml +13 -0
- data/CONTRIBUTING.md +31 -0
- data/LICENSE +14 -0
- data/README.md +22 -0
- data/Rakefile +12 -0
- data/chatoperastore.gemspec +47 -0
- data/lib/chatoperastore/errors.rb +22 -0
- data/lib/chatoperastore/requests.rb +41 -0
- data/lib/chatoperastore/version.rb +5 -0
- data/lib/chatoperastore.rb +65 -0
- data/sig/chatoperastore.rbs +4 -0
- metadata +72 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 105d1b144172c1469aba86b943959f2f1f140dc948e7b2b1edd874bb71575765
|
|
4
|
+
data.tar.gz: d2b7b2e64555f215f86df00286bd3040da8e901e41b440d10e49c9c7c336c2a1
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: ab61f884119e338abb1e3393efa86044d3961fb9b80a93b3be9425e2347f9cc8467931a47d17ca54ff3039b2ef71178ef6009ece4744bb72bcadb11def36b56f
|
|
7
|
+
data.tar.gz: e0ae7f8910117c711356e59f16fbe18685960f7c0aef65613b9ffb832a0d0a47a2f7df03e86bc5915d3617b609f6b41d77511baf7fe8074f81c890a6fb1d3b5e
|
data/.env.sample
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
LICENSE_STORE_PROVIDER=https://store.chatopera.com
|
data/.rspec
ADDED
data/.rubocop.yml
ADDED
data/CONTRIBUTING.md
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# Chatoperastore
|
|
2
|
+
|
|
3
|
+
TODO: Delete this and the text below, and describe your gem
|
|
4
|
+
|
|
5
|
+
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/chatoperastore`. To experiment with that code, run `bin/console` for an interactive prompt.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
TODO: Replace `UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG` with your gem name right after releasing it to RubyGems.org. Please do not do it earlier due to security reasons. Alternatively, replace this section with instructions to install your gem from git if you don't plan to release to RubyGems.org.
|
|
10
|
+
|
|
11
|
+
Install the gem and add to the application's Gemfile by executing:
|
|
12
|
+
|
|
13
|
+
$ bundle add UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG
|
|
14
|
+
|
|
15
|
+
If bundler is not being used to manage dependencies, install the gem by executing:
|
|
16
|
+
|
|
17
|
+
$ gem install UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG
|
|
18
|
+
|
|
19
|
+
## Usage
|
|
20
|
+
|
|
21
|
+
TODO: Write usage instructions here
|
|
22
|
+
|
|
23
|
+
## Development
|
|
24
|
+
|
|
25
|
+
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.
|
|
26
|
+
|
|
27
|
+
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).
|
|
28
|
+
|
|
29
|
+
## Contributing
|
|
30
|
+
|
|
31
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/chatoperastore.
|
data/LICENSE
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
Copyright 2023 Beijing Huaxia Chunsong Technology Co., Ltd. <https://www.chatopera.com>
|
|
2
|
+
|
|
3
|
+
Licensed under the Chunsong Public License, Version 1.0 (the "License");
|
|
4
|
+
you may not use this file except in compliance with the License.
|
|
5
|
+
You may obtain a copy of the License at
|
|
6
|
+
|
|
7
|
+
https://docs.cskefu.com/licenses/v1.html
|
|
8
|
+
|
|
9
|
+
Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
See the License for the specific language governing permissions and
|
|
13
|
+
limitations under the License.
|
|
14
|
+
|
data/README.md
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# Chatopera Store Ruby SDK
|
|
2
|
+
Your Software Subscription Management Service, e.g. billing, invoices.
|
|
3
|
+
|
|
4
|
+
https://store.chatopera.com
|
|
5
|
+
|
|
6
|
+
Docs: https://readthe.gitee.io/store-docs/
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
## Contribution
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
cp .env.sample .env
|
|
13
|
+
# edit .env file
|
|
14
|
+
./bin/setup # install deps
|
|
15
|
+
./bin/test.sh # run tests
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
Release new version, `bin/release.sh`, this script would build, push gem from source codes.
|
|
19
|
+
|
|
20
|
+
## License
|
|
21
|
+
|
|
22
|
+
[Chunsong Public License, Version 1.0](./LICENSE)
|
data/Rakefile
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "lib/chatoperastore/version"
|
|
4
|
+
require 'pp'
|
|
5
|
+
|
|
6
|
+
Gem::Specification.new do |spec|
|
|
7
|
+
spec.name = "chatoperastore"
|
|
8
|
+
spec.version = Chatoperastore::VERSION
|
|
9
|
+
spec.authors = ["Hai Liang Wang"]
|
|
10
|
+
spec.email = ["hai@chatopera.com"]
|
|
11
|
+
spec.license = 'Chunsong Public License, version 1.0'
|
|
12
|
+
spec.summary = "Ruby SDK of Chatopera Store, https://store.chatopera.com"
|
|
13
|
+
spec.description = <<-EOS
|
|
14
|
+
## TBD, a draft version.
|
|
15
|
+
## License Chunsong Public License, version 1.0
|
|
16
|
+
https://www.cskefu.com/licenses/v1.html
|
|
17
|
+
EOS
|
|
18
|
+
|
|
19
|
+
spec.homepage = "https://readthe.gitee.io/store-docs/"
|
|
20
|
+
spec.required_ruby_version = ">= 2.6.0"
|
|
21
|
+
|
|
22
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
|
23
|
+
|
|
24
|
+
# Specify which files should be added to the gem when it is released.
|
|
25
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
|
26
|
+
spec.files = Dir.chdir(__dir__) do
|
|
27
|
+
`git ls-files -z`.split("\x0").reject do |f|
|
|
28
|
+
(File.expand_path(f) == __FILE__) ||
|
|
29
|
+
f.start_with?(*%w[bin/ test/ spec/ features/ .git appveyor Gemfile chatoperastore-])
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
puts "Packing files ..."
|
|
33
|
+
pp spec.files
|
|
34
|
+
puts ""
|
|
35
|
+
|
|
36
|
+
spec.bindir = "exe"
|
|
37
|
+
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
|
38
|
+
spec.require_paths = ["lib"]
|
|
39
|
+
|
|
40
|
+
# Uncomment to register a new dependency of your gem
|
|
41
|
+
# spec.add_dependency "example-gem", "~> 1.0"
|
|
42
|
+
|
|
43
|
+
# For more information and examples about making a new gem, check out our
|
|
44
|
+
# guide at: https://bundler.io/guides/creating_gem.html
|
|
45
|
+
#
|
|
46
|
+
spec.add_development_dependency 'dotenv', '~> 2.5'
|
|
47
|
+
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Copyright (c) 2023. Beijing Huaxia Chunsong Technology Co., Ltd. <https://www.chatopera.com>
|
|
4
|
+
#
|
|
5
|
+
# Licensed under the Chunsong Public License, Version 1.0 (the "License");
|
|
6
|
+
# you may not use this file except in compliance with the License.
|
|
7
|
+
# You may obtain a copy of the License at
|
|
8
|
+
#
|
|
9
|
+
# https://docs.cskefu.com/licenses/v1.html
|
|
10
|
+
#
|
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
# See the License for the specific language governing permissions and
|
|
15
|
+
# limitations under the License.
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
module Chatoperastore
|
|
19
|
+
class InvalidProviderError < StandardError; end
|
|
20
|
+
class InvalidStoreResponseError < StandardError; end
|
|
21
|
+
|
|
22
|
+
end
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# Copyright (c) 2023. Beijing Huaxia Chunsong Technology Co., Ltd. <https://www.chatopera.com>
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Chunsong Public License, Version 1.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# https://docs.cskefu.com/licenses/v1.html
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
|
|
15
|
+
require "net/http"
|
|
16
|
+
require "net/https"
|
|
17
|
+
require "openssl"
|
|
18
|
+
require 'json'
|
|
19
|
+
require_relative 'errors'
|
|
20
|
+
|
|
21
|
+
module Chatoperastore
|
|
22
|
+
|
|
23
|
+
module Requests
|
|
24
|
+
def getRequestBypassSSLChecks(url, **params)
|
|
25
|
+
uri = URI(url)
|
|
26
|
+
req = Net::HTTP::Get.new(uri.path)
|
|
27
|
+
res = Net::HTTP.start(
|
|
28
|
+
uri.host, uri.port,
|
|
29
|
+
:use_ssl => uri.scheme == 'https',
|
|
30
|
+
:verify_mode => OpenSSL::SSL::VERIFY_NONE) do |https|
|
|
31
|
+
https.request(req)
|
|
32
|
+
end
|
|
33
|
+
if res.code == "200"
|
|
34
|
+
return JSON.parse(res.body)
|
|
35
|
+
else
|
|
36
|
+
raise Chatoperastore::InvalidStoreResponseError.new "Invalid resp code " + res.code
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
end
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Copyright (c) 2023. Beijing Huaxia Chunsong Technology Co., Ltd. <https://www.chatopera.com>
|
|
4
|
+
#
|
|
5
|
+
# Licensed under the Chunsong Public License, Version 1.0 (the "License");
|
|
6
|
+
# you may not use this file except in compliance with the License.
|
|
7
|
+
# You may obtain a copy of the License at
|
|
8
|
+
#
|
|
9
|
+
# https://docs.cskefu.com/licenses/v1.html
|
|
10
|
+
#
|
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
# See the License for the specific language governing permissions and
|
|
15
|
+
# limitations under the License.
|
|
16
|
+
|
|
17
|
+
require 'net/http'
|
|
18
|
+
require 'net/https'
|
|
19
|
+
require 'openssl'
|
|
20
|
+
require_relative "chatoperastore/version"
|
|
21
|
+
require_relative "chatoperastore/errors"
|
|
22
|
+
require_relative "chatoperastore/requests"
|
|
23
|
+
|
|
24
|
+
module Chatoperastore
|
|
25
|
+
|
|
26
|
+
LICENSE_STORE_PROVIDER = "LICENSE_STORE_PROVIDER"
|
|
27
|
+
VALID_BASEURLS = %w(https://store.chatopera.com http://localhost:7035)
|
|
28
|
+
BASE_PATH = "/api"
|
|
29
|
+
|
|
30
|
+
class AbstractClient
|
|
31
|
+
|
|
32
|
+
attr_accessor :base_url
|
|
33
|
+
|
|
34
|
+
def initialize
|
|
35
|
+
super
|
|
36
|
+
if ENV.has_key?(LICENSE_STORE_PROVIDER)
|
|
37
|
+
@base_url = ENV[LICENSE_STORE_PROVIDER]
|
|
38
|
+
unless VALID_BASEURLS.include?(@base_url)
|
|
39
|
+
raise InvalidProviderError.new "Invalid Base Url value for chatopera store."
|
|
40
|
+
end
|
|
41
|
+
else
|
|
42
|
+
@base_url = "https://store.chatopera.com"
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
class QuotaWdClient < AbstractClient
|
|
48
|
+
include Chatoperastore::Requests
|
|
49
|
+
|
|
50
|
+
def initialize
|
|
51
|
+
super
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def getLicenseBasics(license_id)
|
|
55
|
+
req_url = @base_url + BASE_PATH + "/quotawd/license/basics/" + license_id
|
|
56
|
+
resp_body = getRequestBypassSSLChecks(req_url)
|
|
57
|
+
if resp_body.include?("rc")
|
|
58
|
+
return resp_body
|
|
59
|
+
else
|
|
60
|
+
raise InvalidStoreResponseError.new "Invalid response"
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
end
|
|
65
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: chatoperastore
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.0.8
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Hai Liang Wang
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: exe
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2023-11-30 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: dotenv
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - "~>"
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '2.5'
|
|
20
|
+
type: :development
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - "~>"
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '2.5'
|
|
27
|
+
description: " ## TBD, a draft version. \n ## License Chunsong Public License,
|
|
28
|
+
version 1.0\n https://www.cskefu.com/licenses/v1.html\n"
|
|
29
|
+
email:
|
|
30
|
+
- hai@chatopera.com
|
|
31
|
+
executables: []
|
|
32
|
+
extensions: []
|
|
33
|
+
extra_rdoc_files: []
|
|
34
|
+
files:
|
|
35
|
+
- ".env.sample"
|
|
36
|
+
- ".rspec"
|
|
37
|
+
- ".rubocop.yml"
|
|
38
|
+
- CONTRIBUTING.md
|
|
39
|
+
- LICENSE
|
|
40
|
+
- README.md
|
|
41
|
+
- Rakefile
|
|
42
|
+
- chatoperastore.gemspec
|
|
43
|
+
- lib/chatoperastore.rb
|
|
44
|
+
- lib/chatoperastore/errors.rb
|
|
45
|
+
- lib/chatoperastore/requests.rb
|
|
46
|
+
- lib/chatoperastore/version.rb
|
|
47
|
+
- sig/chatoperastore.rbs
|
|
48
|
+
homepage: https://readthe.gitee.io/store-docs/
|
|
49
|
+
licenses:
|
|
50
|
+
- Chunsong Public License, version 1.0
|
|
51
|
+
metadata:
|
|
52
|
+
homepage_uri: https://readthe.gitee.io/store-docs/
|
|
53
|
+
post_install_message:
|
|
54
|
+
rdoc_options: []
|
|
55
|
+
require_paths:
|
|
56
|
+
- lib
|
|
57
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
58
|
+
requirements:
|
|
59
|
+
- - ">="
|
|
60
|
+
- !ruby/object:Gem::Version
|
|
61
|
+
version: 2.6.0
|
|
62
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
63
|
+
requirements:
|
|
64
|
+
- - ">="
|
|
65
|
+
- !ruby/object:Gem::Version
|
|
66
|
+
version: '0'
|
|
67
|
+
requirements: []
|
|
68
|
+
rubygems_version: 3.4.22
|
|
69
|
+
signing_key:
|
|
70
|
+
specification_version: 4
|
|
71
|
+
summary: Ruby SDK of Chatopera Store, https://store.chatopera.com
|
|
72
|
+
test_files: []
|