k3cloud-sdk 0.2.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: 1200e70367f5dd2d10e943d9d58b391bf014250556fba2fbd6f567012399c870
4
- data.tar.gz: 0e7ceab95445f1347f2aa56b89a7615c361bc436586141c9e92871ec639973f3
3
+ metadata.gz: c9f13e7dae26d950dec804b2dcfc315d6f8a5ed08e23b69c9443d17f8a0bde77
4
+ data.tar.gz: 43c42ac730bf506a61b5ea51a33036579096c34fa06345fb598e27b7011622c3
5
5
  SHA512:
6
- metadata.gz: 4ad24fe15d838fec3ebc2e970fd502a9f38aa71a59b249f244b3aa24c6d9812aef2b619d8486b4a7a9cf8fd57c66714e3e36a643e1c1082bbb8d44a44741bafb
7
- data.tar.gz: 1fb9f1e076dcc3db553cfda0e7c89fc09b5bd7d2942981dd36821a6134c5a7591b119b5cb97a25078498b5b14eac4b6530f61c38ef2a45de2928499065d43bd2
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.2.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.2.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.2.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-10-09 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: