diff --git a/CHANGELOG.md b/CHANGELOG.md index fe05627..1c00410 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ ## 0.5.0 -* Add `token_info` [method](https://business-api.tiktok.com/portal/docs?id=1765927978092545) to validate TikTok profiles \ No newline at end of file +* Add `token_info` [method](https://business-api.tiktok.com/portal/docs?id=1765927978092545) to validate TikTok profiles + +## 0.5.1 + +* Use POST method for `token_info` request \ No newline at end of file diff --git a/lib/panda.rb b/lib/panda.rb index ce6c0fe..3a03b73 100644 --- a/lib/panda.rb +++ b/lib/panda.rb @@ -18,14 +18,14 @@ def config @config ||= Panda::Configuration.new end - def make_get_request(request) + def make_request(request) connection = Faraday.new do |conn| conn.use Panda::ErrorMiddleware conn.request :json conn.response :json end - response = connection.get(request.url, request.params, request.headers) + response = connection.run_request(request.method, request.url, request.params, request.headers) Panda::HTTPResponse.new(response.status, response.headers, response.body) end end diff --git a/lib/panda/client.rb b/lib/panda/client.rb index 19f563f..524cc6a 100644 --- a/lib/panda/client.rb +++ b/lib/panda/client.rb @@ -64,13 +64,13 @@ def token_info private def get_token(path, params = {}) - request = Panda::HTTPRequest.new('GET', path, params) - Panda::TokenInfo.new(Panda.make_get_request(request)) + request = Panda::HTTPRequest.new('POST', path, params) + Panda::TokenInfo.new(Panda.make_request(request)) end def get_collection(path, params = {}) request = Panda::HTTPRequest.new('GET', path, params, 'Access-Token' => access_token) - Panda::Collection.new(Panda.make_get_request(request), self) + Panda::Collection.new(Panda.make_request(request), self) end end end diff --git a/lib/panda/http_request.rb b/lib/panda/http_request.rb index 6a12f74..3eaabe9 100644 --- a/lib/panda/http_request.rb +++ b/lib/panda/http_request.rb @@ -1,6 +1,7 @@ # frozen_string_literal: true require 'panda/version' +require 'uri' module Panda class HTTPRequest @@ -13,10 +14,6 @@ def initialize(method, path, params = {}, headers = {}) @raw_headers = headers end - def method - raw_method - end - def url uri = URI.parse(Panda.config.api_base_url) uri.path = "/open_api/#{Panda.config.api_version}/#{raw_path}" @@ -39,10 +36,14 @@ def headers ) end + def method + raw_method.downcase.to_sym + end + private def get? - method == 'GET' + raw_method == 'GET' end end end diff --git a/lib/panda/version.rb b/lib/panda/version.rb index a0d50c5..38bf466 100644 --- a/lib/panda/version.rb +++ b/lib/panda/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module Panda - VERSION = '0.5.0' + VERSION = '0.5.1' end