yx_sdk 0.1.6 → 0.1.7

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: 9f10018fd4d430ca1dfc8eecd3985ac4107ec08e
4
- data.tar.gz: 9f0245f8a7b2201a89f0b8881cbac0ae75120b54
3
+ metadata.gz: 2650aa7f15f87cd3340404fcde01e6802efbb4d8
4
+ data.tar.gz: b5653c66c55dbfe8f8c93d9d7410d46ac22ed2ad
5
5
  SHA512:
6
- metadata.gz: 21920443bea67e74284c189b1be1beac8324d1bbe78df7689fb8d8249c697dba7a2f15f020aafa6e5ad7b54f52d1d4a954a5ea0cd4bad12a0ae40d994c7693f1
7
- data.tar.gz: 44bd8e6f1c54aa861f9da4e9f77165a00c45b727ee268e273a9160890e69542ec640c08a945dca7804595c026c039388cc661611adc539980af6d85f524ebc97
6
+ metadata.gz: e13c22362fb1bcec94af0baf5cc0a26399eaf98eb5b44f18f028c74129d1b7fe3fdbcac9510978dd0b0c92103592e4cd7b08d650a9a35c4653c4982e9f58334d
7
+ data.tar.gz: 45b36f2befe07707e2ac112c3b8f5c8b79733951a16f949897d7e25fcc033333181bad49db8fc0d3973efcfddf8a1f70a23967e0655253b93b5dc16dcf995ef0
data/lib/yx_sdk.rb CHANGED
@@ -3,7 +3,11 @@ require "yx_sdk/version"
3
3
  require "yx_sdk/handler/result_handler"
4
4
  require "yx_sdk/api"
5
5
  require "yx_sdk/client"
6
-
6
+ if defined? Yajl
7
+ require 'yajl/json_gem'
8
+ else
9
+ require "json"
10
+ end
7
11
 
8
12
  module YxSdk
9
13
 
@@ -11,24 +15,25 @@ module YxSdk
11
15
 
12
16
  class << self
13
17
 
14
- def http_post_without_token(url, post_body={}, url_params={}, header = {}, endpoint="plain")
18
+ def http_post_without_token(url, url_params={}, header = {}, endpoint="plain")
15
19
  post_api_url = endpoint_url(endpoint, url)
20
+ post_body = ''
16
21
  if endpoint == "plain" || endpoint == CUSTOM_ENDPOINT
17
- post_body = JSON.dump(post_body)
22
+ url_params.each {|k,v| post_body = post_body + "#{k}=#{v}&"}
18
23
  end
19
- logger.info("request url is #{post_api_url}, header is #{header}")
20
- load_json(resource(post_api_url, header).post(post_body, params: url_params))
24
+ puts "request url is #{post_api_url}, header is #{header}, post_body is #{post_body[0..-1]}"
25
+ load_json(resource(post_api_url, header).post(post_body[0..-1]))
21
26
  end
22
27
 
23
28
 
24
29
  def resource(url, header)
25
- RestClient::Resource.new(url, header)
30
+ RestClient::Resource.new(url, :headers => header)
26
31
  end
27
32
 
28
33
  # return hash
29
34
  def load_json(string)
30
35
  result_hash = JSON.parse(string.force_encoding("UTF-8").gsub(/[\u0011-\u001F]/, ""))
31
- logger.info "response #{result_hash}"
36
+ puts "response #{result_hash}"
32
37
  code = result_hash.delete("code")
33
38
  info = result_hash.delete("info")
34
39
  ResultHandler.new(code, info)
data/lib/yx_sdk/client.rb CHANGED
@@ -13,9 +13,9 @@ module YxSdk
13
13
  end
14
14
 
15
15
  # 暴露出:http_get,http_post两个方法,方便第三方开发者扩展未开发的微信API。
16
- def http_post(url, post_body={}, url_params={}, endpoint="plain")
16
+ def http_post(url, url_params={}, endpoint="plain")
17
17
  # url_params = url_params.merge(access_token_param)
18
- YxSdk.http_post_without_token(url, post_body, url_params, get_header, endpoint)
18
+ YxSdk.http_post_without_token(url, url_params, get_header, endpoint)
19
19
  end
20
20
 
21
21
  def get_header
@@ -1,3 +1,3 @@
1
1
  module YxSdk
2
- VERSION = "0.1.6"
2
+ VERSION = "0.1.7"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yx_sdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - karidyang