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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 95dea2e6c3cc040bb5763f782a1ff9c86364e10a
4
- data.tar.gz: caac9071b57094469954a0e31550cefede965f33
3
+ metadata.gz: '086ce26787c30d276a9de72dff92b763db3c21aa'
4
+ data.tar.gz: e119a89e89eecefedeb4958783baea8bfdd7d3b9
5
5
  SHA512:
6
- metadata.gz: 182a0b376f16072b292603ec418c0e9cd2a0504b1e44938af66dbe3c81272ae3a2c46a3a5347d916c1baadc37f3b9270ecd0184bd1919c2a918675f3b63c44b2
7
- data.tar.gz: f2c4734e53536e059fb50a49673a1120444ae325ba35adfc5e1a8fac355db20ad7f02517e2ce32cb8274545115228968c6bd9cf6f074bf5068ec137b36aa130a
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(server + action, query: query_params, basic_auth: basic_auth, header: { 'Content-Type' => 'application/json' })
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)
@@ -1,3 +1,3 @@
1
1
  module Kf5Api
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
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.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-15 00:00:00.000000000 Z
11
+ date: 2017-06-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler