kf5_api 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/kf5_api/base.rb +8 -1
- data/lib/kf5_api/version.rb +1 -1
- data/lib/kf5_api.rb +5 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '086ce26787c30d276a9de72dff92b763db3c21aa'
|
4
|
+
data.tar.gz: e119a89e89eecefedeb4958783baea8bfdd7d3b9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d095a03735399c502543ca7fced68bd14a600e616057395ae6306c3c91d3d16f3b3f3c8beec0155295bd7befa3e250f5d8f2ca9571370dc68fe037e6285bfaff
|
7
|
+
data.tar.gz: d68ae8ffcb37d65230efca346ab3c483579a567e2ed8c48eb7102042553838ffddd4644d0d97b267078eaa2ade6574727eac2bde94bfbd5a9499b9cf207355b0
|
data/lib/kf5_api/base.rb
CHANGED
@@ -4,9 +4,16 @@ module Kf5Api
|
|
4
4
|
module Base
|
5
5
|
def get(action, query_params = {})
|
6
6
|
server = "https://#{Kf5Api.config.sub_domain}.kf5.com"
|
7
|
+
url = server + action
|
7
8
|
query_params = query_params.inject({}){ |memo, (k,v)| memo[k.to_s] = v; memo }
|
8
9
|
|
9
|
-
HTTParty.get(
|
10
|
+
response = HTTParty.get(url, query: query_params, basic_auth: basic_auth, header: { 'Content-Type' => 'application/json' })
|
11
|
+
|
12
|
+
unless response.code == 200
|
13
|
+
Kf5Api.logger.error "[Kf5Api] url: #{url}, status: #{response.code}, body: #{response.parsed_response}"
|
14
|
+
end
|
15
|
+
|
16
|
+
response
|
10
17
|
end
|
11
18
|
|
12
19
|
def basic_auth(user_name = nil, password = nil, use_password = false)
|
data/lib/kf5_api/version.rb
CHANGED
data/lib/kf5_api.rb
CHANGED
@@ -4,6 +4,7 @@ require "kf5_api/base"
|
|
4
4
|
require "kf5_api/organization"
|
5
5
|
require "kf5_api/user"
|
6
6
|
require "kf5_api/kchat"
|
7
|
+
require "logger"
|
7
8
|
|
8
9
|
module Kf5Api
|
9
10
|
class << self
|
@@ -14,5 +15,9 @@ module Kf5Api
|
|
14
15
|
def config
|
15
16
|
@config ||= Configuration.new
|
16
17
|
end
|
18
|
+
|
19
|
+
def logger
|
20
|
+
@logger ||= Logger.new(STDOUT)
|
21
|
+
end
|
17
22
|
end
|
18
23
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kf5_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- wangrui
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-06-
|
11
|
+
date: 2017-06-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|