FIX: Remove dependency on rest-client.

This commit is contained in:
Guo Xiang Tan
2017-06-16 09:08:15 +09:00
parent cae09ee4c8
commit d82dbd565b
10 changed files with 34 additions and 45 deletions

View File

@ -1,4 +1,3 @@
require_dependency 'rest_client'
require_dependency 'version'
module DiscourseHub
@ -41,11 +40,19 @@ module DiscourseHub
end
def self.singular_action(action, rel_url, params={})
JSON.parse RestClient.send(action, "#{hub_base_url}#{rel_url}", {params: params, accept: accepts, referer: referer } )
JSON.parse(Excon.send(action,
"#{hub_base_url}#{rel_url}",
body: params.to_query,
headers: { 'Referer' => referer, 'Accept' => accepts.join(', ') }
).body)
end
def self.collection_action(action, rel_url, params={})
JSON.parse RestClient.send(action, "#{hub_base_url}#{rel_url}", params, content_type: :json, accept: accepts, referer: referer )
JSON.parse(Excon.send(action,
"#{hub_base_url}#{rel_url}",
body: params,
headers: { 'Referer' => referer, 'Accept' => accepts.join(', '), 'Content-Type' => 'applicaton/json' }
).body)
end
def self.hub_base_url
@ -57,7 +64,7 @@ module DiscourseHub
end
def self.accepts
[:json, 'application/vnd.discoursehub.v1']
['application/json', 'application/vnd.discoursehub.v1']
end
def self.referer