oksky-chat-api 0.1.3 → 0.1.4

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
  SHA1:
3
- metadata.gz: 8665394fca4ddf8574dc33525b3a5263155a2575
4
- data.tar.gz: 9c3089ed53919ec7f8ca170dddc1b4dfc3f6411d
3
+ metadata.gz: 208df13505446839f47a4328ede2afee77509917
4
+ data.tar.gz: b0f36264a40750e663664689a03c72016e0f99c8
5
5
  SHA512:
6
- metadata.gz: a36b75c28839ddf938cba617a7d4b9c7ed02ad9a25a2067d283cb729421a50b12cfcb9ced54b5b92d40d2ba2573ab9b86f75c545253b1e59665c84c5b6e8f153
7
- data.tar.gz: ba759dc99ef29792948be245dec4023fe1b202f96f6ccfedd7277118db39a931386e88867057d15f44e4e4ceb6cc629add52f064f2d449e124aec13bc4151cd4
6
+ metadata.gz: dd4308f0100d171a328b94fba1732b033f981413ff650ec3ce3dd17f241d74e9a01c8d04af015cac3539301f8fd85396556b26b9f1b4b7d143fc74f67adb6613
7
+ data.tar.gz: 39002fa802b66bf67ece97d4ce05159cf6a1f1cdba7de6b4204f92f02b83af0dcc0cb3de51a40bfdd3d94bd03e11d68d875f25c6176f1f0fec7b65e5f82cdff1
@@ -1,7 +1,7 @@
1
1
  module Oksky
2
2
  module Chat
3
3
  module API
4
- VERSION = "0.1.3"
4
+ VERSION = "0.1.4"
5
5
  end
6
6
  end
7
7
  end
@@ -62,7 +62,7 @@ module Oksky
62
62
  # @return [Oksky::Chat::Event::Message]
63
63
  def get_message_content(message_id, option = {}, is_parse = true)
64
64
  endpoint_path = "/messages/#{message_id}"
65
- result = get(endpoint_path)
65
+ result = get(endpoint_path, option)
66
66
 
67
67
  if is_parse
68
68
  json = JSON.parse(result.body)
@@ -85,6 +85,7 @@ module Oksky
85
85
  config.endpoint = endpoint
86
86
  config.endpoint_path = endpoint_path
87
87
  config.credentials = credentials
88
+ config.payload = option
88
89
  end
89
90
 
90
91
  request.get
@@ -66,6 +66,7 @@ module Oksky
66
66
  config.endpoint = endpoint
67
67
  config.endpoint_path = endpoint_path
68
68
  config.credentials = credentials
69
+ config.payload = option
69
70
  end
70
71
 
71
72
  request.get
@@ -60,6 +60,7 @@ module Oksky
60
60
  config.endpoint = endpoint
61
61
  config.endpoint_path = endpoint_path
62
62
  config.credentials = credentials
63
+ config.payload = option
63
64
  end
64
65
 
65
66
  request.get
@@ -42,9 +42,13 @@ module Oksky
42
42
 
43
43
  if is_parse
44
44
  json = JSON.parse(result.body)
45
- json["data"].map{|d|
46
- Oksky::Chat::Event::Support.new(d)
47
- }
45
+ if json.has_key?("data") && !json["data"].empty?
46
+ json["data"].map{|d|
47
+ Oksky::Chat::Event::Support.new(d)
48
+ }
49
+ else
50
+ return []
51
+ end
48
52
  else
49
53
  return result
50
54
  end
@@ -75,16 +79,12 @@ module Oksky
75
79
  def get(endpoint_path, option = {})
76
80
  raise Oksky::Chat::API::InvalidCredentialsError, 'Invalidates credentials' unless credentials?
77
81
 
78
- unless option.empty?
79
- params = URI.encode_www_form(option)
80
- endpoint_path = "#{endpoint_path}?#{params}"
81
- end
82
-
83
82
  request = Request.new do |config|
84
83
  config.httpclient = httpclient
85
84
  config.endpoint = endpoint
86
85
  config.endpoint_path = endpoint_path
87
86
  config.credentials = credentials
87
+ config.payload = option
88
88
  end
89
89
 
90
90
  request.get
@@ -14,11 +14,16 @@ module Oksky
14
14
  http.use_ssl = true
15
15
  end
16
16
 
17
+ http.set_debug_output($stderr) if ENV["RAILS_ENV"] == "development"
18
+
17
19
  http
18
20
  end
19
21
 
20
- def get(url, header = {})
22
+ def get(url, payload = {}, header = {})
21
23
  uri = URI(url)
24
+ unless payload.empty?
25
+ uri.query = URI.encode_www_form(payload)
26
+ end
22
27
  http(uri).get(uri.request_uri, header)
23
28
  end
24
29
 
@@ -17,7 +17,7 @@ module Oksky
17
17
 
18
18
  # @return [Hash]
19
19
  def payload
20
- !@payload.empty? && @payload.kind_of?(Hash) ? @payload.delete_if{|k, v| v.nil?}.to_json : {}
20
+ !@payload.empty? && @payload.kind_of?(Hash) ? @payload.delete_if{|k, v| v.nil?} : {}
21
21
  end
22
22
 
23
23
  # @return [Hash]
@@ -37,7 +37,7 @@ module Oksky
37
37
  # @return [Net::HTTPResponse]
38
38
  def get
39
39
  assert_for_getting_message
40
- httpclient.get(endpoint + endpoint_path, header)
40
+ httpclient.get(endpoint + endpoint_path, payload, header)
41
41
  end
42
42
 
43
43
  # Post content of specified URL.
@@ -47,7 +47,7 @@ module Oksky
47
47
  # @return [Net::HTTPResponse]
48
48
  def post
49
49
  assert_for_posting_message
50
- httpclient.post(endpoint + endpoint_path, payload, header)
50
+ httpclient.post(endpoint + endpoint_path, payload.to_json, header)
51
51
  end
52
52
 
53
53
  def assert_for_getting_message
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: oksky-chat-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - SOLAIRO, INC.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-10-23 00:00:00.000000000 Z
11
+ date: 2017-10-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler