kc-sdk-company 0.1.0

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: f5d1555690c0eaa74645a1f7d7e0196712d89a0a862249ad5eeda7405e937eda
4
+ data.tar.gz: 07bb8c1eb0c5a141e8aca60a1fcec9c2e2ff9cd8f8915de611afc06f11e539f5
5
+ SHA512:
6
+ metadata.gz: 1d5677380db7cb2405c5b463cb49cae15a538dc50abaf26ab266c2da4722f1d20b434c543a0cc2365ab887c2510076279e5e2232940092f65e4fc768ef47e917
7
+ data.tar.gz: 5870048f125bf04a0efa25ef858377b4eabd84df8c72540dbdbae8b8514b6fcdbb67dcacb00a7a084c7f6f98733c104a8f5aa9f390c37b7f9464adb8ab167f52
data/.drone.yml ADDED
@@ -0,0 +1,90 @@
1
+ ---
2
+ kind: pipeline
3
+ name: publish
4
+
5
+ clone:
6
+ depth: 1
7
+
8
+ steps:
9
+ - name: restore-bundle-cache
10
+ image: meltwater/drone-cache:latest
11
+ environment:
12
+ AWS_ACCESS_KEY_ID:
13
+ from_secret: CI_AWS_ACCESS_KEY_ID
14
+ AWS_SECRET_ACCESS_KEY:
15
+ from_secret: CI_AWS_SECRET_ACCESS_KEY
16
+ settings:
17
+ restore: true
18
+ cache_key: '{{ checksum "Gemfile.lock" }}'
19
+ bucket: drone-ci-cache-bucket
20
+ region: ap-northeast-1
21
+ mount:
22
+ - 'vendor/bundle'
23
+
24
+ - name: build
25
+ image: ruby:2-alpine
26
+ commands:
27
+ - apk add --no-cache build-base git
28
+ - gem install bundler:2.3.14
29
+ - bundle install -j4
30
+ - rake build
31
+
32
+ - name: rebuild-bundle-cache
33
+ image: meltwater/drone-cache:latest
34
+ environment:
35
+ AWS_ACCESS_KEY_ID:
36
+ from_secret: CI_AWS_ACCESS_KEY_ID
37
+ AWS_SECRET_ACCESS_KEY:
38
+ from_secret: CI_AWS_SECRET_ACCESS_KEY
39
+ settings:
40
+ rebuild: true
41
+ cache_key: '{{ checksum "Gemfile.lock" }}'
42
+ bucket: drone-ci-cache-bucket
43
+ region: ap-northeast-1
44
+ mount:
45
+ - 'vendor/bundle'
46
+ when:
47
+ status:
48
+ - success
49
+ - failure
50
+
51
+ - name: deployment
52
+ image: ruby:alpine
53
+ environment:
54
+ PUSH_KEY:
55
+ from_secret: PUSH_KEY
56
+ commands:
57
+ - mkdir -p ~/.gem
58
+ - touch ~/.gem/credentials
59
+ - echo -e "$PUSH_KEY" > ~/.gem/credentials
60
+ - chmod 0600 ~/.gem/credentials
61
+ - gem push --key push_key pkg/*.gem
62
+
63
+ trigger:
64
+ event:
65
+ - tag
66
+
67
+ ---
68
+ kind: pipeline
69
+ name: after
70
+
71
+ clone:
72
+ disable: true
73
+
74
+ steps:
75
+ - name: notify
76
+ image: plugins/slack
77
+ settings:
78
+ icon_emoji: ":rocket:"
79
+ webhook:
80
+ from_secret: SLACK_WEBHOOK
81
+
82
+ depends_on:
83
+ - publish
84
+
85
+ trigger:
86
+ event:
87
+ - tag
88
+ status:
89
+ - success
90
+ - failure
data/.gitignore ADDED
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.travis.yml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ sudo: false
3
+ language: ruby
4
+ cache: bundler
5
+ rvm:
6
+ - 2.3.4
7
+ before_install: gem install bundler -v 2.0.1
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ # Change Log
2
+
3
+ ## v0.1.0 / 2022-08-21
4
+ ### Added
5
+ - Create project
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in kc-sdk-company.gemspec
4
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,65 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ kc-sdk-company (0.1.0)
5
+ rest-client
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ diff-lcs (1.5.0)
11
+ docile (1.4.0)
12
+ domain_name (0.5.20190701)
13
+ unf (>= 0.0.5, < 1.0.0)
14
+ http-accept (1.7.0)
15
+ http-cookie (1.0.5)
16
+ domain_name (~> 0.5)
17
+ mime-types (3.4.1)
18
+ mime-types-data (~> 3.2015)
19
+ mime-types-data (3.2022.0105)
20
+ netrc (0.11.0)
21
+ rake (10.5.0)
22
+ rest-client (2.1.0)
23
+ http-accept (>= 1.7.0, < 2.0)
24
+ http-cookie (>= 1.0.2, < 2.0)
25
+ mime-types (>= 1.16, < 4.0)
26
+ netrc (~> 0.8)
27
+ rspec (3.11.0)
28
+ rspec-core (~> 3.11.0)
29
+ rspec-expectations (~> 3.11.0)
30
+ rspec-mocks (~> 3.11.0)
31
+ rspec-core (3.11.0)
32
+ rspec-support (~> 3.11.0)
33
+ rspec-expectations (3.11.0)
34
+ diff-lcs (>= 1.2.0, < 2.0)
35
+ rspec-support (~> 3.11.0)
36
+ rspec-its (1.3.0)
37
+ rspec-core (>= 3.0.0)
38
+ rspec-expectations (>= 3.0.0)
39
+ rspec-mocks (3.11.1)
40
+ diff-lcs (>= 1.2.0, < 2.0)
41
+ rspec-support (~> 3.11.0)
42
+ rspec-support (3.11.0)
43
+ simplecov (0.21.2)
44
+ docile (~> 1.1)
45
+ simplecov-html (~> 0.11)
46
+ simplecov_json_formatter (~> 0.1)
47
+ simplecov-html (0.12.3)
48
+ simplecov_json_formatter (0.1.4)
49
+ unf (0.1.4)
50
+ unf_ext
51
+ unf_ext (0.0.8.2)
52
+
53
+ PLATFORMS
54
+ ruby
55
+
56
+ DEPENDENCIES
57
+ bundler (~> 2.0)
58
+ kc-sdk-company!
59
+ rake (~> 10.0)
60
+ rspec (~> 3.0)
61
+ rspec-its
62
+ simplecov (~> 0.21.2)
63
+
64
+ BUNDLED WITH
65
+ 2.3.10
data/README.md ADDED
@@ -0,0 +1,44 @@
1
+ [![Build Status](https://ci.kabob.io/api/badges/kabobcompany/kc-sdk-company-ruby/status.svg)](https://ci.kabob.io/kabobcompany/kc-sdk-company-ruby)
2
+ # kc-sdk-company
3
+ Provides kabob cloud app api client.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'kc-sdk-company'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install kc-sdk-company
20
+
21
+ For rails, create config `config/initializers/kc_sdk_company.rb`
22
+
23
+ ```ruby
24
+ KcSdkCompany.configure do |config|
25
+ # kabob cloud api url, default: https://cloud.kabob.io
26
+ config.api_url = 'https://cloud.kabob.io'
27
+
28
+ # you have to set your app access token
29
+ config.access_token = 'YOUR_COMPANY_ACCESS_TOKEN'
30
+
31
+ # you can set a logger if you want logging api request
32
+ # config.logger = Rails.logger
33
+ end
34
+
35
+ ```
36
+
37
+ ## Usage
38
+
39
+ [Api](#api)
40
+
41
+ ### Api
42
+
43
+ ## Contact
44
+ The project's website is located at https://github.com/kabobcompany/kc-sdk-company-ruby
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "kabob/cloud/client"
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(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,44 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "kc-sdk-company/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "kc-sdk-company"
8
+ spec.version = KcSdkCompany::VERSION
9
+ spec.authors = ["Yi-Cyuan Chen"]
10
+ spec.email = ["emn178@gmail.com"]
11
+
12
+ spec.summary = %q{Kabob cloud client library.}
13
+ spec.description = %q{Kabob cloud client library.}
14
+ spec.homepage = "https://github.com/kabobcompany/kc-sdk-company-ruby"
15
+
16
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
17
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
18
+ if spec.respond_to?(:metadata)
19
+ spec.metadata["allowed_push_host"] = "https://rubygems.org/"
20
+
21
+ spec.metadata["homepage_uri"] = spec.homepage
22
+ spec.metadata["source_code_uri"] = "https://github.com/kabobcompany/kc-sdk-company-ruby"
23
+ spec.metadata["changelog_uri"] = "https://github.com/kabobcompany/kc-sdk-company-ruby/CHANGELOG.md"
24
+ else
25
+ raise "RubyGems 2.0 or newer is required to protect against " \
26
+ "public gem pushes."
27
+ end
28
+
29
+ # Specify which files should be added to the gem when it is released.
30
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
31
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
32
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features|tmp)/}) }
33
+ end
34
+ spec.bindir = "exe"
35
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
36
+ spec.require_paths = ["lib"]
37
+
38
+ spec.add_dependency "rest-client"
39
+ spec.add_development_dependency "bundler", "~> 2.0"
40
+ spec.add_development_dependency "rake", "~> 10.0"
41
+ spec.add_development_dependency "rspec", "~> 3.0"
42
+ spec.add_development_dependency "rspec-its"
43
+ spec.add_development_dependency "simplecov", "~> 0.21.2"
44
+ end
@@ -0,0 +1,19 @@
1
+ module KcSdkCompany
2
+ class Api
3
+ class Base
4
+ def initialize(api)
5
+ @api = api
6
+ end
7
+
8
+ def resource
9
+ @api.resource
10
+ end
11
+
12
+ def validate_keys!(hash, keys)
13
+ keys.each do |k|
14
+ raise ArgumentError, "required keywords: #{keys.join(', ')}" unless hash.key?(k)
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,17 @@
1
+ module KcSdkCompany
2
+ class Api
3
+ class Orders < Base
4
+ def surplus(query)
5
+ validate_keys!(query, %i[company_id plan scope])
6
+ resp = resource['v1/orders/surplus'].get({ params: query })
7
+ JSON.parse(resp.body)
8
+ end
9
+
10
+ def consuming(data)
11
+ validate_keys!(data, %i[company_id plan scope quantity taken_at uid])
12
+ resp = resource['v1/orders/consuming'].post(data)
13
+ JSON.parse(resp.body)
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,20 @@
1
+ require 'kc-sdk-company/api/base'
2
+ require 'kc-sdk-company/api/orders'
3
+
4
+ module KcSdkCompany
5
+ class Api
6
+ attr_accessor :orders
7
+
8
+ def initialize
9
+ self.orders = KcSdkCompany::Api::Orders.new(self)
10
+ end
11
+
12
+ def resource
13
+ @resource ||= RestClient::Resource.new(
14
+ "#{KcSdkCompany.configuration.api_url}/api/company",
15
+ log: KcSdkCompany.configuration.logger,
16
+ headers: { 'Authorization': "Bearer #{KcSdkCompany.configuration.access_token}" }
17
+ )
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,12 @@
1
+ module KcSdkCompany
2
+ class Configuration
3
+ attr_accessor :api_url, :access_token, :logger
4
+
5
+ def initialize(options = {})
6
+ options.each do |key, value|
7
+ instance_variable_set("@#{key}", value)
8
+ end
9
+ @api_url ||= 'https://cloud.kabob.io'
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,4 @@
1
+ module KcSdkCompany
2
+ class Engine < ::Rails::Engine
3
+ end
4
+ end
@@ -0,0 +1,3 @@
1
+ module KcSdkCompany
2
+ VERSION = '0.1.0'.freeze
3
+ end
@@ -0,0 +1,20 @@
1
+ require 'rest-client'
2
+ require 'kc-sdk-company/version'
3
+ require 'kc-sdk-company/configuration'
4
+ require 'kc-sdk-company/api'
5
+
6
+ require 'kc-sdk-company/engine' if defined?(::Rails)
7
+
8
+ module KcSdkCompany
9
+ def self.configure
10
+ yield configuration
11
+ end
12
+
13
+ def self.configuration
14
+ @configuration ||= Configuration.new
15
+ end
16
+
17
+ def self.api
18
+ @api ||= Api.new
19
+ end
20
+ end
metadata ADDED
@@ -0,0 +1,149 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: kc-sdk-company
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Yi-Cyuan Chen
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2022-09-20 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rest-client
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '2.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '2.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '3.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '3.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec-its
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: simplecov
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: 0.21.2
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: 0.21.2
97
+ description: Kabob cloud client library.
98
+ email:
99
+ - emn178@gmail.com
100
+ executables: []
101
+ extensions: []
102
+ extra_rdoc_files: []
103
+ files:
104
+ - ".drone.yml"
105
+ - ".gitignore"
106
+ - ".rspec"
107
+ - ".travis.yml"
108
+ - CHANGELOG.md
109
+ - Gemfile
110
+ - Gemfile.lock
111
+ - README.md
112
+ - Rakefile
113
+ - bin/console
114
+ - bin/setup
115
+ - kc-sdk-app.gemspec
116
+ - lib/kc-sdk-company.rb
117
+ - lib/kc-sdk-company/api.rb
118
+ - lib/kc-sdk-company/api/base.rb
119
+ - lib/kc-sdk-company/api/orders.rb
120
+ - lib/kc-sdk-company/configuration.rb
121
+ - lib/kc-sdk-company/engine.rb
122
+ - lib/kc-sdk-company/version.rb
123
+ homepage: https://github.com/kabobcompany/kc-sdk-company-ruby
124
+ licenses: []
125
+ metadata:
126
+ allowed_push_host: https://rubygems.org/
127
+ homepage_uri: https://github.com/kabobcompany/kc-sdk-company-ruby
128
+ source_code_uri: https://github.com/kabobcompany/kc-sdk-company-ruby
129
+ changelog_uri: https://github.com/kabobcompany/kc-sdk-company-ruby/CHANGELOG.md
130
+ post_install_message:
131
+ rdoc_options: []
132
+ require_paths:
133
+ - lib
134
+ required_ruby_version: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ required_rubygems_version: !ruby/object:Gem::Requirement
140
+ requirements:
141
+ - - ">="
142
+ - !ruby/object:Gem::Version
143
+ version: '0'
144
+ requirements: []
145
+ rubygems_version: 3.1.6
146
+ signing_key:
147
+ specification_version: 4
148
+ summary: Kabob cloud client library.
149
+ test_files: []