k3cloud-sdk 0.1.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ad64f7624e0d670b5fc3d43a49469b5be650c796c2deb24588e281d84eb62867
4
- data.tar.gz: 512b3585e661e58446308a29bdcbd2af95361805aa5802c230d6191b258847a9
3
+ metadata.gz: c9f13e7dae26d950dec804b2dcfc315d6f8a5ed08e23b69c9443d17f8a0bde77
4
+ data.tar.gz: 43c42ac730bf506a61b5ea51a33036579096c34fa06345fb598e27b7011622c3
5
5
  SHA512:
6
- metadata.gz: c5cc429bb8215e212b49d292da775561c774f7fb8258c9ce1249d4cfae071a51d7b91a9a0e35f67e5670d563b28221e1d434ed0eb0690d2b7ccdf177263f5dde
7
- data.tar.gz: 21485935926a10a96f5e7258463f84281e3c06ef4bf68149be7ed30b1a2809cb30034db4a7c0673589d14bcc84a4b6ad40c34cfda990a7d4f6e1b4c42ed28cec
6
+ metadata.gz: 033b860f4d85d5ce6e4b8599e8cd8ba9f95c065c470b4618a39205fb28852bf4dedd701a06f8ee2b6a357d33d910efb9ecc249baa2e353e932ddc1d4f3c458dc
7
+ data.tar.gz: '082ff58a369c49835fe6c71f7abaebf580401d9f3ee3bef41e0451511b72ee32daffa5d4c90a5c5966cc9ca18506cd535618b51ae9e22c00a9869838729c23b2'
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- k3cloud-sdk (0.1.0)
4
+ k3cloud-sdk (0.3.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -13,6 +13,7 @@ If bundler is not being used to manage dependencies, install the gem by executin
13
13
 
14
14
  ## Usage
15
15
 
16
+ #### 1. Single Account Configuration:
16
17
  You'll need to configure it in `config/initializers/k3cloud.rb`:
17
18
 
18
19
  ```ruby
@@ -35,6 +36,41 @@ Then you can call the k3cloud API using the following code:
35
36
  K3cloud.execute_bill_query(data)
36
37
  ```
37
38
 
39
+ #### 2. Multi Account Configuration:
40
+ You'll need to configure it in `config/initializers/k3cloud.rb`:
41
+
42
+ ```ruby
43
+ config1 = K3cloud::Configuration.new do |c|
44
+ c.acct_id = ENV['K3CLOUD1_ACCT_ID']
45
+ c.user_name = ENV['K3CLOUD1_USERNAME']
46
+ c.app_id = ENV['K3CLOUD1_APP_ID']
47
+ c.app_secret= ENV['K3CLOUD1_APP_SECRET']
48
+ c.server_url = ENV['K3CLOUD1_SERVER_URL']
49
+ end
50
+
51
+ config2 = K3cloud::Configuration.new do |c|
52
+ c.acct_id = ENV['K3CLOUD2_ACCT_ID']
53
+ c.user_name = ENV['K3CLOUD2_USERNAME']
54
+ c.app_id = ENV['K3CLOUD2_APP_ID']
55
+ c.app_secret= ENV['K3CLOUD2_APP_SECRET']
56
+ c.server_url = ENV['K3CLOUD2_SERVER_URL']
57
+ end
58
+
59
+ K3cloud1 = K3cloud.new_api(config1)
60
+ K3cloud2 = K3cloud.new_api(config2)
61
+ ```
62
+
63
+ Then you can call the k3cloud API using the following code:
64
+ ```ruby
65
+ data = {
66
+ FormId: "",
67
+ FieldKeys: "",
68
+ FilterString: ""
69
+ }
70
+ K3cloud1.execute_bill_query(data)
71
+ K3cloud2.execute_bill_query(data)
72
+ ```
73
+
38
74
  ## Development
39
75
 
40
76
  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.
@@ -31,7 +31,17 @@ module K3cloud
31
31
 
32
32
  attr_accessor :connect_timeout, :request_timeout
33
33
 
34
- def initialize
34
+ def initialize(options = {})
35
+ @acct_id = options[:acct_id]
36
+ @user_name = options[:user_name]
37
+ @password = options[:password]
38
+ @app_id = options[:app_id]
39
+ @app_secret = options[:app_secret]
40
+ @server_url = options[:server_url]
41
+ @org_num = options[:org_num]
42
+ @connect_timeout = options[:connect_timeout]
43
+ @request_timeout = options[:request_timeout]
44
+
35
45
  yield(self) if block_given?
36
46
  end
37
47
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module K3cloud
4
- VERSION = "0.1.0"
4
+ VERSION = "0.3.0"
5
5
  end
data/lib/k3cloud.rb CHANGED
@@ -22,11 +22,15 @@ module K3cloud
22
22
  @logger ||= ::Logger.new($stderr)
23
23
  end
24
24
 
25
- def api
26
- @api ||= K3cloud::K3cloudApi.new
25
+ def new_api(config = nil)
26
+ if config
27
+ K3cloud::K3cloudApi.new(config)
28
+ else
29
+ @default_api ||= K3cloud::K3cloudApi.new
30
+ end
27
31
  end
28
32
 
29
- def_delegators :api, :draft, :save, :batch_save, :submit, :audit, :un_audit, :view, :execute_bill_query, :delete,
33
+ def_delegators :new_api, :draft, :save, :batch_save, :submit, :audit, :un_audit, :view, :execute_bill_query, :delete,
30
34
  :cancel_assign, :push, :execute_operation, :allocate, :cancel_allocate, :group_save, :query_group_info,
31
35
  :group_delete, :attachment_upload, :attachment_download, :query_business_info, :get_sys_report_data,
32
36
  :flex_save, :send_msg, :disassembly, :workflow_audit, :switch_org
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: k3cloud-sdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - zevinto
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-09-26 00:00:00.000000000 Z
11
+ date: 2023-11-14 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Ruby Gem for K3cloud API.
14
14
  email:
@@ -29,7 +29,7 @@ files:
29
29
  - bin/console
30
30
  - bin/setup
31
31
  - k3cloud.gemspec
32
- - lib/K3cloud-sdk.rb
32
+ - lib/k3cloud-sdk.rb
33
33
  - lib/k3cloud.rb
34
34
  - lib/k3cloud/configuration.rb
35
35
  - lib/k3cloud/errors/k3cloud_error.rb
File without changes