Compare commits
4 Commits
027b125285
...
f0846308da
Author | SHA1 | Date | |
---|---|---|---|
f0846308da | |||
b3b7fe6359 | |||
f0b541ee50 | |||
df9077e3c1 |
@ -4,19 +4,19 @@
|
||||
class BtcpayManagerService < RestApiService
|
||||
private
|
||||
|
||||
def base_url
|
||||
@base_url ||= "#{Setting.btcpay_api_url}/stores/#{Setting.btcpay_store_id}"
|
||||
end
|
||||
def base_url
|
||||
@base_url ||= "#{Setting.btcpay_api_url}/stores/#{Setting.btcpay_store_id}"
|
||||
end
|
||||
|
||||
def auth_token
|
||||
@auth_token ||= Setting.btcpay_auth_token
|
||||
end
|
||||
def auth_token
|
||||
@auth_token ||= Setting.btcpay_auth_token
|
||||
end
|
||||
|
||||
def headers
|
||||
{
|
||||
"Content-Type" => "application/json",
|
||||
"Accept" => "application/json",
|
||||
"Authorization" => "token #{auth_token}"
|
||||
}
|
||||
end
|
||||
def headers
|
||||
{
|
||||
"Content-Type" => "application/json",
|
||||
"Accept" => "application/json",
|
||||
"Authorization" => "token #{auth_token}"
|
||||
}
|
||||
end
|
||||
end
|
||||
|
@ -4,19 +4,19 @@
|
||||
class MastodonManagerService < RestApiService
|
||||
private
|
||||
|
||||
def base_url
|
||||
@base_url ||= "#{Setting.mastodon_public_url}/api"
|
||||
end
|
||||
def base_url
|
||||
@base_url ||= "#{Setting.mastodon_public_url}/api"
|
||||
end
|
||||
|
||||
def auth_token
|
||||
@auth_token ||= Setting.mastodon_auth_token
|
||||
end
|
||||
def auth_token
|
||||
@auth_token ||= Setting.mastodon_auth_token
|
||||
end
|
||||
|
||||
def headers
|
||||
{
|
||||
"Content-Type" => "application/json",
|
||||
"Accept" => "application/json",
|
||||
"Authorization" => "Bearer #{auth_token}"
|
||||
}
|
||||
end
|
||||
def headers
|
||||
{
|
||||
"Content-Type" => "application/json",
|
||||
"Accept" => "application/json",
|
||||
"Authorization" => "Bearer #{auth_token}"
|
||||
}
|
||||
end
|
||||
end
|
||||
|
@ -1,27 +1,27 @@
|
||||
class RestApiService < ApplicationService
|
||||
private
|
||||
|
||||
def base_url
|
||||
raise NotImplementedError
|
||||
end
|
||||
def base_url
|
||||
raise NotImplementedError
|
||||
end
|
||||
|
||||
def headers
|
||||
raise NotImplementedError
|
||||
end
|
||||
def headers
|
||||
raise NotImplementedError
|
||||
end
|
||||
|
||||
def endpoint_url(path)
|
||||
"#{base_url}/#{path.gsub(/^\//, '')}"
|
||||
end
|
||||
def endpoint_url(path)
|
||||
"#{base_url}/#{path.gsub(/^\//, '')}"
|
||||
end
|
||||
|
||||
def get(path, params = {})
|
||||
res = Faraday.get endpoint_url(path), params, headers
|
||||
# TODO handle unsuccessful responses with no valid JSON body
|
||||
JSON.parse(res.body)
|
||||
end
|
||||
def get(path, params = {})
|
||||
res = Faraday.get endpoint_url(path), params, headers
|
||||
# TODO handle unsuccessful responses with no valid JSON body
|
||||
JSON.parse(res.body)
|
||||
end
|
||||
|
||||
def post(path, payload)
|
||||
res = Faraday.post endpoint_url(path), payload.to_json, headers
|
||||
# TODO handle unsuccessful responses with no valid JSON body
|
||||
JSON.parse(res.body)
|
||||
end
|
||||
def post(path, payload)
|
||||
res = Faraday.post endpoint_url(path), payload.to_json, headers
|
||||
# TODO handle unsuccessful responses with no valid JSON body
|
||||
JSON.parse(res.body)
|
||||
end
|
||||
end
|
||||
|
@ -11,6 +11,8 @@ module UserManager
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def import_remote_avatar
|
||||
tempfile = Down.download(@avatar_url)
|
||||
content_type = tempfile.content_type
|
||||
|
Loading…
x
Reference in New Issue
Block a user