k3cloud-sdk 0.2.0 → 0.4.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1200e70367f5dd2d10e943d9d58b391bf014250556fba2fbd6f567012399c870
4
- data.tar.gz: 0e7ceab95445f1347f2aa56b89a7615c361bc436586141c9e92871ec639973f3
3
+ metadata.gz: 3fcdb39f0120d7be1d75b2b05088eae22fd6ac5d3fdb422bf25f6a472b729fb3
4
+ data.tar.gz: 36d2bf34f18781c5a7574b03cbe62dcdbbba8e20b2c63b23860e7c08dc3e9aac
5
5
  SHA512:
6
- metadata.gz: 4ad24fe15d838fec3ebc2e970fd502a9f38aa71a59b249f244b3aa24c6d9812aef2b619d8486b4a7a9cf8fd57c66714e3e36a643e1c1082bbb8d44a44741bafb
7
- data.tar.gz: 1fb9f1e076dcc3db553cfda0e7c89fc09b5bd7d2942981dd36821a6134c5a7591b119b5cb97a25078498b5b14eac4b6530f61c38ef2a45de2928499065d43bd2
6
+ metadata.gz: c72cc86924e218be315fb570958bd9289c58a475cc4ac6014de43447030c5f09ab642d784601e5acfea43fdefe0788bcb8ccfa9cb38e221bc549d139180bd80d
7
+ data.tar.gz: 311051445ab1bb7b3dd719aa17a34538337be2edafce4ce094404fc7d80e2b8b1f0549820f1ee66a3a6bc822f1606cf59af0b9f13f749ae0185e4f5882f6a725
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.4.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
 
@@ -14,7 +14,7 @@ class K3cloudError < StandardError
14
14
 
15
15
  def self.parse(json)
16
16
  index = json.index("{")
17
- json = json[index..] if index >= 0
17
+ json = json[index..-1] if index >= 0
18
18
 
19
19
  parsed_json = JSON.parse(json)
20
20
  kd_error = K3cloudError.new
@@ -11,7 +11,7 @@ module MD5Utils
11
11
  result = ""
12
12
 
13
13
  s.each_byte do |byte|
14
- result += (byte & 0xFF | -256).to_s(16)[6..]
14
+ result += (byte & 0xFF | -256).to_s(16)[6..-1]
15
15
  end
16
16
 
17
17
  result
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module K3cloud
4
- VERSION = "0.2.0"
4
+ VERSION = "0.4.0"
5
5
  end
@@ -58,7 +58,7 @@ module K3cloud
58
58
  def get_url_path(url)
59
59
  if url.start_with?("http")
60
60
  index = url.index("/", 10)
61
- index.nil? ? url : url[index..]
61
+ index.nil? ? url : url[index..-1]
62
62
  else
63
63
  url
64
64
  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.4.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-17 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Ruby Gem for K3cloud API.
14
14
  email: