Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use POST method for token request #11

Merged
merged 1 commit into from
Jan 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.5.0

* Add `token_info` [method](https://business-api.tiktok.com/portal/docs?id=1765927978092545) to validate TikTok profiles
* 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
4 changes: 2 additions & 2 deletions lib/panda.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions lib/panda/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
11 changes: 6 additions & 5 deletions lib/panda/http_request.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# frozen_string_literal: true

require 'panda/version'
require 'uri'

module Panda
class HTTPRequest
Expand All @@ -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}"
Expand All @@ -39,10 +36,14 @@ def headers
)
end

def method
raw_method.downcase.to_sym
end

private

def get?
AlphaB marked this conversation as resolved.
Show resolved Hide resolved
method == 'GET'
raw_method == 'GET'
end
end
end
2 changes: 1 addition & 1 deletion lib/panda/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module Panda
VERSION = '0.5.0'
VERSION = '0.5.1'
end
Loading